Skip to content

Commit 00761dc

Browse files
committed
[SYCL][CUDA] Multiple fixes for the CUDA adapter (#11121)
- Return correct error code in urContextCreateWithNativeHandle - Add UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT to urDeviceGetInfo - Move asserts from urEnqueueMemBufferFill to UR validation layers (commit 2c533e6 on UR repository) - Make behaviour of urEventSetCallback consistent with other unsupported entrypoints. - urProgramGetInfo and urQueueGetInfo now return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION for unsupported cases. - Add entrypoints for urSamplerGetNativeHandle and urSamplerCreateWithNativeHandle - Fix UR_USM_ALLOC_INFO_BASE_PTR and UR_USM_ALLOC_INFO_SIZE implementation.
1 parent 905d2f2 commit 00761dc

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle(
150150
std::ignore = pProperties;
151151
std::ignore = phContext;
152152

153-
return UR_RESULT_ERROR_INVALID_OPERATION;
153+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
154154
}
155155

156156
UR_APIEXPORT ur_result_t UR_APICALL urContextSetExtendedDeleter(

device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10261026
case UR_DEVICE_INFO_GPU_SUBSLICES_PER_SLICE:
10271027
case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE:
10281028
case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU:
1029+
case UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT:
10291030
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
10301031

10311032
default:

enqueue.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -731,19 +731,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferFill(
731731
UR_ASSERT(size + offset <= hBuffer->Mem.BufferMem.getSize(),
732732
UR_RESULT_ERROR_INVALID_SIZE);
733733

734-
auto ArgsAreMultiplesOfPatternSize =
735-
(offset % patternSize == 0) || (size % patternSize == 0);
736-
737-
auto PatternIsValid = (pPattern != nullptr);
738-
739-
auto PatternSizeIsValid =
740-
((patternSize & (patternSize - 1)) == 0) && // is power of two
741-
(patternSize > 0) && (patternSize <= 128); // falls within valid range
742-
743-
UR_ASSERT(ArgsAreMultiplesOfPatternSize && PatternIsValid &&
744-
PatternSizeIsValid,
745-
UR_RESULT_ERROR_INVALID_SIZE);
746-
747734
std::unique_ptr<ur_event_handle_t_> RetImplEvent{nullptr};
748735

749736
try {

event.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback(ur_event_handle_t,
219219
ur_execution_info_t,
220220
ur_event_callback_t,
221221
void *) {
222-
detail::ur::die("Event Callback not implemented in CUDA adapter");
223222
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
224223
}
225224

program.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
315315
case UR_PROGRAM_INFO_BINARIES:
316316
return ReturnValue(&hProgram->Binary, 1);
317317
case UR_PROGRAM_INFO_KERNEL_NAMES:
318-
return getKernelNames(hProgram);
318+
/* TODO: Add implementation for getKernelNames */
319+
UR_ASSERT(getKernelNames(hProgram), UR_RESULT_ERROR_UNSUPPORTED_FEATURE);
320+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
321+
case UR_PROGRAM_INFO_NUM_KERNELS:
322+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
319323
default:
320324
break;
321325
}

queue.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
311311
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
312312
}
313313
}
314-
default:
314+
case UR_QUEUE_INFO_DEVICE_DEFAULT:
315+
case UR_QUEUE_INFO_SIZE:
315316
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
317+
default:
318+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
316319
}
317-
318-
return UR_RESULT_ERROR_INVALID_ENUMERATION;
319320
}

sampler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,14 @@ urSamplerRelease(ur_sampler_handle_t hSampler) {
9393

9494
return UR_RESULT_SUCCESS;
9595
}
96+
97+
UR_APIEXPORT ur_result_t UR_APICALL
98+
urSamplerGetNativeHandle(ur_sampler_handle_t, ur_native_handle_t *) {
99+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
100+
}
101+
102+
UR_APIEXPORT ur_result_t UR_APICALL urSamplerCreateWithNativeHandle(
103+
ur_native_handle_t, ur_context_handle_t,
104+
const ur_sampler_native_properties_t *, ur_sampler_handle_t *) {
105+
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
106+
}

ur_interface_loader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetPlatformProcAddrTable(
4040
pDdiTable->pfnGet = urPlatformGet;
4141
pDdiTable->pfnGetApiVersion = urPlatformGetApiVersion;
4242
pDdiTable->pfnGetInfo = urPlatformGetInfo;
43-
pDdiTable->pfnGetNativeHandle = nullptr;
43+
pDdiTable->pfnGetNativeHandle = urPlatformGetNativeHandle;
4444
pDdiTable->pfnGetBackendOption = urPlatformGetBackendOption;
4545
return UR_RESULT_SUCCESS;
4646
}
@@ -132,9 +132,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetSamplerProcAddrTable(
132132
return result;
133133
}
134134
pDdiTable->pfnCreate = urSamplerCreate;
135-
pDdiTable->pfnCreateWithNativeHandle = nullptr;
135+
pDdiTable->pfnCreateWithNativeHandle = urSamplerCreateWithNativeHandle;
136136
pDdiTable->pfnGetInfo = urSamplerGetInfo;
137-
pDdiTable->pfnGetNativeHandle = nullptr;
137+
pDdiTable->pfnGetNativeHandle = urSamplerGetNativeHandle;
138138
pDdiTable->pfnRelease = urSamplerRelease;
139139
pDdiTable->pfnRetain = urSamplerRetain;
140140
return UR_RESULT_SUCCESS;

usm.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,21 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem,
232232
#endif
233233
}
234234
case UR_USM_ALLOC_INFO_BASE_PTR: {
235-
#if __CUDA_API_VERSION >= 10020
235+
#if CUDA_VERSION >= 10020
236236
// CU_POINTER_ATTRIBUTE_RANGE_START_ADDR was introduced in CUDA 10.2
237-
unsigned int Value;
238-
result = UR_CHECK_ERROR(cuPointerGetAttribute(
239-
&Value, CU_POINTER_ATTRIBUTE_RANGE_START_ADDR, (CUdeviceptr)pMem));
240-
return ReturnValue(Value);
237+
void *Base;
238+
Result = UR_CHECK_ERROR(cuPointerGetAttribute(
239+
&Base, CU_POINTER_ATTRIBUTE_RANGE_START_ADDR, (CUdeviceptr)pMem));
240+
return ReturnValue(Base);
241241
#else
242242
return UR_RESULT_ERROR_INVALID_VALUE;
243243
#endif
244244
}
245245
case UR_USM_ALLOC_INFO_SIZE: {
246-
#if __CUDA_API_VERSION >= 10020
246+
#if CUDA_VERSION >= 10020
247247
// CU_POINTER_ATTRIBUTE_RANGE_SIZE was introduced in CUDA 10.2
248-
unsigned int Value;
249-
result = UR_CHECK_ERROR(cuPointerGetAttribute(
248+
size_t Value;
249+
Result = UR_CHECK_ERROR(cuPointerGetAttribute(
250250
&Value, CU_POINTER_ATTRIBUTE_RANGE_SIZE, (CUdeviceptr)pMem));
251251
return ReturnValue(Value);
252252
#else

0 commit comments

Comments
 (0)