Skip to content

Commit cef934d

Browse files
authored
ocl: speedup host-memory allocation on GH200 (#846)
1 parent 43f8eef commit cef934d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/acc/opencl/acc_opencl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ int c_dbcsr_acc_init(void) {
274274
: c_dbcsr_acc_opencl_config.lock_main);
275275
c_dbcsr_acc_opencl_config.verbosity = (NULL == env_verbose ? 0 : atoi(env_verbose));
276276
c_dbcsr_acc_opencl_config.priority = (NULL == env_priority ? /*default*/ 3 : atoi(env_priority));
277-
c_dbcsr_acc_opencl_config.xhints = (NULL == env_xhints ? (1 + 2) : atoi(env_xhints));
277+
c_dbcsr_acc_opencl_config.xhints = (NULL == env_xhints ? (1 + 2 + 4) : atoi(env_xhints));
278278
c_dbcsr_acc_opencl_config.async = (NULL == env_async ? async_default : atoi(env_async));
279279
c_dbcsr_acc_opencl_config.dump = (NULL == env_dump ? /*default*/ 0 : atoi(env_dump));
280280
c_dbcsr_acc_opencl_config.debug = (NULL == env_debug ? c_dbcsr_acc_opencl_config.dump : atoi(env_debug));

src/acc/opencl/acc_opencl_mem.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ int c_dbcsr_acc_host_mem_allocate(void** host_mem, size_t nbytes, void* stream)
190190
if (EXIT_SUCCESS == result) {
191191
const c_dbcsr_acc_opencl_stream_t* const str = (NULL != stream ? ACC_OPENCL_STREAM(stream)
192192
: c_dbcsr_acc_opencl_stream_default());
193-
void* const mapped = clEnqueueMapBuffer(
194-
str->queue, memory, CL_TRUE /*always block*/, CL_MAP_READ | CL_MAP_WRITE, 0 /*offset*/, nbytes, 0, NULL, NULL, &result);
193+
void* const mapped = clEnqueueMapBuffer(str->queue, memory, CL_TRUE /*always block*/,
194+
# if defined(CL_VERSION_1_2) || defined(CL_MAP_WRITE_INVALIDATE_REGION)
195+
(4 & c_dbcsr_acc_opencl_config.xhints) ? CL_MAP_WRITE_INVALIDATE_REGION :
196+
# endif
197+
(CL_MAP_READ | CL_MAP_WRITE),
198+
0 /*offset*/, nbytes, 0, NULL, NULL, &result);
195199
assert(EXIT_SUCCESS == result || NULL == mapped);
196200
if (EXIT_SUCCESS == result) {
197201
const uintptr_t address = (uintptr_t)mapped;

0 commit comments

Comments
 (0)