15 static void queue_error_cb(
const char *message,
void *user_ptr)
18 *
reinterpret_cast<std::string *
>(user_ptr) = message;
22 OneapiDevice::OneapiDevice(
const DeviceInfo &info,
23 OneAPIDLLInterface &oneapi_dll_object,
26 :
Device(info, stats, profiler),
27 device_queue_(nullptr),
28 texture_info_(this,
"texture_info",
MEM_GLOBAL),
30 kg_memory_device_(nullptr),
32 oneapi_dll_(oneapi_dll_object)
34 need_texture_info_ =
false;
36 oneapi_dll_.oneapi_set_error_cb(queue_error_cb, &oneapi_error_string_);
39 assert(oneapi_dll_.oneapi_create_queue !=
nullptr);
41 bool is_finished_ok = oneapi_dll_.oneapi_create_queue(device_queue_, info.
num);
42 if (is_finished_ok ==
false) {
43 set_error(
"oneAPI queue initialization error: got runtime exception \"" +
44 oneapi_error_string_ +
"\"");
47 VLOG_DEBUG <<
"oneAPI queue has been successfully created for the device \""
49 assert(device_queue_);
52 size_t globals_segment_size;
53 is_finished_ok = oneapi_dll_.oneapi_kernel_globals_size(device_queue_, globals_segment_size);
54 if (is_finished_ok ==
false) {
55 set_error(
"oneAPI constant memory initialization got runtime exception \"" +
56 oneapi_error_string_ +
"\"");
59 VLOG_DEBUG <<
"Successfully created global/constant memory segment (kernel globals object)";
62 kg_memory_ = oneapi_dll_.oneapi_usm_aligned_alloc_host(device_queue_, globals_segment_size, 16);
63 oneapi_dll_.oneapi_usm_memset(device_queue_, kg_memory_, 0, globals_segment_size);
65 kg_memory_device_ = oneapi_dll_.oneapi_usm_alloc_device(device_queue_, globals_segment_size);
67 kg_memory_size_ = globals_segment_size;
69 max_memory_on_device_ = oneapi_dll_.oneapi_get_memcapacity(device_queue_);
72 OneapiDevice::~OneapiDevice()
75 oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_);
76 oneapi_dll_.oneapi_usm_free(device_queue_, kg_memory_device_);
78 for (ConstMemMap::iterator mt = const_mem_map_.begin(); mt != const_mem_map_.end(); mt++)
82 oneapi_dll_.oneapi_free_queue(device_queue_);
85 bool OneapiDevice::check_peer_access(
Device * )
95 bool OneapiDevice::load_kernels(
const uint requested_features)
97 assert(device_queue_);
100 (
void)requested_features;
102 bool is_finished_ok = oneapi_dll_.oneapi_run_test_kernel(device_queue_);
103 if (is_finished_ok ==
false) {
104 set_error(
"oneAPI kernel load: got runtime exception \"" + oneapi_error_string_ +
"\"");
108 assert(device_queue_);
110 return is_finished_ok;
113 void OneapiDevice::load_texture_info()
115 if (need_texture_info_) {
116 need_texture_info_ =
false;
117 texture_info_.copy_to_device();
130 assert(device_queue_);
139 void *device_pointer =
nullptr;
141 device_pointer = oneapi_dll_.oneapi_usm_alloc_device(device_queue_, memory_size);
142 if (device_pointer ==
nullptr) {
143 set_error(
"oneAPI kernel - device memory allocation error for " +
145 ", possibly caused by lack of available memory space on the device: " +
165 assert(device_queue_);
166 oneapi_dll_.oneapi_usm_memcpy(
171 SyclQueue *OneapiDevice::sycl_queue()
173 return device_queue_;
176 string OneapiDevice::oneapi_error_message()
178 return string(oneapi_error_string_);
181 OneAPIDLLInterface OneapiDevice::oneapi_dll_object()
186 void *OneapiDevice::kernel_globals_device_pointer()
188 return kg_memory_device_;
200 assert(device_queue_);
201 oneapi_dll_.oneapi_usm_free(device_queue_, (
void *)mem.
device_pointer);
208 assert(!
"mem_alloc not supported for textures.");
211 assert(!
"mem_alloc not supported for global memory.");
226 VLOG_DEBUG <<
"OneapiDevice::mem_copy_to: \"" << mem.
name <<
"\", "
243 generic_copy_to(mem);
247 void OneapiDevice::mem_copy_from(
device_memory &mem,
size_t y,
size_t w,
size_t h,
size_t elem)
250 assert(!
"mem_copy_from not supported for textures.");
253 const size_t size = (
w > 0 || h > 0 || elem > 0) ? (elem *
w * h) : mem.
memory_size();
257 VLOG_DEBUG <<
"OneapiDevice::mem_copy_from: \"" << mem.
name <<
"\" object of "
260 <<
" data " <<
size <<
" bytes";
263 assert(device_queue_);
269 bool is_finished_ok = oneapi_dll_.oneapi_usm_memcpy(
270 device_queue_, shifted_host, shifted_device,
size);
271 if (is_finished_ok ==
false) {
272 set_error(
"oneAPI memory operation error: got runtime exception \"" +
273 oneapi_error_string_ +
"\"");
294 assert(device_queue_);
295 bool is_finished_ok = oneapi_dll_.oneapi_usm_memset(
297 if (is_finished_ok ==
false) {
298 set_error(
"oneAPI memory operation error: got runtime exception \"" + oneapi_error_string_ +
328 void OneapiDevice::const_copy_to(
const char *name,
void *host,
size_t size)
332 VLOG_DEBUG <<
"OneapiDevice::const_copy_to \"" << name <<
"\" object "
336 ConstMemMap::iterator i = const_mem_map_.find(name);
339 if (i == const_mem_map_.end()) {
342 const_mem_map_.insert(ConstMemMap::value_type(name,
data));
348 assert(
data->memory_size() <=
size);
350 data->copy_to_device();
352 oneapi_dll_.oneapi_set_global_memory(
353 device_queue_, kg_memory_, name, (
void *)
data->device_pointer);
355 oneapi_dll_.oneapi_usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
363 VLOG_DEBUG <<
"OneapiDevice::global_alloc \"" << mem.
name <<
"\" object "
368 generic_copy_to(mem);
370 oneapi_dll_.oneapi_set_global_memory(
373 oneapi_dll_.oneapi_usm_memcpy(device_queue_, kg_memory_device_, kg_memory_, kg_memory_size_);
386 generic_copy_to(mem);
390 if (slot >= texture_info_.size()) {
391 texture_info_.resize(slot + 128);
394 texture_info_[slot] = mem.
info;
395 need_texture_info_ =
true;
408 unique_ptr<DeviceQueue> OneapiDevice::gpu_queue_create()
410 return make_unique<OneapiDeviceQueue>(
this);
413 int OneapiDevice::get_num_multiprocessors()
415 assert(device_queue_);
416 return oneapi_dll_.oneapi_get_num_multiprocessors(device_queue_);
419 int OneapiDevice::get_max_num_threads_per_multiprocessor()
421 assert(device_queue_);
422 return oneapi_dll_.oneapi_get_max_num_threads_per_multiprocessor(device_queue_);
425 bool OneapiDevice::should_use_graphics_interop()
432 void *OneapiDevice::usm_aligned_alloc_host(
size_t memory_size,
size_t alignment)
434 assert(device_queue_);
435 return oneapi_dll_.oneapi_usm_aligned_alloc_host(device_queue_, memory_size, alignment);
438 void OneapiDevice::usm_free(
void *usm_ptr)
440 assert(device_queue_);
441 return oneapi_dll_.oneapi_usm_free(device_queue_, usm_ptr);
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void mem_free(size_t size)
void mem_alloc(size_t size)
size_t memory_elements_size(int elements)
device_ptr device_pointer
#define CCL_NAMESPACE_END
SyclQueue void void size_t num_bytes void
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
unsigned __int64 uint64_t
string string_human_readable_size(size_t size)
string string_human_readable_number(size_t num)