Skip to content

Commit a5a6f6c

Browse files
renaming
1 parent 1ac0c76 commit a5a6f6c

6 files changed

Lines changed: 35 additions & 37 deletions

File tree

cpp/src/arrow/buffer_test.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,13 +1027,13 @@ TEST(TestDeviceRegistry, Basics) {
10271027
// Test the error cases for the device registry
10281028

10291029
// CPU is already registered
1030-
ASSERT_RAISES(KeyError, RegisterDeviceMemoryManager(
1031-
DeviceAllocationType::kCPU, [](int64_t device_id) {
1032-
return default_cpu_memory_manager();
1033-
}));
1030+
ASSERT_RAISES(KeyError,
1031+
RegisterDeviceMapper(DeviceAllocationType::kCPU, [](int64_t device_id) {
1032+
return default_cpu_memory_manager();
1033+
}));
10341034

10351035
// VPI is not registered
1036-
ASSERT_RAISES(KeyError, GetDeviceMemoryManager(DeviceAllocationType::kVPI));
1036+
ASSERT_RAISES(KeyError, GetDeviceMapper(DeviceAllocationType::kVPI));
10371037
}
10381038

10391039
} // namespace arrow

cpp/src/arrow/c/bridge.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,10 +1967,10 @@ Result<std::shared_ptr<RecordBatch>> ImportRecordBatch(struct ArrowArray* array,
19671967
return ImportRecordBatch(array, *maybe_schema);
19681968
}
19691969

