diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_command.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_command.cpp index c7ccfb4ce4..fad490bc09 100644 --- a/projects/clr/opencl/api/opencl/amdocl/cl_command.cpp +++ b/projects/clr/opencl/api/opencl/amdocl/cl_command.cpp @@ -195,42 +195,28 @@ RUNTIME_ENTRY(cl_int, clSetDefaultDeviceCommandQueue, return CL_INVALID_CONTEXT; } - amd::Context& amdContext = *as_amd(context); - amd::Device& amdDevice = *as_amd(device); - amd::DeviceQueue* deviceQueue = as_amd(command_queue)->asDeviceQueue(); + if (!is_valid(command_queue)) { + return CL_INVALID_COMMAND_QUEUE; + } - if (!is_valid(device) || !amdContext.containsDevice(&amdDevice)) { + amd::Context* amdContext = as_amd(context); + amd::Device* amdDevice = as_amd(device); + if (!is_valid(device) || !amdContext->containsDevice(amdDevice)) { return CL_INVALID_DEVICE; } - if (!is_valid(command_queue)) { - return CL_INVALID_VALUE; + amd::DeviceQueue* deviceQueue = as_amd(command_queue)->asDeviceQueue(); + if ((deviceQueue == NULL) || (amdContext != &deviceQueue->context()) || + (amdDevice != &deviceQueue->device())) { + return CL_INVALID_COMMAND_QUEUE; } - - //TODO: implemente the set default device command queue logic - LogWarning("Device support for clSetDefaultDeviceCommandQueue() has not been implemented"); - -#if 0 - // implementation of the set default device command queue logic - unverified - - //TODO: Need to update the clGetCommandQueueInfo to support CL_QUEUE_DEVICE_DEFAULT - // { - amd::ScopedLock lock(amdContext.lock()); - - amd::DeviceQueue* queue = amdContext.defDeviceQueue(amdDevice); - if (NULL != queue) { - amdContext.removeDeviceQueue(amdDevice, queue); - queue->release(); - } - - amdContext.addDeviceQueue(amdDevice, deviceQueue, true); - deviceQueue->retain(); + amd::ScopedLock lock(amdContext->lock()); + amdContext->setDefDeviceQueue(*amdDevice, deviceQueue); } -#endif - return CL_INVALID_VALUE; + return CL_SUCCESS; } RUNTIME_EXIT @@ -348,6 +334,12 @@ RUNTIME_ENTRY(cl_int, clGetCommandQueueInfo, const void* handle = hostQueue->thread().handle(); return amd::clGetInfo(handle, param_value_size, param_value, param_value_size_ret); } + case CL_QUEUE_DEVICE_DEFAULT: { + const amd::Device& device = as_amd(command_queue)->device(); + amd::CommandQueue* defQueue = as_amd(command_queue)->context().defDeviceQueue(device); + cl_command_queue queue = defQueue ? as_cl(defQueue) : NULL; + return amd::clGetInfo(queue, param_value_size, param_value, param_value_size_ret); + } default: break; } diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp index 3416beeb92..8cc2907606 100644 --- a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp +++ b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp @@ -1143,14 +1143,9 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMigrateMem, return CL_INVALID_VALUE; } - //TODO: implemente the svm migration memory logic - LogWarning("Device support for clEnqueueSVMMigrateMem() has not been implemented"); - -#if 0 - // implementation of the svm migration memory logic - unverified - - for (int i = 0; i < num_svm_pointers; i++) { - const void* svm_ptr = svm_pointers[i]; + std::vector memObjects; + for (cl_uint i = 0; i < num_svm_pointers; i++) { + const void* svm_ptr = svm_pointers[i]; amd::Memory* svmMem = amd::SvmManager::FindSvmBuffer(svm_ptr); if (NULL != svmMem) { @@ -1161,19 +1156,15 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMigrateMem, } // Make sure the specified size[i] is within a valid range + // TODO: handle the size parameter properly size_t svm_size = (size == NULL) ? 0 : size[i]; - size_t offset = reinterpret_cast(svm_ptr) - reinterpret_cast(svmMem->getSvmPtr()); - if (offset < 0 || (offset + svm_size) > svmMem->getSize()) { + size_t offset = reinterpret_cast(svm_ptr) - reinterpret_cast
(svmMem->getSvmPtr()); + if ((offset + svm_size) > svmMem->getSize()) { LogWarning("wrong svm address "); return CL_INVALID_VALUE; } - // Make sure we have memory for the command execution - device::Memory* mem = svmMem->getDeviceMemory(queue->device()); - if (NULL == mem) { - LogPrintfError("Can't allocate memory size - 0x%08X bytes!", svmMem->getSize()); - return CL_OUT_OF_RESOURCES; - } + memObjects.push_back(svmMem); } } @@ -1184,22 +1175,27 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMigrateMem, return err; } - amd::Command* command = new amd::SvmMigrateMemCommand(hostQueue, eventWaitList, num_svm_pointers, - svm_pointers, size, flags); + amd::MigrateMemObjectsCommand* command = new amd::MigrateMemObjectsCommand( + hostQueue, CL_COMMAND_MIGRATE_MEM_OBJECTS, eventWaitList, memObjects, flags); if (command == NULL) { return CL_OUT_OF_HOST_MEMORY; } + // Make sure we have memory for the command execution + if (!command->validateMemory()) { + delete command; + return CL_MEM_OBJECT_ALLOCATION_FAILURE; + } + command->enqueue(); *not_null(event) = as_cl(&command->event()); if (event == NULL) { command->release(); } -#endif - return CL_INVALID_VALUE; + return CL_SUCCESS; } RUNTIME_EXIT /*! @}