| 235 | } |
| 236 | |
| 237 | address KernelParameters::capture(device::VirtualDevice& vDev, uint64_t lclMemSize, |
| 238 | int32_t* error) { |
| 239 | const Device& device = vDev.device(); |
| 240 | *error = CL_SUCCESS; |
| 241 | |
| 242 | //! Information about which arguments are SVM pointers is stored after |
| 243 | // the actual parameters, but only if the device has any SVM capability |
| 244 | const size_t execInfoSize = getNumberOfSvmPtr() * sizeof(void*); |
| 245 | |
| 246 | address mem = vDev.allocKernelArguments(totalSize_ + execInfoSize, 128); |
| 247 | if (mem == nullptr) { |
| 248 | mem = reinterpret_cast<address>( |
| 249 | AlignedMemory::allocate(totalSize_ + execInfoSize, PARAMETERS_MIN_ALIGNMENT)); |
| 250 | } else { |
| 251 | deviceKernelArgs_ = true; |
| 252 | } |
| 253 | |
| 254 | if (mem != nullptr) { |
| 255 | ::memcpy(mem, values_, totalSize_); |
| 256 | |
| 257 | for (size_t i = 0; i < signature_.numParameters(); ++i) { |
| 258 | const KernelParameterDescriptor& desc = signature_.at(i); |
| 259 | if (desc.type_ == T_POINTER && (desc.addressQualifier_ != CL_KERNEL_ARG_ADDRESS_LOCAL)) { |
| 260 | Memory* memArg = memoryObjects_[desc.info_.arrayIndex_]; |
| 261 | if (memArg != nullptr) { |
| 262 | if (!(amd::IS_HIP && AMD_DIRECT_DISPATCH)) { |
| 263 | memArg->retain(); |
| 264 | } |
| 265 | device::Memory* devMem = memArg->getDeviceMemory(device); |
| 266 | if (nullptr == devMem) { |
| 267 | LogPrintfError("Can't allocate memory size - 0x%08X bytes!", memArg->getSize()); |
| 268 | *error = CL_MEM_OBJECT_ALLOCATION_FAILURE; |
| 269 | break; |
| 270 | } |
| 271 | // Write GPU VA addreess to the arguments |
| 272 | if (!desc.info_.rawPointer_) { |
| 273 | *reinterpret_cast<uintptr_t*>(mem + desc.offset_) = |
| 274 | static_cast<uintptr_t>(devMem->virtualAddress()); |
| 275 | } |
| 276 | } else if (desc.info_.rawPointer_) { |
| 277 | if (!device.isFineGrainedSystem(true)) { |
| 278 | } |
| 279 | } |
| 280 | } else if (desc.type_ == T_SAMPLER) { |
| 281 | Sampler* samplerArg = samplerObjects_[desc.info_.arrayIndex_]; |
| 282 | if (samplerArg != nullptr) { |
| 283 | device::Sampler* deviceSampler = samplerArg->getDeviceSampler(device); |
| 284 | if (!deviceSampler) { |
| 285 | *error = CL_INVALID_CONTEXT; |
| 286 | break; |
| 287 | } |
| 288 | samplerArg->retain(); |
| 289 | // todo: It's uint64_t type |
| 290 | *reinterpret_cast<uintptr_t*>(mem + desc.offset_) = |
| 291 | static_cast<uintptr_t>(samplerArg->getDeviceSampler(device)->hwSrd()); |
| 292 | } |
| 293 | } else if (desc.type_ == T_QUEUE) { |
| 294 | DeviceQueue* queue = queueObjects_[desc.info_.arrayIndex_]; |
no test coverage detected