Skip to content

Commit 036953c

Browse files
Merge pull request #1725 from arcaneframework/dev/gg-use-one-environment-variable-for-memory-pool
Use one environment variable to select memory pool usage
2 parents 427add3 + b561143 commit 036953c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Diff for: arcane/src/arcane/accelerator/cuda/CudaAccelerator.cc

+18-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ using namespace Arccore;
3737
/*---------------------------------------------------------------------------*/
3838
/*---------------------------------------------------------------------------*/
3939

40+
//! Liste des flags pour le pool mémoire à activer
41+
enum class MemoryPoolFlags
42+
{
43+
UVM = 1,
44+
Device = 2,
45+
HostPinned = 4
46+
};
47+
48+
/*---------------------------------------------------------------------------*/
49+
/*---------------------------------------------------------------------------*/
50+
4051
void arcaneCheckCudaErrors(const TraceInfo& ti, cudaError_t e)
4152
{
4253
if (e != cudaSuccess)
@@ -203,7 +214,7 @@ class CudaMemoryAllocatorBase
203214
, m_sub_allocator(&m_direct_sub_allocator)
204215
, m_allocator_name(allocator_name)
205216
{
206-
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_CUDA_MALLOC_PRINT_LEVEL", true))
217+
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ACCELERATOR_MEMORY_PRINT_LEVEL", true))
207218
m_print_level = v.value();
208219
}
209220

@@ -349,8 +360,8 @@ class UnifiedMemoryCudaMemoryAllocator
349360
m_block_wrapper.initialize(page_size, do_page_allocate);
350361

351362
bool use_memory_pool = false;
352-
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_CUDA_MALLOCMANAGED_POOL", true))
353-
use_memory_pool = (v.value() != 0);
363+
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ACCELERATOR_MEMORY_POOL", true))
364+
use_memory_pool = (v.value() & static_cast<int>(MemoryPoolFlags::UVM)) != 0;
354365
_setUseMemoryPool(use_memory_pool);
355366
}
356367

@@ -446,8 +457,8 @@ class HostPinnedCudaMemoryAllocator
446457
void initialize()
447458
{
448459
bool use_memory_pool = false;
449-
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_CUDA_HOSTPINNED_POOL", true))
450-
use_memory_pool = (v.value() != 0);
460+
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ACCELERATOR_MEMORY_POOL", true))
461+
use_memory_pool = (v.value() & static_cast<int>(MemoryPoolFlags::HostPinned)) != 0;
451462
_setUseMemoryPool(use_memory_pool);
452463
m_block_wrapper.initialize(128, use_memory_pool);
453464
}
@@ -484,8 +495,8 @@ class DeviceCudaMemoryAllocator
484495
void initialize()
485496
{
486497
bool use_memory_pool = false;
487-
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_CUDA_DEVICE_POOL", true))
488-
use_memory_pool = (v.value() != 0);
498+
if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ACCELERATOR_MEMORY_POOL", true))
499+
use_memory_pool = (v.value() & static_cast<int>(MemoryPoolFlags::Device)) != 0;
489500
_setUseMemoryPool(use_memory_pool);
490501
m_block_wrapper.initialize(128, use_memory_pool);
491502
}

0 commit comments

Comments
 (0)