Skip to content

Commit ccf0bc4

Browse files
committed
ocl: more accurate profiling events
- Always perform ACC_OPENCL_MEM_EVTRELEASE code-path. - Removed ACC_OPENCL_MEM_EVTRELEASE definition.
1 parent 95ee950 commit ccf0bc4

1 file changed

Lines changed: 12 additions & 23 deletions

File tree

src/acc/opencl/acc_opencl_mem.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
# include <unistd.h>
2020
# endif
2121

22-
# if !defined(ACC_OPENCL_MEM_EVTRELEASE) && 1
23-
# define ACC_OPENCL_MEM_EVTRELEASE
24-
# endif
2522
# if !defined(ACC_OPENCL_MEM_ALIGNSCALE)
2623
# define ACC_OPENCL_MEM_ALIGNSCALE 8
2724
# endif
@@ -282,12 +279,10 @@ int c_dbcsr_acc_host_mem_deallocate(void* host_mem, void* stream) {
282279
}
283280
}
284281
# endif
285-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
286282
if (NULL != event) {
287283
result2 = clReleaseEvent(event);
288284
if (EXIT_SUCCESS == result) result = result2;
289285
}
290-
# endif
291286
}
292287
result2 = clReleaseMemObject(info.memory);
293288
if (EXIT_SUCCESS == result) result = result2;
@@ -336,9 +331,7 @@ void CL_CALLBACK c_dbcsr_acc_memcpy_notify(cl_event event, cl_int event_status,
336331
} break;
337332
}
338333
}
339-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
340334
if (NULL != event) ACC_OPENCL_EXPECT(EXIT_SUCCESS == clReleaseEvent(event));
341-
# endif
342335
}
343336

344337

@@ -602,12 +595,10 @@ int c_dbcsr_acc_memcpy_h2d(const void* host_mem, void* dev_mem, size_t nbytes, v
602595
result = clSetEventCallback(event, CL_COMPLETE, c_dbcsr_acc_memcpy_notify, dev_mem);
603596
if (EXIT_SUCCESS == result) event = NULL; /* prevent releasing the event */
604597
}
605-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
606598
if (NULL != event) {
607599
const int result_release = clReleaseEvent(event);
608600
if (EXIT_SUCCESS == result) result = result_release;
609601
}
610-
# endif
611602
}
612603
}
613604
}
@@ -658,16 +649,14 @@ int c_dbcsr_acc_memcpy_d2h(const void* dev_mem, void* host_mem, size_t nbytes, v
658649
ACC_OPENCL_RELEASE(c_dbcsr_acc_opencl_config.lock_memory);
659650
if (NULL != event) {
660651
if (EXIT_SUCCESS == result) {
661-
assert(NULL != c_dbcsr_acc_opencl_config.hist_d2h);
652+
assert(NULL != c_dbcsr_acc_opencl_config.hist_d2h /*&& NULL == devinfo->clEnqueueMemcpyINTEL*/);
662653
result = clSetEventCallback(event, CL_COMPLETE, c_dbcsr_acc_memcpy_notify, nconst.ptr);
663654
if (EXIT_SUCCESS == result) event = NULL; /* prevent releasing the event */
664655
}
665-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
666656
if (NULL != event) {
667657
const int result_release = clReleaseEvent(event);
668658
if (EXIT_SUCCESS == result) result = result_release;
669659
}
670-
# endif
671660
}
672661
}
673662
# if defined(ACC_OPENCL_PROFILE_DBCSR)
@@ -720,18 +709,21 @@ int c_dbcsr_acc_memcpy_d2d(const void* devmem_src, void* devmem_dst, size_t nbyt
720709
}
721710
if (NULL != event) {
722711
if (EXIT_SUCCESS == result) {
723-
if (NULL == stream) result = clWaitForEvents(1, &event);
724-
if (EXIT_SUCCESS == result && NULL != c_dbcsr_acc_opencl_config.hist_d2d) {
712+
if (NULL != c_dbcsr_acc_opencl_config.hist_d2d) {
713+
assert(NULL == c_dbcsr_acc_opencl_config.device.clEnqueueMemcpyINTEL);
725714
result = clSetEventCallback(event, CL_COMPLETE, c_dbcsr_acc_memcpy_notify, nconst.ptr);
726-
if (EXIT_SUCCESS == result) event = NULL; /* prevent releasing the event */
715+
if (EXIT_SUCCESS == result) {
716+
const cl_event wait = event;
717+
event = NULL; /* prevent releasing the event */
718+
if (NULL == stream) result = clWaitForEvents(1, &wait);
719+
}
727720
}
721+
else if (NULL == stream) result = clWaitForEvents(1, &event);
728722
}
729-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
730723
if (NULL != event) {
731724
const int result_release = clReleaseEvent(event);
732725
if (EXIT_SUCCESS == result) result = result_release;
733726
}
734-
# endif
735727
}
736728
}
737729
# if defined(ACC_OPENCL_PROFILE_DBCSR)
@@ -778,15 +770,12 @@ int c_dbcsr_acc_opencl_memset(void* dev_mem, int value, size_t offset, size_t nb
778770
ACC_OPENCL_RELEASE(c_dbcsr_acc_opencl_config.lock_memory);
779771
}
780772
if (NULL != event) {
773+
int result_release;
781774
if (NULL == stream && EXIT_SUCCESS == result) {
782775
result = clWaitForEvents(1, &event);
783776
}
784-
# if defined(ACC_OPENCL_MEM_EVTRELEASE)
785-
{
786-
const int result_release = clReleaseEvent(event);
787-
if (EXIT_SUCCESS == result) result = result_release;
788-
}
789-
# endif
777+
result_release = clReleaseEvent(event);
778+
if (EXIT_SUCCESS == result) result = result_release;
790779
}
791780
}
792781
# if defined(ACC_OPENCL_PROFILE_DBCSR)

0 commit comments

Comments
 (0)