17
17
#include < oneapi/dnnl/dnnl_ocl.hpp>
18
18
#endif
19
19
20
- #define BOUNDARIES_CHECK (copy_type, src_size, src_offset, dst_size, dst_offset, copy_size ) \
21
- OPENVINO_ASSERT (src_offset + copy_size <= src_size && dst_offset + copy_size <= dst_size, \
22
- " [GPU] Incorrect buffer sizes for " , \
23
- copy_type, \
24
- " call. Parameters provided are" \
25
- " : src_size=" , \
26
- src_size, \
27
- " , src_offset=" , \
28
- src_offset, \
29
- " , dst_size=" , \
30
- dst_size, \
31
- " , dst_offset=" , \
32
- dst_offset, \
33
- " , copy_size=" , \
34
- copy_size, \
35
- " ." );
36
-
37
20
#define TRY_CATCH_CL_ERROR (...) \
38
21
try { \
39
22
__VA_ARGS__; \
44
27
namespace cldnn {
45
28
namespace ocl {
46
29
30
+ static inline void check_boundaries (const std::string& func_str,
31
+ size_t src_size,
32
+ size_t src_offset,
33
+ size_t dst_size,
34
+ size_t dst_offset,
35
+ size_t copy_size) {
36
+ OPENVINO_ASSERT (src_offset + copy_size <= src_size && dst_offset + copy_size <= dst_size,
37
+ " [GPU] Incorrect buffer sizes for " ,
38
+ func_str,
39
+ " call. " ,
40
+ " Parameters provided are" ,
41
+ " : src_size=" ,
42
+ src_size,
43
+ " , src_offset=" ,
44
+ src_offset,
45
+ " , dst_size=" ,
46
+ dst_size,
47
+ " , dst_offset=" ,
48
+ dst_offset,
49
+ " , copy_size=" ,
50
+ copy_size,
51
+ " ." );
52
+ }
53
+
47
54
static inline cldnn::event::ptr create_event (stream& stream, size_t bytes_count, bool need_user_event) {
48
55
if (bytes_count == 0 ) {
49
56
GPU_DEBUG_TRACE_DETAIL << " Skip memory operation for 0 size tensor" << std::endl;
@@ -149,7 +156,7 @@ event::ptr gpu_buffer::copy_from(stream& stream, const void* data_ptr, size_t sr
149
156
if (size == 0 )
150
157
return result_event;
151
158
152
- BOUNDARIES_CHECK (" gpu_buffer::copy_from(void*)" , SIZE_MAX, src_offset, _bytes_count, dst_offset, size);
159
+ check_boundaries (" gpu_buffer::copy_from(void*)" , SIZE_MAX, src_offset, _bytes_count, dst_offset, size);
153
160
154
161
auto cl_stream = downcast<ocl_stream>(&stream);
155
162
auto cl_event = blocking ? nullptr : &downcast<ocl_event>(result_event.get ())->get ();
@@ -165,7 +172,7 @@ event::ptr gpu_buffer::copy_from(stream& stream, const memory& src_mem, size_t s
165
172
if (size == 0 )
166
173
return result_event;
167
174
168
- BOUNDARIES_CHECK (" gpu_buffer::copy_from(memory&)" , src_mem.size (), src_offset, _bytes_count, dst_offset, size);
175
+ check_boundaries (" gpu_buffer::copy_from(memory&)" , src_mem.size (), src_offset, _bytes_count, dst_offset, size);
169
176
170
177
switch (src_mem.get_allocation_type ()) {
171
178
case allocation_type::usm_host:
@@ -201,7 +208,7 @@ event::ptr gpu_buffer::copy_to(stream& stream, void* data_ptr, size_t src_offset
201
208
if (size == 0 )
202
209
return result_event;
203
210
204
- BOUNDARIES_CHECK (" gpu_buffer::copy_to(void*)" , _bytes_count, src_offset, SIZE_MAX, dst_offset, size);
211
+ check_boundaries (" gpu_buffer::copy_to(void*)" , _bytes_count, src_offset, SIZE_MAX, dst_offset, size);
205
212
206
213
auto cl_stream = downcast<ocl_stream>(&stream);
207
214
auto cl_event = blocking ? nullptr : &downcast<ocl_event>(result_event.get ())->get ();
@@ -563,7 +570,7 @@ event::ptr gpu_usm::copy_from(stream& stream, const void* data_ptr, size_t src_o
563
570
if (size == 0 )
564
571
return result_event;
565
572
566
- BOUNDARIES_CHECK (" gpu_usm::copy_from(void*)" , SIZE_MAX, src_offset, _bytes_count, dst_offset, size);
573
+ check_boundaries (" gpu_usm::copy_from(void*)" , SIZE_MAX, src_offset, _bytes_count, dst_offset, size);
567
574
568
575
auto cl_stream = downcast<ocl_stream>(&stream);
569
576
auto cl_event = blocking ? nullptr : &downcast<ocl_event>(result_event.get ())->get ();
@@ -580,7 +587,7 @@ event::ptr gpu_usm::copy_from(stream& stream, const memory& src_mem, size_t src_
580
587
if (size == 0 )
581
588
return result_event;
582
589
583
- BOUNDARIES_CHECK (" gpu_usm::copy_from(memory&)" , src_mem.size (), src_offset, _bytes_count, dst_offset, size);
590
+ check_boundaries (" gpu_usm::copy_from(memory&)" , src_mem.size (), src_offset, _bytes_count, dst_offset, size);
584
591
585
592
auto cl_stream = downcast<ocl_stream>(&stream);
586
593
auto cl_event = blocking ? nullptr : &downcast<ocl_event>(result_event.get ())->get ();
@@ -613,7 +620,7 @@ event::ptr gpu_usm::copy_to(stream& stream, void* data_ptr, size_t src_offset, s
613
620
if (size == 0 )
614
621
return result_event;
615
622
616
- BOUNDARIES_CHECK (" gpu_usm::copy_to(void*)" , _bytes_count, src_offset, SIZE_MAX, dst_offset, size);
623
+ check_boundaries (" gpu_usm::copy_to(void*)" , _bytes_count, src_offset, SIZE_MAX, dst_offset, size);
617
624
618
625
auto cl_stream = downcast<ocl_stream>(&stream);
619
626
auto cl_event = blocking ? nullptr : &downcast<ocl_event>(result_event.get ())->get ();
@@ -701,5 +708,3 @@ ocl_surfaces_lock::ocl_surfaces_lock(std::vector<memory::ptr> mem, const stream&
701
708
702
709
} // namespace ocl
703
710
} // namespace cldnn
704
-
705
- #undef BOUNDARIES_CHECK
0 commit comments