Skip to content

Commit

Permalink
Fix CTS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongreig committed Oct 15, 2024
1 parent e456967 commit a955bec
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 46 deletions.
20 changes: 11 additions & 9 deletions source/adapters/cuda/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
std::vector<CUstream> ComputeCuStreams(1, CuStream);
std::vector<CUstream> TransferCuStreams(0);

auto isNativeHandleOwned =
pProperties ? pProperties->isNativeHandleOwned : false;

// Create queue and set num_compute_streams to 1, as computeCuStreams has
// valid stream
*phQueue =
new ur_queue_handle_t_{std::move(ComputeCuStreams),
std::move(TransferCuStreams),
hContext,
hDevice,
CuFlags,
Flags,
/*priority*/ 0,
/*backend_owns*/ pProperties->isNativeHandleOwned};
*phQueue = new ur_queue_handle_t_{std::move(ComputeCuStreams),
std::move(TransferCuStreams),
hContext,
hDevice,
CuFlags,
Flags,
/*priority*/ 0,
/*backend_owns*/ isNativeHandleOwned};
(*phQueue)->NumComputeStreams = 1;

return UR_RESULT_SUCCESS;
Expand Down
3 changes: 3 additions & 0 deletions source/adapters/hip/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ UR_APIEXPORT ur_result_t UR_APICALL
urMemGetNativeHandle(ur_mem_handle_t hMem, ur_device_handle_t Device,
ur_native_handle_t *phNativeMem) {
UR_ASSERT(Device != nullptr, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
if (hMem->isImage()) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
#if defined(__HIP_PLATFORM_NVIDIA__)
if (sizeof(BufferMem::native_type) > sizeof(ur_native_handle_t)) {
// Check that all the upper bits that cannot be represented by
Expand Down
20 changes: 11 additions & 9 deletions source/adapters/hip/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
std::vector<hipStream_t> ComputeHIPStreams(1, HIPStream);
std::vector<hipStream_t> TransferHIPStreams(0);

auto isNativeHandleOwned =
pProperties ? pProperties->isNativeHandleOwned : false;

// Create queue and set num_compute_streams to 1, as computeHIPStreams has
// valid stream
*phQueue =
new ur_queue_handle_t_{std::move(ComputeHIPStreams),
std::move(TransferHIPStreams),
hContext,
hDevice,
HIPFlags,
Flags,
/*priority*/ 0,
/*backend_owns*/ pProperties->isNativeHandleOwned};
*phQueue = new ur_queue_handle_t_{std::move(ComputeHIPStreams),
std::move(TransferHIPStreams),
hContext,
hDevice,
HIPFlags,
Flags,
/*priority*/ 0,
/*backend_owns*/ isNativeHandleOwned};
(*phQueue)->NumComputeStreams = 1;

return UR_RESULT_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions source/adapters/level_zero/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,9 @@ ur_result_t urKernelCreateWithNativeHandle(
ze_kernel_handle_t ZeKernel = ur_cast<ze_kernel_handle_t>(NativeKernel);
ur_kernel_handle_t_ *Kernel = nullptr;
try {
Kernel = new ur_kernel_handle_t_(ZeKernel, Properties->isNativeHandleOwned,
Context);
if (Properties->isNativeHandleOwned) {
auto OwnNativeHandle = Properties ? Properties->isNativeHandleOwned : false;
Kernel = new ur_kernel_handle_t_(ZeKernel, OwnNativeHandle, Context);
if (OwnNativeHandle) {
// If ownership is passed to the adapter we need to pass the kernel
// to this vector which is then used during ZeKernelRelease.
Kernel->ZeKernels.push_back(ZeKernel);
Expand Down
9 changes: 5 additions & 4 deletions source/adapters/level_zero/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ ur_result_t urProgramGetNativeHandle(
}

default:
return UR_RESULT_ERROR_INVALID_OPERATION;
// L0 only supprts returning native handle from built programs.
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

return UR_RESULT_SUCCESS;
Expand All @@ -959,9 +960,9 @@ ur_result_t urProgramCreateWithNativeHandle(
// executable (state Object).

try {
ur_program_handle_t_ *UrProgram =
new ur_program_handle_t_(ur_program_handle_t_::Exe, Context, ZeModule,
Properties->isNativeHandleOwned);
auto OwnNativeHandle = Properties ? Properties->isNativeHandleOwned : false;
ur_program_handle_t_ *UrProgram = new ur_program_handle_t_(
ur_program_handle_t_::Exe, Context, ZeModule, OwnNativeHandle);
*Program = reinterpret_cast<ur_program_handle_t>(UrProgram);
} catch (const std::bad_alloc &) {
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
Expand Down
1 change: 1 addition & 0 deletions source/adapters/opencl/ur_interface_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ urGetMemProcAddrTable(ur_api_version_t Version, ur_mem_dditable_t *pDdiTable) {
pDdiTable->pfnGetNativeHandle = urMemGetNativeHandle;
pDdiTable->pfnImageCreate = urMemImageCreate;
pDdiTable->pfnImageGetInfo = urMemImageGetInfo;
pDdiTable->pfnImageCreateWithNativeHandle = urMemImageCreateWithNativeHandle;
pDdiTable->pfnRelease = urMemRelease;
pDdiTable->pfnRetain = urMemRetain;
return UR_RESULT_SUCCESS;
Expand Down
1 change: 1 addition & 0 deletions test/conformance/event/event_adapter_native_cpu.match
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ urEventReleaseTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventGetNativeHandleTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventGetNativeHandleTest.InvalidNullPointerNativeEvent/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventCreateWithNativeHandleTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventCreateWithNativeHandleTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventSetCallbackTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventSetCallbackTest.ValidateParameters/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urEventSetCallbackTest.AllStates/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
Expand Down
1 change: 1 addition & 0 deletions test/conformance/kernel/kernel_adapter_native_cpu.match
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ urKernelCreateTest.InvalidNullPointerName/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.
urKernelCreateTest.InvalidNullPointerKernel/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelCreateTest.InvalidKernelName/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelCreateWithNativeHandleTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelCreateWithNativeHandleTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelCreateWithNativeHandleTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelCreateWithNativeHandleTest.InvalidNullPointerNativeKernel/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
urKernelGetGroupInfoTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}__UR_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE
Expand Down
4 changes: 0 additions & 4 deletions test/conformance/program/program_adapter_level_zero.match
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{{NONDETERMINISTIC}}
urProgramCreateWithNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urProgramCreateWithNativeHandleTest.InvalidNullHandleContext/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urProgramCreateWithNativeHandleTest.InvalidNullPointerProgram/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urProgramGetBuildInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_PROGRAM_BUILD_INFO_STATUS
urProgramGetFunctionPointerTest.InvalidKernelName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urProgramGetNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
{{OPT}}urProgramLinkErrorTest.LinkFailure/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
{{OPT}}urProgramLinkErrorTest.SetOutputOnLinkError/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
urProgramSetSpecializationConstantsTest.InvalidValueSize/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}
Expand Down
1 change: 1 addition & 0 deletions test/conformance/program/program_adapter_native_cpu.match
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{{OPT}}urProgramCreateWithILTest.InvalidNullPointerProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramCreateWithILTest.BuildInvalidProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramCreateWithNativeHandleTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramCreateWithNativeHandleTest.SuccessWithProperties/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramCreateWithNativeHandleTest.InvalidNullHandleContext/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramCreateWithNativeHandleTest.InvalidNullPointerProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}
{{OPT}}urProgramGetBuildInfoTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU__{{.*}}__UR_PROGRAM_BUILD_INFO_STATUS
Expand Down
32 changes: 15 additions & 17 deletions test/conformance/testing/include/uur/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ struct urMemImageTest : urContextTest {
if (!imageSupported) {
GTEST_SKIP();
}
ASSERT_SUCCESS(urMemImageCreate(context, 0, &image_format, &image_desc,
nullptr, &image));
}

void TearDown() override {
Expand All @@ -214,23 +216,19 @@ struct urMemImageTest : urContextTest {
UUR_RETURN_ON_FATAL_FAILURE(urContextTest::TearDown());
}

ur_image_format_t image_format = {
/*.channelOrder =*/UR_IMAGE_CHANNEL_ORDER_ARGB,
/*.channelType =*/UR_IMAGE_CHANNEL_TYPE_UNORM_INT8,
};
ur_image_desc_t image_desc = {
/*.stype =*/UR_STRUCTURE_TYPE_IMAGE_DESC,
/*.pNext =*/nullptr,
/*.type =*/UR_MEM_TYPE_IMAGE2D,
/*.width =*/16,
/*.height =*/16,
/*.depth =*/1,
/*.arraySize =*/1,
/*.rowPitch =*/16 * sizeof(char[4]),
/*.slicePitch =*/16 * 16 * sizeof(char[4]),
/*.numMipLevel =*/0,
/*.numSamples =*/0,
};
ur_image_format_t image_format = {UR_IMAGE_CHANNEL_ORDER_RGBA,
UR_IMAGE_CHANNEL_TYPE_FLOAT};
ur_image_desc_t image_desc = {UR_STRUCTURE_TYPE_IMAGE_DESC, // stype
nullptr, // pNext
UR_MEM_TYPE_IMAGE1D, // mem object type
1024, // image width
1, // image height
1, // image depth
1, // array size
0, // row pitch
0, // slice pitch
0, // mip levels
0}; // num samples
ur_mem_handle_t image = nullptr;
};

Expand Down

0 comments on commit a955bec

Please sign in to comment.