1970-
Result<std::shared_ptr<MemoryManager>> DefaultDeviceMapper(ArrowDeviceType device_type,
1971-
int64_t device_id) {
1972-
ARROW_ASSIGN_OR_RAISE(auto mapper, GetDeviceMemoryManager(
1973-
static_cast<DeviceAllocationType>(device_type)));
1970+
Result<std::shared_ptr<MemoryManager>> DefaultDeviceMemoryMapper(
1971+
ArrowDeviceType device_type, int64_t device_id) {
1972+
ARROW_ASSIGN_OR_RAISE(auto mapper,
1973+
GetDeviceMapper(static_cast<DeviceAllocationType>(device_type)));
19741974
return mapper(device_id);
19751975
}
19761976

cpp/src/arrow/c/bridge.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ using DeviceMemoryMapper =
219219
std::function<Result<std::shared_ptr<MemoryManager>>(ArrowDeviceType, int64_t)>;
220220

221221
ARROW_EXPORT
222-
Result<std::shared_ptr<MemoryManager>> DefaultDeviceMapper(ArrowDeviceType device_type,
223-
int64_t device_id);
222+
Result<std::shared_ptr<MemoryManager>> DefaultDeviceMemoryMapper(
223+
ArrowDeviceType device_type, int64_t device_id);
224224

225225
/// \brief EXPERIMENTAL: Import C++ device array from the C data interface.
226226
///
@@ -236,7 +236,7 @@ Result<std::shared_ptr<MemoryManager>> DefaultDeviceMapper(ArrowDeviceType devic
236236
ARROW_EXPORT
237237
Result<std::shared_ptr<Array>> ImportDeviceArray(
238238
struct ArrowDeviceArray* array, std::shared_ptr<DataType> type,
239-
const DeviceMemoryMapper& mapper = DefaultDeviceMapper);
239+
const DeviceMemoryMapper& mapper = DefaultDeviceMemoryMapper);
240240

241241
/// \brief EXPERIMENTAL: Import C++ device array and its type from the C data interface.
242242
///
@@ -253,7 +253,7 @@ Result<std::shared_ptr<Array>> ImportDeviceArray(
253253
ARROW_EXPORT
254254
Result<std::shared_ptr<Array>> ImportDeviceArray(
255255
struct ArrowDeviceArray* array, struct ArrowSchema* type,
256-
const DeviceMemoryMapper& mapper = DefaultDeviceMapper);
256+
const DeviceMemoryMapper& mapper = DefaultDeviceMemoryMapper);
257257

258258
/// \brief EXPERIMENTAL: Import C++ record batch with buffers on a device from the C data
259259
/// interface.
@@ -271,7 +271,7 @@ Result<std::shared_ptr<Array>> ImportDeviceArray(
271271
ARROW_EXPORT
272272
Result<std::shared_ptr<RecordBatch>> ImportDeviceRecordBatch(
273273
struct ArrowDeviceArray* array, std::shared_ptr<Schema> schema,
274-
const DeviceMemoryMapper& mapper = DefaultDeviceMapper);
274+
const DeviceMemoryMapper& mapper = DefaultDeviceMemoryMapper);
275275

276276
/// \brief EXPERIMENTAL: Import C++ record batch with buffers on a device and its schema
277277
/// from the C data interface.
@@ -291,7 +291,7 @@ Result<std::shared_ptr<RecordBatch>> ImportDeviceRecordBatch(
291291
ARROW_EXPORT
292292
Result<std::shared_ptr<RecordBatch>> ImportDeviceRecordBatch(
293293
struct ArrowDeviceArray* array, struct ArrowSchema* schema,
294-
const DeviceMemoryMapper& mapper = DefaultDeviceMapper);
294+
const DeviceMemoryMapper& mapper = DefaultDeviceMemoryMapper);
295295

296296
/// @}
297297

cpp/src/arrow/device.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ std::shared_ptr<MemoryManager> CPUDevice::default_memory_manager() {
272272

273273
namespace {
274274

275-
class DeviceMemoryManagerRegistryImpl {
275+
class DeviceMapperRegistryImpl {
276276
public:
277-
DeviceMemoryManagerRegistryImpl() {}
277+
DeviceMapperRegistryImpl() {}
278278

279-
Status RegisterDevice(DeviceAllocationType device_type, MemoryMapper memory_mapper) {
279+
Status RegisterDevice(DeviceAllocationType device_type, DeviceMapper memory_mapper) {
280280
std::lock_guard<std::mutex> lock(lock_);
281281
auto [_, inserted] = registry_.try_emplace(device_type, std::move(memory_mapper));
282282
if (!inserted) {
@@ -286,7 +286,7 @@ class DeviceMemoryManagerRegistryImpl {
286286
return Status::OK();
287287
}
288288

289-
Result<MemoryMapper> GetMemoryManager(DeviceAllocationType device_type) {
289+
Result<DeviceMapper> GetMapper(DeviceAllocationType device_type) {
290290
std::lock_guard<std::mutex> lock(lock_);
291291
auto it = registry_.find(device_type);
292292
if (it == registry_.end()) {
@@ -298,38 +298,38 @@ class DeviceMemoryManagerRegistryImpl {
298298

299299
private:
300300
std::mutex lock_;
301-
std::unordered_map<DeviceAllocationType, MemoryMapper> registry_;
301+
std::unordered_map<DeviceAllocationType, DeviceMapper> registry_;
302302
};
303303

304-
Result<std::shared_ptr<MemoryManager>> DefaultCPUMemoryMapper(int64_t device_id) {
304+
Result<std::shared_ptr<MemoryManager>> DefaultCPUDeviceMapper(int64_t device_id) {
305305
return default_cpu_memory_manager();
306306
}
307307

308-
static std::unique_ptr<DeviceMemoryManagerRegistryImpl> CreateDeviceRegistry() {
309-
auto registry = std::make_unique<DeviceMemoryManagerRegistryImpl>();
308+
static std::unique_ptr<DeviceMapperRegistryImpl> CreateDeviceRegistry() {
309+
auto registry = std::make_unique<DeviceMapperRegistryImpl>();
310310

311311
// Always register the CPU device
312-
DCHECK_OK(registry->RegisterDevice(DeviceAllocationType::kCPU, DefaultCPUMemoryMapper));
312+
DCHECK_OK(registry->RegisterDevice(DeviceAllocationType::kCPU, DefaultCPUDeviceMapper));
313313

314314
return registry;
315315
}
316316

317-
DeviceMemoryManagerRegistryImpl* GetDeviceRegistry() {
317+
DeviceMapperRegistryImpl* GetDeviceRegistry() {
318318
static auto g_registry = CreateDeviceRegistry();
319319
return g_registry.get();
320320
}
321321

322322
} // namespace
323323

324-
Status RegisterDeviceMemoryManager(DeviceAllocationType device_type,
325-
MemoryMapper memory_mapper) {
324+
Status RegisterDeviceMapper(DeviceAllocationType device_type,
325+
DeviceMapper mapper) {
326326
auto registry = GetDeviceRegistry();
327-
return registry->RegisterDevice(device_type, std::move(memory_mapper));
327+
return registry->RegisterDevice(device_type, std::move(mapper));
328328
}
329329

330-
Result<MemoryMapper> GetDeviceMemoryManager(DeviceAllocationType device_type) {
330+
Result<DeviceMapper> GetDeviceMapper(DeviceAllocationType device_type) {
331331
auto registry = GetDeviceRegistry();
332-
return registry->GetMemoryManager(device_type);
332+
return registry->GetMapper(device_type);
333333
}
334334

335335
} // namespace arrow

cpp/src/arrow/device.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class ARROW_EXPORT CPUMemoryManager : public MemoryManager {
363363
ARROW_EXPORT
364364
std::shared_ptr<MemoryManager> default_cpu_memory_manager();
365365

366-
using MemoryMapper =
366+
using DeviceMapper =
367367
std::function<Result<std::shared_ptr<MemoryManager>>(int64_t device_id)>;
368368

369369
/// \brief Register a function to retrieve a MemoryManager for a Device type
@@ -380,8 +380,7 @@ using MemoryMapper =
380380
/// MemoryManager for the registered device type and given device id
381381
/// \return Status
382382
ARROW_EXPORT
383-
Status RegisterDeviceMemoryManager(DeviceAllocationType device_type,
384-
MemoryMapper memory_mapper);
383+
Status RegisterDeviceMapper(DeviceAllocationType device_type, DeviceMapper mapper);
385384

386385
/// \brief Get the registered function to retrieve a MemoryManager for the
387386
/// given Device type
@@ -390,6 +389,6 @@ Status RegisterDeviceMemoryManager(DeviceAllocationType device_type,
390389
/// \return function that takes a device id and returns the appropriate
391390
/// MemoryManager for the registered device type and given device id
392391
ARROW_EXPORT
393-
Result<MemoryMapper> GetDeviceMemoryManager(DeviceAllocationType device_type);
392+
Result<DeviceMapper> GetDeviceMapper(DeviceAllocationType device_type);
394393

395394
} // namespace arrow

cpp/src/arrow/gpu/cuda_memory.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,13 @@ Result<std::shared_ptr<MemoryManager>> DefaultMemoryMapper(ArrowDeviceType devic
504504

505505
namespace {
506506

507-
Result<std::shared_ptr<MemoryManager>> DefaultCUDAMemoryMapper(int64_t device_id) {
507+
Result<std::shared_ptr<MemoryManager>> DefaultCUDADeviceMapper(int64_t device_id) {
508508
ARROW_ASSIGN_OR_RAISE(auto device, arrow::cuda::CudaDevice::Make(device_id));
509509
return device->default_memory_manager();
510510
}
511511

512512
bool RegisterCUDADeviceInternal() {
513-
DCHECK_OK(
514-
RegisterDeviceMemoryManager(DeviceAllocationType::kCUDA, DefaultCUDAMemoryMapper));
513+
DCHECK_OK(RegisterDeviceMapper(DeviceAllocationType::kCUDA, DefaultCUDADeviceMapper));
515514
// TODO add the CUDA_HOST and CUDA_MANAGED allocation types when they are supported in
516515
// the CudaDevice
517516
return true;

0 commit comments

Comments
 (0)