| 72 | ispc::Data1D Data::emptyData1D; |
| 73 | |
| 74 | void Data::init() |
| 75 | { |
| 76 | managedObjectType = OSP_DATA; |
| 77 | if (reduce_min(numItems) == 0) |
| 78 | throw std::out_of_range("OSPData: all numItems must be positive"); |
| 79 | dimensions = |
| 80 | std::max(1, (numItems.x > 1) + (numItems.y > 1) + (numItems.z > 1)); |
| 81 | // compute strides if requested |
| 82 | if (byteStride.x == 0) |
| 83 | byteStride.x = sizeOf(type); |
| 84 | if (byteStride.y == 0) |
| 85 | byteStride.y = numItems.x * byteStride.x; |
| 86 | if (byteStride.z == 0) |
| 87 | byteStride.z = numItems.y * byteStride.y; |
| 88 | |
| 89 | #ifdef OSPRAY_TARGET_SYCL |
| 90 | // Check if the shared data the app gave is actually in USM, if not we still |
| 91 | // need to make a copy of it internally so it's accessible on the GPU |
| 92 | if (shared) { |
| 93 | devicert::Device &device = getISPCDevice().getDRTDevice(); |
| 94 | const size_t sizeBytes = byteStride.z * numItems.z; |
| 95 | auto memType = device.getPointerType(addr); |
| 96 | switch (memType) { |
| 97 | case devicert::Alloc::Host: |
| 98 | default: |
| 99 | // std::cerr << "HOST..COPYING" << std::endl; |
| 100 | shared = false; |
| 101 | view = devicert::make_buffer_shared_unique<char>(device, sizeBytes); |
| 102 | addr = view->data(); |
| 103 | std::memcpy(addr, appSharedPtr, sizeBytes); |
| 104 | break; |
| 105 | case devicert::Alloc::Shared: |
| 106 | // std::cerr << "SHARED..USE IN PLACE" << std::endl; |
| 107 | break; |
| 108 | case devicert::Alloc::Device: |
| 109 | static bool useDeviceMemory = |
| 110 | (rkcommon::utility::getEnvVar<int>("OSPRAY_ALLOW_DEVICE_MEMORY") |
| 111 | .value_or(0) |
| 112 | != 0); |
| 113 | if (useDeviceMemory) { |
| 114 | // std::cerr << "DEVICE..USE IN PLACE" << std::endl; |
| 115 | addr = appSharedPtr; |
| 116 | } else { |
| 117 | // std::cerr << "DEVICE..COPYING" << std::endl; |
| 118 | shared = false; |
| 119 | |
| 120 | // make ospray's shared buffer |
| 121 | view = devicert::make_buffer_shared_unique<char>(device, sizeBytes); |
| 122 | |
| 123 | // copy to it |
| 124 | device.memcpy(view->sharedPtr(), appSharedPtr, sizeBytes); |
| 125 | addr = view->data(); |
| 126 | } |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | #endif |
| 131 |
nothing calls this directly
no test coverage detected