| 350 | } |
| 351 | |
| 352 | hipError_t ihipLaunchKernelCommand(amd::Command*& command, hipFunction_t f, |
| 353 | amd::LaunchParams& launch_params, hip::Stream* stream, |
| 354 | void** kernelParams, void** extra, |
| 355 | hipEvent_t startEvent = nullptr, hipEvent_t stopEvent = nullptr, |
| 356 | uint32_t flags = 0, uint32_t params = 0, uint32_t gridId = 0, |
| 357 | uint32_t numGrids = 0, uint64_t prevGridSum = 0, |
| 358 | uint64_t allGridSum = 0, uint32_t firstDevice = 0) { |
| 359 | hip::DeviceFunc* function = hip::DeviceFunc::asFunction(f); |
| 360 | amd::Kernel* kernel = function->kernel(); |
| 361 | |
| 362 | size_t globalWorkOffset[3] = {0}; |
| 363 | amd::NDRangeContainer ndrange(3, globalWorkOffset, launch_params.global_.Data(), |
| 364 | launch_params.local_.Data()); |
| 365 | amd::Command::EventWaitList waitList; |
| 366 | |
| 367 | bool profileNDRange = (startEvent != nullptr || stopEvent != nullptr); |
| 368 | |
| 369 | // Flag set to 1 signifies that kernel can be launched in anyorder |
| 370 | if (flags & hipExtAnyOrderLaunch) { |
| 371 | params |= amd::NDRangeKernelCommand::AnyOrderLaunch; |
| 372 | } |
| 373 | |
| 374 | amd::NDRangeKernelCommand* kernelCommand = new amd::NDRangeKernelCommand( |
| 375 | *stream, waitList, *kernel, ndrange, launch_params.sharedMemBytes_, params, gridId, numGrids, |
| 376 | prevGridSum, allGridSum, firstDevice, profileNDRange); |
| 377 | if (!kernelCommand) { |
| 378 | return hipErrorOutOfMemory; |
| 379 | } |
| 380 | |
| 381 | address kernargs = nullptr; |
| 382 | size_t kernargs_size = 0; |
| 383 | // 'extra' is a struct that contains the following info: { |
| 384 | // HIP_LAUNCH_PARAM_BUFFER_POINTER, kernargs, |
| 385 | // HIP_LAUNCH_PARAM_BUFFER_SIZE, &kernargs_size, |
| 386 | // HIP_LAUNCH_PARAM_END } |
| 387 | if (extra != nullptr) { |
| 388 | assert(kernelParams == nullptr); |
| 389 | if (extra[0] != HIP_LAUNCH_PARAM_BUFFER_POINTER || extra[2] != HIP_LAUNCH_PARAM_BUFFER_SIZE || |
| 390 | extra[4] != HIP_LAUNCH_PARAM_END) { |
| 391 | kernelCommand->release(); |
| 392 | return hipErrorInvalidValue; |
| 393 | } |
| 394 | kernargs = reinterpret_cast<address>(extra[1]); |
| 395 | kernargs_size = *reinterpret_cast<size_t*>(extra[3]); |
| 396 | const uint32_t numParams = kernel->signature().numParameters(); |
| 397 | const bool expectsArgs = (numParams > 0); |
| 398 | const bool hasArgs = (kernargs != nullptr && kernargs_size > 0); |
| 399 | // we either expected args but got none, or didn’t expect any but got some |
| 400 | if (expectsArgs == true && hasArgs == false) { |
| 401 | return hipErrorInvalidValue; |
| 402 | } |
| 403 | if (expectsArgs == false && kernargs_size != 0) { |
| 404 | return hipErrorLaunchOutOfResources; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | if (DEBUG_HIP_KERNARG_COPY_OPT) { |
| 409 | if (CL_SUCCESS != |
no test coverage detected