-
Notifications
You must be signed in to change notification settings - Fork 97
[SYCLomatic][Driver] Enabled migration of cuPointerGetAttributes #2152
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
Merged
zhimingwang36
merged 14 commits into
oneapi-src:SYCLomatic
from
TejaX-Alaghari:cuPtrGetAttr
Aug 27, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
05965de
Enabled migration of cuPointerGetAttributes
TejaX-Alaghari 9c1d7c1
Corrected format and test case
TejaX-Alaghari 1c98599
Corrected test case
TejaX-Alaghari 1da3c0e
Adjusted the test case
TejaX-Alaghari 54be268
Corrected migration logic
TejaX-Alaghari 5e89557
Corrected type cast of CUmemorytype enum
TejaX-Alaghari fc6153b
Included attribute_types class under pointer_attributes class
TejaX-Alaghari 4af59b1
Added new test case scenario for unsupported attr
TejaX-Alaghari e78dcbc
Merge branch 'SYCLomatic' into cuPtrGetAttr
TejaX-Alaghari 82d700f
Update APINames.inc to include correct status
TejaX-Alaghari 8f49a41
Update memory.hpp
TejaX-Alaghari 26ce162
Merge branch 'SYCLomatic' into cuPtrGetAttr
TejaX-Alaghari e265bfa
Merge branch 'oneapi-src:SYCLomatic' into cuPtrGetAttr
TejaX-Alaghari 26002a2
Merge branch 'SYCLomatic' into cuPtrGetAttr
TejaX-Alaghari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| void test(unsigned int numAttr, CUpointer_attribute *attr, | ||
| void **data, CUdeviceptr ptr) { | ||
| // Start | ||
| cuPointerGetAttributes(numAttr /*unsigned int*/, | ||
| attr /*CUpointer_attribute **/, data /*void ***/, | ||
| ptr /*CUdeviceptr*/); | ||
| // End | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,132 @@ | ||
| // 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 | ||
| // RUN: dpct --format-range=none -out-root %T/Out/cuPointerGetAttributes %s --cuda-include-path="%cuda-path/include" | ||
| // RUN: FileCheck %s --match-full-lines --input-file %T/Out/cuPointerGetAttributes/cuPointerGetAttributes.dp.cpp | ||
| // RUN: %if build_lit %{icpx -c -fsycl %T/Out/cuPointerGetAttributes/cuPointerGetAttributes.dp.cpp -o %T/Out/cuPointerGetAttributes/cuPointerGetAttributes.dp.o %} | ||
| #include <cuda.h> | ||
| #include <cuda_runtime.h> | ||
| #include <stdlib.h> | ||
| #include <iostream> | ||
|
|
||
| int main() { | ||
| int N = 2048; | ||
| size_t size = N * sizeof(float); | ||
|
|
||
| float *h_A = (float *)malloc(size); | ||
|
|
||
| float *d_A; | ||
| cudaMalloc((void **)&d_A, size); | ||
|
|
||
| cudaMemcpy(d_A, h_A, size, cudaMemcpyHostToDevice); | ||
|
|
||
| unsigned int numAttributes = 5; | ||
|
|
||
| // CHECK: dpct::pointer_attributes::type attributes[] = { | ||
| // CHECK: dpct::pointer_attributes::type::memory_type, | ||
| // CHECK: dpct::pointer_attributes::type::device_pointer, | ||
| // CHECK: dpct::pointer_attributes::type::host_pointer, | ||
| // CHECK: dpct::pointer_attributes::type::is_managed, | ||
| // CHECK: dpct::pointer_attributes::type::device_id | ||
| CUpointer_attribute attributes[] = { | ||
| CU_POINTER_ATTRIBUTE_MEMORY_TYPE, | ||
| CU_POINTER_ATTRIBUTE_DEVICE_POINTER, | ||
| CU_POINTER_ATTRIBUTE_HOST_POINTER, | ||
| CU_POINTER_ATTRIBUTE_IS_MANAGED, | ||
| CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL | ||
| }; | ||
|
|
||
| // CHECK: dpct::pointer_attributes::type attributes_unsupported[] = { | ||
| // CHECK: dpct::pointer_attributes::type::unsupported, | ||
| // CHECK: dpct::pointer_attributes::type::unsupported | ||
| CUpointer_attribute attributes_unsupported[] = { | ||
| CU_POINTER_ATTRIBUTE_CONTEXT, | ||
| CU_POINTER_ATTRIBUTE_IS_LEGACY_CUDA_IPC_CAPABLE | ||
| }; | ||
|
|
||
| // CHECK: sycl::usm::alloc memType; | ||
| CUmemorytype memType; | ||
| void* hostPtr; | ||
| unsigned int isManaged; | ||
| int deviceID; | ||
| // CHECK: dpct::device_ptr devPtr; | ||
| CUdeviceptr devPtr; | ||
| CUcontext cuCtx; | ||
| bool is_legacy_cuda_ipc_capable; | ||
|
|
||
| void* attributeValues[] = { | ||
| &memType, | ||
| &devPtr, | ||
| &hostPtr, | ||
| &isManaged, | ||
| &deviceID | ||
| }; | ||
|
|
||
| void* attributeValues_unsupported[] = { | ||
| &cuCtx, | ||
| &is_legacy_cuda_ipc_capable | ||
| }; | ||
|
|
||
| // CHECK: dpct::pointer_attributes::get(numAttributes, attributes, attributeValues, (dpct::device_ptr) h_A); | ||
| cuPointerGetAttributes( | ||
| numAttributes, | ||
| attributes, | ||
| attributeValues, | ||
| (CUdeviceptr) h_A | ||
| ); | ||
|
|
||
| std::cout << "====== Host Attributes =======" << std::endl; | ||
| std::cout << deviceID << std::endl; | ||
| std::cout << static_cast<int>(memType) << std::endl; | ||
| std::cout << hostPtr << std::endl; | ||
| std::cout << devPtr << std::endl; | ||
| std::cout << isManaged << std::endl; | ||
|
|
||
| void * malloc_host; | ||
| cudaMallocHost((void **)&malloc_host, size); | ||
| // CHECK: dpct::pointer_attributes::get(numAttributes, attributes, attributeValues, (dpct::device_ptr) malloc_host); | ||
| cuPointerGetAttributes( | ||
| numAttributes, | ||
| attributes, | ||
| attributeValues, | ||
| (CUdeviceptr) malloc_host | ||
| ); | ||
| std::cout << "====== Malloc Host Attributes =======" << std::endl; | ||
| std::cout << "malloc host " << malloc_host << std::endl; | ||
| std::cout << deviceID << std::endl; | ||
| std::cout << static_cast<int>(memType) << std::endl; | ||
| std::cout << hostPtr << std::endl; | ||
| std::cout << devPtr << std::endl; | ||
| std::cout << isManaged << std::endl; | ||
|
|
||
| // CHECK: dpct::pointer_attributes::get(numAttributes, attributes, attributeValues, (dpct::device_ptr) d_A); | ||
| cuPointerGetAttributes( | ||
| numAttributes, | ||
| attributes, | ||
| attributeValues, | ||
| (CUdeviceptr) d_A | ||
| ); | ||
| std::cout << "====== Device Attributes =======" << std::endl; | ||
| std::cout << *static_cast<int *>(attributeValues[0]) << std::endl; | ||
| std::cout << attributeValues[1] << std::endl; | ||
| std::cout << attributeValues[2] << std::endl; | ||
| std::cout << *static_cast<unsigned int *>(attributeValues[3]) << std::endl; | ||
| std::cout << *static_cast<int *>(attributeValues[4]) << std::endl; | ||
|
|
||
| // CHECK: if (memType == sycl::usm::alloc::host) { | ||
| if (memType == CU_MEMORYTYPE_HOST) { | ||
| return 0; | ||
| // CHECK: } else if (memType == sycl::usm::alloc::device) { | ||
| } else if (memType == CU_MEMORYTYPE_DEVICE) { | ||
| return 1; | ||
| } else if (isManaged) { | ||
| return 2; | ||
| } | ||
|
|
||
| // CHECK: dpct::pointer_attributes::get(2, attributes_unsupported, attributeValues_unsupported, (dpct::device_ptr) d_A); | ||
| cuPointerGetAttributes( | ||
| 2, | ||
| attributes_unsupported, | ||
| attributeValues_unsupported, | ||
| (CUdeviceptr) d_A | ||
| ); | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.