Skip to content

Commit

Permalink
[HIP] Fix segfaults
Browse files Browse the repository at this point in the history
  • Loading branch information
veselypeta committed Oct 19, 2023
1 parent 93e7c18 commit 924d74b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
8 changes: 6 additions & 2 deletions source/adapters/hip/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName,
ScopedContext Active(hProgram->getContext()->getDevice());

hipFunction_t HIPFunc;
UR_CHECK_ERROR(
hipModuleGetFunction(&HIPFunc, hProgram->get(), pKernelName));
hipError_t KernelError =
hipModuleGetFunction(&HIPFunc, hProgram->get(), pKernelName);
if (KernelError == hipErrorNotFound) {
return UR_RESULT_ERROR_INVALID_KERNEL_NAME;
}
UR_CHECK_ERROR(KernelError);

std::string KernelNameWoffset = std::string(pKernelName) + "_with_offset";
hipFunction_t HIPFuncWithOffsetParam;
Expand Down
1 change: 1 addition & 0 deletions test/conformance/enqueue/enqueue_adapter_hip.match
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{OPT}} Segmentation fault
urEnqueueDeviceGetGlobalVariableReadTest.Success/AMD_HIP_BACKEND___{{.*}}_
urEnqueueDeviceGetGlobalVariableReadTest.InvalidEventWaitInvalidEvent/AMD_HIP_BACKEND___{{.*}}_
urEnqueueDeviceGetGlobalVariableWriteTest.InvalidEventWaitInvalidEvent/AMD_HIP_BACKEND___{{.*}}_
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/kernel/kernel_adapter_hip.match
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
urKernelCreateTest.InvalidKernelName/AMD_HIP_BACKEND___{{.*}}_
{{OPT}} Segmentation fault
urKernelGetInfoTest.Success/AMD_HIP_BACKEND___{{.*}}___UR_KERNEL_INFO_NUM_REGS
urKernelGetInfoTest.InvalidSizeSmall/AMD_HIP_BACKEND___{{.*}}___UR_KERNEL_INFO_FUNCTION_NAME
urKernelGetInfoTest.InvalidSizeSmall/AMD_HIP_BACKEND___{{.*}}___UR_KERNEL_INFO_NUM_ARGS
Expand Down
8 changes: 4 additions & 4 deletions test/conformance/kernel/urKernelCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ struct urKernelCreateTest : uur::urProgramTest {
UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelCreateTest);

TEST_P(urKernelCreateTest, Success) {
ASSERT_SUCCESS(urKernelCreate(program, kernel_name.data(), &kernel));
ASSERT_SUCCESS(urKernelCreate(program, kernel_name.c_str(), &kernel));
}

TEST_P(urKernelCreateTest, InvalidNullHandleProgram) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
urKernelCreate(nullptr, kernel_name.data(), &kernel));
urKernelCreate(nullptr, kernel_name.c_str(), &kernel));
}

TEST_P(urKernelCreateTest, InvalidNullPointerName) {
Expand All @@ -43,11 +43,11 @@ TEST_P(urKernelCreateTest, InvalidNullPointerName) {

TEST_P(urKernelCreateTest, InvalidNullPointerKernel) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
urKernelCreate(program, kernel_name.data(), nullptr));
urKernelCreate(program, kernel_name.c_str(), nullptr));
}

TEST_P(urKernelCreateTest, InvalidKernelName) {
std::string invalid_name = "incorrect_kernel_name";
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME,
urKernelCreate(program, invalid_name.data(), &kernel));
urKernelCreate(program, invalid_name.c_str(), &kernel));
}
1 change: 1 addition & 0 deletions test/conformance/program/program_adapter_hip.match
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{OPT}} Segmentation fault
urProgramCreateWithNativeHandleTest.InvalidNullHandleContext/AMD_HIP_BACKEND___{{.*}}_
urProgramCreateWithNativeHandleTest.InvalidNullPointerProgram/AMD_HIP_BACKEND___{{.*}}_
urProgramGetBuildInfoTest.Success/AMD_HIP_BACKEND___{{.*}}___UR_PROGRAM_BUILD_INFO_BINARY_TYPE
Expand Down

0 comments on commit 924d74b

Please sign in to comment.