P4 to Git Change 1477581 by wchau@wchau_WIN_OCL_HSA on 2017/11/01 16:33:34

SWDEV-136305 - [OCL 2.1 Plat] API calls for all drivers

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_command.cpp#15 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#22 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#87 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.hpp#27 edit


[ROCm/clr commit: ab934181fa]
Tá an tiomantas seo le fáil i:
foreman
2017-11-01 16:53:27 -04:00
tuismitheoir 7fa1b2c5b1
tiomantas 80e0bed02b
D'athraigh 2 comhad le 35 breiseanna agus 47 scriosta
+19 -27
Féach ar an gComhad
@@ -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;
}
+16 -20
Féach ar an gComhad
@@ -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<amd::Memory*> 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<uintptr_t>(svm_ptr) - reinterpret_cast<uintptr_t>(svmMem->getSvmPtr());
if (offset < 0 || (offset + svm_size) > svmMem->getSize()) {
size_t offset = reinterpret_cast<const_address>(svm_ptr) - reinterpret_cast<address>(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
/*! @}