-
Notifications
You must be signed in to change notification settings - Fork 93
[External Resource Interop][Semaphores] Added support for 2 more semaphore types #2751
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
Closed
Closed
Changes from all commits
Commits
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,7 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(cudaExternalMemory_t extMem) { | ||
// Start | ||
cudaDestroyExternalMemory(extMem /*cudaExternalMemory_t*/); | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(cudaExternalSemaphore_t extSem) { | ||
// Start | ||
cudaDestroyExternalSemaphore(extSem /*cudaExternalSemaphore_t*/); | ||
// End | ||
} |
10 changes: 10 additions & 0 deletions
10
clang/examples/DPCT/Runtime/cudaExternalMemoryGetMappedBuffer.cu
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,10 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(void **devPtr, cudaExternalMemory_t extMem, | ||
const cudaExternalMemoryBufferDesc *bufferDesc) { | ||
// Start | ||
cudaExternalMemoryGetMappedBuffer( | ||
devPtr /*void ***/, extMem /*cudaExternalMemory_t*/, | ||
bufferDesc /*const cudaExternalMemoryBufferDesc **/); | ||
// End | ||
} |
10 changes: 10 additions & 0 deletions
10
clang/examples/DPCT/Runtime/cudaExternalMemoryGetMappedMipmappedArray.cu
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,10 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(cudaMipmappedArray_t *mipmap, cudaExternalMemory_t extMem, | ||
const cudaExternalMemoryMipmappedArrayDesc *mipmapDesc) { | ||
// Start | ||
cudaExternalMemoryGetMappedMipmappedArray( | ||
mipmap /*cudaMipmappedArray_t **/, extMem /*cudaExternalMemory_t*/, | ||
mipmapDesc /*const cudaExternalMemoryMipmappedArrayDesc **/); | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(cudaExternalMemory_t *extMem, | ||
const cudaExternalMemoryHandleDesc *memHandleDesc) { | ||
// Start | ||
cudaImportExternalMemory( | ||
extMem /*cudaExternalMemory_t **/, | ||
memHandleDesc /*const cudaExternalMemoryHandleDesc **/); | ||
// End | ||
} |
10 changes: 10 additions & 0 deletions
10
clang/examples/DPCT/Runtime/cudaImportExternalSemaphore.cu
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,10 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(cudaExternalSemaphore_t *extSem, | ||
const cudaExternalSemaphoreHandleDesc *semHandleDesc) { | ||
// Start | ||
cudaImportExternalSemaphore( | ||
extSem /*cudaExternalSemaphore_t **/, | ||
semHandleDesc /*const cudaExternalSemaphoreHandleDesc **/); | ||
// End | ||
} |
16 changes: 16 additions & 0 deletions
16
clang/examples/DPCT/Runtime/cudaSignalExternalSemaphoresAsync.cu
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,16 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(const cudaExternalSemaphore_t *extSemArray, | ||
const cudaExternalSemaphoreSignalParams *paramsArray, | ||
unsigned int numExtSems, cudaStream_t stream = 0) { | ||
// Start | ||
cudaSignalExternalSemaphoresAsync( | ||
extSemArray /*const cudaExternalSemaphore_t **/, | ||
paramsArray /*const cudaExternalSemaphoreSignalParams **/, | ||
numExtSems /*unsigned int*/); | ||
cudaSignalExternalSemaphoresAsync( | ||
extSemArray /*const cudaExternalSemaphore_t **/, | ||
paramsArray /*const cudaExternalSemaphoreSignalParams **/, | ||
numExtSems /*unsigned int*/, stream /*cudaStream_t*/); | ||
// End | ||
} |
16 changes: 16 additions & 0 deletions
16
clang/examples/DPCT/Runtime/cudaWaitExternalSemaphoresAsync.cu
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,16 @@ | ||
// Option: --use-experimental-features=bindless_images | ||
|
||
void test(const cudaExternalSemaphore_t *extSemArray, | ||
const cudaExternalSemaphoreWaitParams *paramsArray, | ||
unsigned int numExtSems, cudaStream_t stream = 0) { | ||
// Start | ||
cudaWaitExternalSemaphoresAsync( | ||
extSemArray /*const cudaExternalSemaphore_t **/, | ||
paramsArray /*const cudaExternalSemaphoreWaitParams **/, | ||
numExtSems /*unsigned int*/); | ||
cudaWaitExternalSemaphoresAsync( | ||
extSemArray /*const cudaExternalSemaphore_t **/, | ||
paramsArray /*const cudaExternalSemaphoreWaitParams **/, | ||
numExtSems /*unsigned int*/, stream /*cudaStream_t*/); | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,31 +1307,40 @@ inline void import_external_semaphore(external_sem_wrapper **extSem, | |
/// parameters. | ||
/// \param [in] numExtSems Number of external semaphores to signal. | ||
/// \param [in] q_ptr The queue used to signal the external semaphore resource. | ||
inline void signal_external_semaphore(external_sem_wrapper **extSem, | ||
external_sem_params *semSignalParams, | ||
unsigned int numExtSems, | ||
queue_ptr q_ptr = &get_default_queue()) { | ||
inline void signal_external_semaphores(external_sem_wrapper **extSem, | ||
external_sem_params *semSignalParams, | ||
unsigned int numExtSems, | ||
queue_ptr q_ptr = &get_default_queue()) { | ||
for (int i = 0; i < numExtSems; i++) { | ||
auto extSemType = extSem[i]->get_handle_type(); | ||
switch (extSemType) { | ||
#ifdef _WIN32 | ||
if (extSemType == sycl::ext::oneapi::experimental:: | ||
external_semaphore_handle_type::win32_nt_dx12_fence) { | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be merge WIN32 together? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I'll refactor the switch case |
||
win32_nt_dx12_fence: | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
timeline_win32_nt_handle: | ||
q_ptr->ext_oneapi_signal_external_semaphore( | ||
extSem[i]->get(), semSignalParams[i].get_value()); | ||
} else if (extSemType == | ||
sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
win32_nt_handle) { | ||
break; | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
win32_nt_handle: | ||
q_ptr->ext_oneapi_signal_external_semaphore(extSem[i]->get()); | ||
} | ||
#else | ||
if (extSemType == sycl::ext::oneapi::experimental:: | ||
external_semaphore_handle_type::opaque_fd) { | ||
break; | ||
#else // _WIN32 | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
timeline_fd: | ||
q_ptr->ext_oneapi_signal_external_semaphore( | ||
extSem[i]->get(), semSignalParams[i].get_value()); | ||
break; | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
opaque_fd: | ||
q_ptr->ext_oneapi_signal_external_semaphore(extSem[i]->get()); | ||
} | ||
break; | ||
#endif // _WIN32 | ||
else { | ||
default: | ||
throw std::runtime_error( | ||
"Unsupported external semaphore resource handle type!"); | ||
break; | ||
} | ||
} | ||
} | ||
|
@@ -1341,31 +1350,40 @@ inline void signal_external_semaphore(external_sem_wrapper **extSem, | |
/// \param [in] semWaitParams Pointer to the external semaphore wait parameters. | ||
/// \param [in] numExtSems Number of external semaphores to wait. | ||
/// \param [in] q_ptr The queue used to wait on the external semaphore resource. | ||
inline void wait_external_semaphore(external_sem_wrapper **extSem, | ||
external_sem_params *semWaitParams, | ||
unsigned int numExtSems, | ||
queue_ptr q_ptr = &get_default_queue()) { | ||
inline void wait_external_semaphores(external_sem_wrapper **extSem, | ||
external_sem_params *semWaitParams, | ||
unsigned int numExtSems, | ||
queue_ptr q_ptr = &get_default_queue()) { | ||
for (int i = 0; i < numExtSems; i++) { | ||
auto extSemType = extSem[i]->get_handle_type(); | ||
switch (extSemType) { | ||
#ifdef _WIN32 | ||
if (extSemType == sycl::ext::oneapi::experimental:: | ||
external_semaphore_handle_type::win32_nt_dx12_fence) { | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
win32_nt_dx12_fence: | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
timeline_win32_nt_handle: | ||
q_ptr->ext_oneapi_wait_external_semaphore(extSem[i]->get(), | ||
semWaitParams[i].get_value()); | ||
} else if (extSemType == | ||
sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
win32_nt_handle) { | ||
break; | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
win32_nt_handle: | ||
q_ptr->ext_oneapi_wait_external_semaphore(extSem[i]->get()); | ||
} | ||
#else | ||
if (extSemType == sycl::ext::oneapi::experimental:: | ||
external_semaphore_handle_type::opaque_fd) { | ||
break; | ||
#else // _WIN32 | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
timeline_fd: | ||
q_ptr->ext_oneapi_wait_external_semaphore(extSem[i]->get(), | ||
semWaitParams[i].get_value()); | ||
break; | ||
case sycl::ext::oneapi::experimental::external_semaphore_handle_type:: | ||
opaque_fd: | ||
q_ptr->ext_oneapi_wait_external_semaphore(extSem[i]->get()); | ||
} | ||
break; | ||
#endif // _WIN32 | ||
else { | ||
default: | ||
throw std::runtime_error( | ||
"Unsupported external semaphore resource handle type!"); | ||
break; | ||
} | ||
} | ||
} | ||
|
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the migration?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration for
cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd
isexternal_semaphore_handle_type::timeline_fd
here