Skip to content

Commit

Permalink
[SYCLomatic] Emit msg to suggest user use "--use-experimental-feature…
Browse files Browse the repository at this point in the history
…s=virtual_mem" to migrate virtual mem API (#2562)

Signed-off-by: intwanghao <hao3.wang@intel.com>
  • Loading branch information
intwanghao authored Dec 12, 2024
1 parent 2ee47bf commit 7a4b708
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions clang/lib/DPCT/RulesLang/RulesLang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8123,6 +8123,13 @@ void DriverDeviceAPIRule::runRule(
auto SecArg = CE->getArg(1);
if (auto DRE = dyn_cast<DeclRefExpr>(SecArg)) {
auto AttributeName = DRE->getNameInfo().getAsString();
if (AttributeName ==
"CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED" &&
!DpctGlobalInfo::useExpVirtualMemory()) {
report(CE->getBeginLoc(), Diagnostics::TRY_EXPERIMENTAL_FEATURE, false,
AttributeName, "--use-experimental-features=virtual_mem");
return;
}
auto Search = MapNames::EnumNamesMap.find(AttributeName);
if (Search == MapNames::EnumNamesMap.end()) {
report(CE->getBeginLoc(), Diagnostics::NOT_SUPPORTED_PARAMETER, false,
Expand Down
8 changes: 6 additions & 2 deletions clang/test/dpct/driver_device_after11.2.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v11.1
// RUN: dpct --format-range=none -out-root %T/driver_device_after11.2 %s --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
// RUN: FileCheck %s --match-full-lines --input-file %T/driver_device_after11.2/driver_device_after11.2.dp.cpp
// RUN: %if build_lit %{icpx -c -fsycl %T/driver_device_after11.2/driver_device_after11.2.dp.cpp -o %T/driver_device_after11.2/driver_device_after11.2.dp.o %}
// RUN: %if build_lit %{icpx -c -fsycl -DBUILD_TEST %T/driver_device_after11.2/driver_device_after11.2.dp.cpp -o %T/driver_device_after11.2/driver_device_after11.2.dp.o %}

#include <cuda.h>

int main() {
int i;
CUdevice d;
// CHECK: i = dpct::get_device(d).has(sycl::aspect::ext_oneapi_virtual_mem);
#ifndef BUILD_TEST
// CHECK: /*
// CHECK-NEXT: DPCT1119:{{[0-9]+}}: Migration of CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED is not supported, please try to remigrate with option: --use-experimental-features=virtual_mem.
// CHECK-NEXT: */
cuDeviceGetAttribute(&i, CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED, d);
#endif
return 0;
}
15 changes: 15 additions & 0 deletions clang/test/dpct/driver_device_virtual_mem_after11.2.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2, cuda-11.0, cuda-11.1
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2, v11.0, v11.1
// RUN: dpct --format-range=none --use-experimental-features=virtual_mem -out-root %T/driver_device_virtual_mem_after11.2 %s --cuda-include-path="%cuda-path/include" -- -std=c++14 -x cuda --cuda-host-only
// RUN: FileCheck %s --match-full-lines --input-file %T/driver_device_virtual_mem_after11.2/driver_device_virtual_mem_after11.2.dp.cpp
// RUN: %if build_lit %{icpx -c -fsycl %T/driver_device_virtual_mem_after11.2/driver_device_virtual_mem_after11.2.dp.cpp -o %T/driver_device_virtual_mem_after11.2/driver_device_virtual_mem_after11.2.dp.o %}

#include <cuda.h>

int main() {
int i;
CUdevice d;
// CHECK: i = dpct::get_device(d).has(sycl::aspect::ext_oneapi_virtual_mem);
cuDeviceGetAttribute(&i, CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED, d);
return 0;
}

0 comments on commit 7a4b708

Please sign in to comment.