Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCLomatic] Fix unsuccessful compilation of dpct::load_kernel_library_mem due to failed argument cast #2525

Merged
merged 8 commits into from
Dec 2, 2024
4 changes: 2 additions & 2 deletions clang/lib/DPCT/RulesLang/APINamesDriver.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ FEATURE_REQUEST_FACTORY(
ASSIGNABLE_FACTORY(ASSIGN_FACTORY_ENTRY("cuModuleLoadData", DEREF(0),
CALL(MapNames::getDpctNamespace() +
"load_kernel_library_mem",
ARG(1)))))
CAST(makeLiteral("const char *"), ARG(1))))))
the-slow-one marked this conversation as resolved.
Show resolved Hide resolved

FEATURE_REQUEST_FACTORY(
HelperFeatureEnum::device_ext,
ASSIGNABLE_FACTORY(ASSIGN_FACTORY_ENTRY("cuModuleLoadDataEx", DEREF(0),
CALL(MapNames::getDpctNamespace() +
"load_kernel_library_mem",
ARG(1)))))
CAST(makeLiteral("const char *"), ARG(1))))))
the-slow-one marked this conversation as resolved.
Show resolved Hide resolved
the-slow-one marked this conversation as resolved.
Show resolved Hide resolved

FEATURE_REQUEST_FACTORY(
HelperFeatureEnum::device_ext,
Expand Down
19 changes: 16 additions & 3 deletions clang/test/dpct/module_main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ int main(){
//CHECK: /*
//CHECK-NEXT: DPCT1104:{{[0-9]+}}: 'Data.c_str()' should point to a dynamic library loaded in memory. The dynamic library should supply wrapped kernel functions.
//CHECK-NEXT: */
//CHECK-NEXT: M = dpct::load_kernel_library_mem(Data.c_str());
//CHECK-NEXT: M = dpct::load_kernel_library_mem((const char *)Data.c_str());
the-slow-one marked this conversation as resolved.
Show resolved Hide resolved
cuModuleLoadData(&M, Data.c_str());

unsigned char *DataPtr;
//CHECK: /*
//CHECK-NEXT: DPCT1104:{{[0-9]+}}: 'DataPtr)' should point to a dynamic library loaded in memory. The dynamic library should supply wrapped kernel functions.
//CHECK-NEXT: */
//CHECK-NEXT: M = dpct::load_kernel_library_mem((const char *)DataPtr);
cuModuleLoadData(&M, DataPtr);

//CHECK: /*
//CHECK-NEXT: DPCT1104:{{[0-9]+}}: 'Data.c_str()' should point to a dynamic library loaded in memory. The dynamic library should supply wrapped kernel functions.
//CHECK-NEXT: */
//CHECK-NEXT: M = dpct::load_kernel_library_mem(Data.c_str());
//CHECK-NEXT: M = dpct::load_kernel_library_mem((const char *)Data.c_str());
the-slow-one marked this conversation as resolved.
Show resolved Hide resolved
cuModuleLoadDataEx(&M, Data.c_str(), 0, NULL, NULL);

//CHECK: /*
//CHECK-NEXT: DPCT1104:{{[0-9]+}}: 'DataPtr' should point to a dynamic library loaded in memory. The dynamic library should supply wrapped kernel functions.
//CHECK-NEXT: */
//CHECK-NEXT: M = dpct::load_kernel_library_mem((const char *)DataPtr);
cuModuleLoadDataEx(&M, DataPtr, 0, NULL, NULL);

//CHECK: F = dpct::get_kernel_function(M, FunctionName.c_str());
cuModuleGetFunction(&F, M, FunctionName.c_str());

Expand Down Expand Up @@ -66,4 +79,4 @@ int main(){
}

return 0;
}
}