-
Notifications
You must be signed in to change notification settings - Fork 72
Fix async error reporting and memory type handling in CCLAdaptor and DeviceAdaptor #266
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,14 +45,14 @@ flagcxResult_t cudaAdaptorDeviceMalloc(void **ptr, size_t size, | |
| flagcxStream_t stream) { | ||
| if (type == flagcxMemHost) { | ||
| DEVCHECK(cudaHostAlloc(ptr, size, cudaHostAllocMapped)); | ||
| } else if (type == flagcxMemDevice) { | ||
| } else if (type == flagcxMemManaged) { | ||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||
| } else { | ||
| if (stream == NULL) { | ||
| DEVCHECK(cudaMalloc(ptr, size)); | ||
| } else { | ||
| DEVCHECK(cudaMallocAsync(ptr, size, stream->base)); | ||
| } | ||
| } else if (type == flagcxMemManaged) { | ||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||
| } | ||
| return flagcxSuccess; | ||
| } | ||
|
|
@@ -61,14 +61,14 @@ flagcxResult_t cudaAdaptorDeviceFree(void *ptr, flagcxMemType_t type, | |
| flagcxStream_t stream) { | ||
| if (type == flagcxMemHost) { | ||
| DEVCHECK(cudaFreeHost(ptr)); | ||
| } else if (type == flagcxMemDevice) { | ||
| } else if (type == flagcxMemManaged) { | ||
| DEVCHECK(cudaFree(ptr)); | ||
| } else { | ||
| if (stream == NULL) { | ||
| DEVCHECK(cudaFree(ptr)); | ||
| } else { | ||
| DEVCHECK(cudaFreeAsync(ptr, stream->base)); | ||
| } | ||
| } else if (type == flagcxMemManaged) { | ||
| DEVCHECK(cudaFree(ptr)); | ||
| } | ||
|
Comment on lines
+66
to
72
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. For improved clarity and robustness, it's better to explicitly check for } else if (type == flagcxMemDevice) {
if (stream == NULL) {
DEVCHECK(cudaFree(ptr));
} else {
DEVCHECK(cudaFreeAsync(ptr, stream->base));
}
} |
||
| return flagcxSuccess; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,14 +45,14 @@ flagcxResult_t ducudaAdaptorDeviceMalloc(void **ptr, size_t size, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocHost(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMalloc(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocAsync(ptr, size, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
MC952-arch marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -61,14 +61,14 @@ flagcxResult_t ducudaAdaptorDeviceFree(void *ptr, flagcxMemType_t type, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeHost(ptr)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeAsync(ptr, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
72
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. For improved clarity and robustness, it's better to explicitly check for
Suggested change
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,14 +45,14 @@ flagcxResult_t hipAdaptorDeviceMalloc(void **ptr, size_t size, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipHostMalloc(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipMallocManaged(ptr, size, hipMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipMalloc(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipMallocAsync(ptr, size, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipMallocManaged(ptr, size, hipMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
MC952-arch marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -61,14 +61,14 @@ flagcxResult_t hipAdaptorDeviceFree(void *ptr, flagcxMemType_t type, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipFreeHost(ptr)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipFreeAsync(ptr, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(hipFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
72
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. For improved clarity and robustness, it's better to explicitly check for
Suggested change
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,14 +45,14 @@ flagcxResult_t ixcudaAdaptorDeviceMalloc(void **ptr, size_t size, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocHost(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMalloc(ptr, size)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocAsync(ptr, size, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+50
to
56
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. For improved clarity and robustness, it's better to explicitly check for
Suggested change
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -61,14 +61,14 @@ flagcxResult_t ixcudaAdaptorDeviceFree(void *ptr, flagcxMemType_t type, | |||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeHost(ptr)); | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeAsync(ptr, stream->base)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+66
to
72
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. For improved clarity and robustness, it's better to explicitly check for
Suggested change
|
||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,16 +47,16 @@ flagcxResult_t kunlunAdaptorDeviceMalloc(void **ptr, size_t size, | |||||||||||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocHost(ptr, size)); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMalloc(ptr, size)); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| // The underlying interface here is synchronous, not an asynchronous | ||||||||||||||||||||||||||||||||||||||||||
| // implementation. | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocAsync(ptr, size, stream->base)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaMallocManaged(ptr, size, cudaMemAttachGlobal)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+52
to
60
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. For improved clarity and robustness, it's better to explicitly check for
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -65,16 +65,16 @@ flagcxResult_t kunlunAdaptorDeviceFree(void *ptr, flagcxMemType_t type, | |||||||||||||||||||||||||||||||||||||||||
| flagcxStream_t stream) { | ||||||||||||||||||||||||||||||||||||||||||
| if (type == flagcxMemHost) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeHost(ptr)); | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemDevice) { | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| if (stream == NULL) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| // The underlying interface here is synchronous, not an asynchronous | ||||||||||||||||||||||||||||||||||||||||||
| // implementation. | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFreeAsync(ptr, stream->base)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } else if (type == flagcxMemManaged) { | ||||||||||||||||||||||||||||||||||||||||||
| DEVCHECK(cudaFree(ptr)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
MC952-arch marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||
| return flagcxSuccess; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.