-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCLomatic] Add query api mapping for virtual memory APIs (#2586)
Signed-off-by: intwanghao <[email protected]>
- Loading branch information
1 parent
73a93b4
commit 65f34b9
Showing
11 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(CUdeviceptr ptr, size_t size) { | ||
// Start | ||
cuMemAddressFree(ptr /*CUdeviceptr*/, size /*size_t*/); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(CUdeviceptr *ptr, size_t size, size_t alignment, CUdeviceptr addr, | ||
unsigned long long flags) { | ||
// Start | ||
cuMemAddressReserve(ptr /*CUdeviceptr **/, size /*size_t*/, | ||
alignment /*size_t*/, addr /*CUdeviceptr*/, | ||
flags /*unsigned long long*/); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(size_t size, CUmemAllocationProp *prop, unsigned long long flags) { | ||
// Start | ||
CUmemGenericAllocationHandle *handle; | ||
cuMemCreate(handle /*CUmemGenericAllocationHandle **/, size /*size_t*/, | ||
prop /*CUmemAllocationProp **/, flags /*unsigned long long*/); | ||
// End | ||
} |
12 changes: 12 additions & 0 deletions
12
clang/examples/DPCT/Driver/cuMemGetAllocationGranularity.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(size_t *granularity, CUmemAllocationProp *prop, | ||
CUmemAllocationGranularity_flags option) { | ||
// Start | ||
cuMemGetAllocationGranularity(granularity /*size_t | ||
**/ | ||
, | ||
prop /*CUmemAllocationProp **/, | ||
option /*CUmemAllocationGranularity_flags*/); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(CUdeviceptr ptr, size_t size, size_t offset, | ||
unsigned long long flags) { | ||
// Start | ||
CUmemGenericAllocationHandle handle; | ||
cuMemMap(ptr /*CUdeviceptr*/, size /*size_t*/, offset /*size_t*/, | ||
handle /*CUmemGenericAllocationHandle*/, | ||
flags /*unsigned long long */); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test() { | ||
// Start | ||
CUmemGenericAllocationHandle handle; | ||
cuMemRelease(handle /*CUmemGenericAllocationHandle */); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(CUdeviceptr ptr, size_t size, CUmemAccessDesc *desc, size_t count) { | ||
// Start | ||
cuMemSetAccess(ptr /*CUdeviceptr*/, size /*size_t*/, | ||
desc /*CUmemAccessDesc **/, count /*size_t*/); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Option: --use-experimental-features=virtual_mem | ||
#include <cuda.h> | ||
void test(CUdeviceptr ptr, size_t size) { | ||
// Start | ||
cuMemUnmap(ptr /*CUdeviceptr*/, size /*size_t*/); | ||
// End | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
clang/test/dpct/query_api_mapping/Driver/test_virtual_memory.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// UNSUPPORTED: cuda-8.0, cuda-9.0, cuda-9.1, cuda-9.2, cuda-10.0, cuda-10.1, cuda-10.2 | ||
// UNSUPPORTED: v8.0, v9.0, v9.1, v9.2, v10.0, v10.1, v10.2 | ||
/// Virtual Memory Management | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemMap | FileCheck %s -check-prefix=cuMemMap | ||
// cuMemMap: CUDA API: | ||
// cuMemMap-NEXT: CUmemGenericAllocationHandle handle; | ||
// cuMemMap-NEXT: cuMemMap(ptr /*CUdeviceptr*/, size /*size_t*/, offset /*size_t*/, | ||
// cuMemMap-NEXT: handle /*CUmemGenericAllocationHandle*/, | ||
// cuMemMap-NEXT: flags /*unsigned long long */); | ||
// cuMemMap-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemMap-NEXT: dpct::experimental::physical_mem_ptr handle; | ||
// cuMemMap-NEXT: handle->map((uintptr_t)ptr, size, sycl::ext::oneapi::experimental::address_access_mode::read_write, offset); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemRelease | FileCheck %s -check-prefix=cuMemRelease | ||
// cuMemRelease: CUDA API: | ||
// cuMemRelease-NEXT: CUmemGenericAllocationHandle handle; | ||
// cuMemRelease-NEXT: cuMemRelease(handle /*CUmemGenericAllocationHandle */); | ||
// cuMemRelease-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemRelease-NEXT: dpct::experimental::physical_mem_ptr handle; | ||
// cuMemRelease-NEXT: delete (handle); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemUnmap | FileCheck %s -check-prefix=cuMemUnmap | ||
// cuMemUnmap: CUDA API: | ||
// cuMemUnmap-NEXT: cuMemUnmap(ptr /*CUdeviceptr*/, size /*size_t*/); | ||
// cuMemUnmap-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemUnmap-NEXT: sycl::ext::oneapi::experimental::unmap(ptr, size, dpct::get_current_device().get_context()); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemCreate | FileCheck %s -check-prefix=cuMemCreate | ||
// cuMemCreate: CUDA API: | ||
// cuMemCreate-NEXT: CUmemGenericAllocationHandle *handle; | ||
// cuMemCreate-NEXT: cuMemCreate(handle /*CUmemGenericAllocationHandle **/, size /*size_t*/, | ||
// cuMemCreate-NEXT: prop /*CUmemAllocationProp **/, flags /*unsigned long long*/); | ||
// cuMemCreate-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemCreate-NEXT: dpct::experimental::physical_mem_ptr *handle; | ||
// cuMemCreate-NEXT: *handle = new sycl::ext::oneapi::experimental::physical_mem(dpct::get_device(prop->location.id), dpct::get_device(prop->location.id).get_context(), size); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemAddressFree | FileCheck %s -check-prefix=cuMemAddressFree | ||
// cuMemAddressFree: CUDA API: | ||
// cuMemAddressFree-NEXT: cuMemAddressFree(ptr /*CUdeviceptr*/, size /*size_t*/); | ||
// cuMemAddressFree-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemAddressFree-NEXT: sycl::ext::oneapi::experimental::free_virtual_mem((uintptr_t)ptr, size, dpct::get_current_device().get_context()); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemSetAccess | FileCheck %s -check-prefix=cuMemSetAccess | ||
// cuMemSetAccess: CUDA API: | ||
// cuMemSetAccess-NEXT: cuMemSetAccess(ptr /*CUdeviceptr*/, size /*size_t*/, | ||
// cuMemSetAccess-NEXT: desc /*CUmemAccessDesc **/, count /*size_t*/); | ||
// cuMemSetAccess-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemSetAccess-NEXT: sycl::ext::oneapi::experimental::set_access_mode(ptr, size, desc->flags, dpct::get_device(desc->location.id).get_context()); | ||
|
||
// RUN: dpct --cuda-include-path="%cuda-path/include" --query-api-mapping=cuMemGetAllocationGranularity | FileCheck %s -check-prefix=cuMemGetAllocationGranularity | ||
// cuMemGetAllocationGranularity: CUDA API: | ||
// cuMemGetAllocationGranularity-NEXT: cuMemGetAllocationGranularity(granularity /*size_t | ||
// cuMemGetAllocationGranularity-NEXT: **/ | ||
// cuMemGetAllocationGranularity-NEXT: , | ||
// cuMemGetAllocationGranularity-NEXT: prop /*CUmemAllocationProp **/, | ||
// cuMemGetAllocationGranularity-NEXT: option /*CUmemAllocationGranularity_flags*/); | ||
// cuMemGetAllocationGranularity-NEXT: Is migrated to (with the option --use-experimental-features=virtual_mem): | ||
// cuMemGetAllocationGranularity-NEXT: *granularity = sycl::ext::oneapi::experimental::get_mem_granularity(dpct::get_device(prop->location.id), dpct::get_device(prop->location.id).get_context(), option); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters