38
38
ACL_EXPORT
39
39
CL_API_ENTRY cl_int CL_API_CALL
40
40
clEnqueueBarrierIntelFPGA (cl_command_queue command_queue) {
41
- acl_lock () ;
41
+ std::scoped_lock lock{acl_mutex_wrapper} ;
42
42
43
43
if (!acl_command_queue_is_valid (command_queue)) {
44
- UNLOCK_RETURN ( CL_INVALID_COMMAND_QUEUE) ;
44
+ return CL_INVALID_COMMAND_QUEUE;
45
45
}
46
46
47
47
// For in order queue, since every event is executed in sequence,
48
48
// there is an implicit barrier after each event.
49
49
// enqueue barrier does not need to do anything
50
50
if (!(command_queue->properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)) {
51
- UNLOCK_RETURN ( CL_SUCCESS) ;
51
+ return CL_SUCCESS;
52
52
}
53
53
// OpenCL 1.2 spec: If event_wait_list is NULL, then this particular command
54
54
// waits until all previous enqueued commands to command_queue have completed.
55
55
cl_int status = clEnqueueBarrierWithWaitList (command_queue, 0 , 0 , NULL );
56
- UNLOCK_RETURN ( status) ;
56
+ return status;
57
57
}
58
58
59
59
ACL_EXPORT
@@ -66,18 +66,18 @@ ACL_EXPORT
66
66
CL_API_ENTRY cl_int CL_API_CALL
67
67
clEnqueueMarkerIntelFPGA (cl_command_queue command_queue, cl_event *event) {
68
68
cl_int result;
69
- acl_lock () ;
69
+ std::scoped_lock lock{acl_mutex_wrapper} ;
70
70
71
71
if (!acl_command_queue_is_valid (command_queue)) {
72
- UNLOCK_RETURN ( CL_INVALID_COMMAND_QUEUE) ;
72
+ return CL_INVALID_COMMAND_QUEUE;
73
73
}
74
74
75
75
if (!event)
76
- UNLOCK_RETURN ( CL_INVALID_VALUE) ;
76
+ return CL_INVALID_VALUE;
77
77
78
78
result = acl_create_event (command_queue, 0 , 0 , CL_COMMAND_MARKER, event);
79
79
80
- UNLOCK_RETURN ( result) ;
80
+ return result;
81
81
}
82
82
83
83
ACL_EXPORT
@@ -91,13 +91,13 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueWaitForEventsIntelFPGA(
91
91
cl_command_queue command_queue, cl_uint num_event, const cl_event *events) {
92
92
cl_int result;
93
93
94
- acl_lock () ;
94
+ std::scoped_lock lock{acl_mutex_wrapper} ;
95
95
96
96
if (!acl_command_queue_is_valid (command_queue)) {
97
- UNLOCK_RETURN ( CL_INVALID_COMMAND_QUEUE) ;
97
+ return CL_INVALID_COMMAND_QUEUE;
98
98
}
99
99
if (num_event == 0 || events == 0 ) {
100
- UNLOCK_RETURN ( CL_INVALID_VALUE) ;
100
+ return CL_INVALID_VALUE;
101
101
}
102
102
cl_event event = NULL ;
103
103
result = acl_create_event (command_queue, num_event, events,
@@ -110,7 +110,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueWaitForEventsIntelFPGA(
110
110
result = CL_INVALID_EVENT;
111
111
}
112
112
113
- UNLOCK_RETURN ( result) ;
113
+ return result;
114
114
}
115
115
116
116
ACL_EXPORT
@@ -129,16 +129,16 @@ clWaitForEventsIntelFPGA(cl_uint num_events, const cl_event *event_list) {
129
129
cl_context context;
130
130
bool first_yield_to_hal = true ;
131
131
132
- acl_lock () ;
132
+ std::scoped_lock lock{acl_mutex_wrapper} ;
133
133
134
134
if (num_events == 0 || event_list == 0 ) {
135
- UNLOCK_RETURN ( CL_INVALID_VALUE) ;
135
+ return CL_INVALID_VALUE;
136
136
}
137
137
138
138
#ifndef REMOVE_VALID_CHECKS
139
139
result = acl_check_events (num_events, event_list);
140
140
if (result != CL_SUCCESS) {
141
- UNLOCK_RETURN ( CL_INVALID_EVENT) ;
141
+ return CL_INVALID_EVENT;
142
142
}
143
143
#endif
144
144
@@ -193,12 +193,12 @@ clWaitForEventsIntelFPGA(cl_uint num_events, const cl_event *event_list) {
193
193
cl_uint i = 0 ;
194
194
for (i = 0 ; i < num_events; ++i) {
195
195
if (event_list[i]->execution_status < 0 )
196
- UNLOCK_RETURN ( CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST) ;
196
+ return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
197
197
}
198
198
}
199
199
#endif
200
200
201
- UNLOCK_RETURN ( result) ;
201
+ return result;
202
202
}
203
203
204
204
ACL_EXPORT
@@ -214,10 +214,10 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueMarkerWithWaitListIntelFPGA(
214
214
cl_int result;
215
215
cl_event ret_event = NULL ;
216
216
217
- acl_lock () ;
217
+ std::scoped_lock lock{acl_mutex_wrapper} ;
218
218
219
219
if (!acl_command_queue_is_valid (command_queue)) {
220
- UNLOCK_RETURN ( CL_INVALID_COMMAND_QUEUE) ;
220
+ return CL_INVALID_COMMAND_QUEUE;
221
221
}
222
222
223
223
// Spec says:
@@ -248,7 +248,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueMarkerWithWaitListIntelFPGA(
248
248
if (ret_event)
249
249
clReleaseEvent (ret_event); // free the ret event if the caller doesn't want
250
250
// to return it
251
- UNLOCK_RETURN ( result) ;
251
+ return result;
252
252
}
253
253
254
254
ACL_EXPORT
@@ -265,12 +265,12 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueBarrierWithWaitListIntelFPGA(
265
265
const cl_event *event_wait_list, cl_event *event) {
266
266
cl_int result;
267
267
cl_event local_event;
268
- acl_lock () ;
268
+ std::scoped_lock lock{acl_mutex_wrapper} ;
269
269
270
270
result = clEnqueueMarkerWithWaitList (command_queue, num_events_in_wait_list,
271
271
event_wait_list, &local_event);
272
272
if (result != CL_SUCCESS) {
273
- UNLOCK_RETURN ( result) ;
273
+ return result;
274
274
}
275
275
276
276
if (command_queue->properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) {
@@ -282,7 +282,7 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueBarrierWithWaitListIntelFPGA(
282
282
} else {
283
283
clReleaseEvent (local_event);
284
284
}
285
- UNLOCK_RETURN ( result) ;
285
+ return result;
286
286
}
287
287
288
288
ACL_EXPORT
0 commit comments