-
Notifications
You must be signed in to change notification settings - Fork 438
[Compatibility] Support CUDA 11.3 #1290
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,11 @@ using cutlass::bfloat16_t; | |||||||||||||||||||||||||||||
| using cutlass::half_t; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #define TL_DEVICE __forceinline__ __device__ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| #define TL_NOT_IMPLEMENTED() \ | ||||||||||||||||||||||||||||||
| { \ | ||||||||||||||||||||||||||||||
| printf("%s not implemented\n", __PRETTY_FUNCTION__); \ | ||||||||||||||||||||||||||||||
| asm volatile("brkpt;\n"); \ | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| template <typename T> struct normalize_atomic_type { | ||||||||||||||||||||||||||||||
| using type = T; | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
@@ -63,8 +67,12 @@ TL_DEVICE void AtomicMax(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| aref.fetch_max(cuda_cast<NT1>(val), cuda::memory_order(memory_order)); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -89,9 +97,13 @@ TL_DEVICE T1 AtomicMaxRet(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return static_cast<T1>(*reinterpret_cast<T1 *>(&old_val_ushort)); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| return static_cast<T1>( | ||||||||||||||||||||||||||||||
| aref.fetch_max(cuda_cast<NT1>(val), cuda::memory_order(memory_order))); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -117,8 +129,13 @@ TL_DEVICE void AtomicMin(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| aref.fetch_min(cuda_cast<NT1>(val), cuda::memory_order(memory_order)); | ||||||||||||||||||||||||||||||
| return static_cast<T1>( | ||||||||||||||||||||||||||||||
| aref.fetch_min(cuda_cast<NT1>(val), cuda::memory_order(memory_order))); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
|
Comment on lines
+132
to
+138
Contributor
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. Critical: Return statement in void function.
Apply this diff to remove the erroneous return statement: #if CUDART_VERSION >= 11080
cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address);
- return static_cast<T1>(
- aref.fetch_min(cuda_cast<NT1>(val), cuda::memory_order(memory_order)));
+ aref.fetch_min(cuda_cast<NT1>(val), cuda::memory_order(memory_order));
#else
TL_NOT_IMPLEMENTED();
#endif📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -143,9 +160,13 @@ TL_DEVICE T1 AtomicMinRet(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| return static_cast<T1>(*reinterpret_cast<T1 *>(&old_val_ushort)); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| return static_cast<T1>( | ||||||||||||||||||||||||||||||
| aref.fetch_min(cuda_cast<NT1>(val), cuda::memory_order(memory_order))); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -216,8 +237,12 @@ TL_DEVICE void AtomicAdd(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| aref.fetch_add(cuda_cast<NT1>(val), cuda::memory_order(memory_order)); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -290,9 +315,13 @@ TL_DEVICE T1 AtomicAddRet(T1 &ref, T2 val, | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(*address); | ||||||||||||||||||||||||||||||
| return static_cast<T1>( | ||||||||||||||||||||||||||||||
| aref.fetch_add(cuda_cast<NT1>(val), cuda::memory_order(memory_order))); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -618,13 +647,21 @@ AtomicAddx4Ret(float *ref, float *val, | |||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| template <typename T> TL_DEVICE T AtomicLoad(T &ref, int memory_order) { | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<T, cuda::thread_scope_device> aref(ref); | ||||||||||||||||||||||||||||||
| return aref.load(cuda::memory_order(memory_order)); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| template <typename T1, typename T2> | ||||||||||||||||||||||||||||||
| TL_DEVICE void AtomicStore(T1 &ref, T2 value, int memory_order) { | ||||||||||||||||||||||||||||||
| using NT1 = typename normalize_atomic_type<T1>::type; | ||||||||||||||||||||||||||||||
| #if CUDART_VERSION >= 11080 | ||||||||||||||||||||||||||||||
| cuda::atomic_ref<NT1, cuda::thread_scope_device> aref(ref); | ||||||||||||||||||||||||||||||
| aref.store(cuda_cast<NT1>(value), cuda::memory_order(memory_order)); | ||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||
| TL_NOT_IMPLEMENTED(); | ||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
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.
🧩 Analysis chain
Verify CUDA version requirement matches PR objectives.
The code gates atomic operations behind
CUDART_VERSION >= 11080(CUDA 11.8), but the PR title indicates support for CUDA 11.3 (version 11030). Please confirm whether CUDA 11.3 lackscuda::atomic_refsupport, or if the version check should be lowered to 11030.Also applies to: 100-106, 163-169, 240-245, 318-324, 650-655, 661-666
🌐 Web query:
💡 Result:
cuda::atomic_ref was introduced in CUDA Toolkit 11.6. [1][2]
Sources:
[1] CUDA Core Compute Libraries — Synchronization Primitives (cuda::atomic_ref listed as CUDA 11.6).
[2] libcu++ 1.7.0 release notes (libcu++ 1.7.0 / CUDA Toolkit 11.6 adds atomic_ref).
Confirm PR target version—CUDA 11.3 cannot support
cuda::atomic_refoperations.The
cuda::atomic_refAPI was introduced in CUDA Toolkit 11.6, not 11.3. The version gates atCUDART_VERSION >= 11080(CUDA 11.8) are unnecessarily restrictive, but lowering them to 11030 (CUDA 11.3) will not work—the API didn't exist until 11.6.Either the PR target version should be CUDA 11.6+, or alternative implementations must be provided for CUDA 11.3-11.5. The current
TL_NOT_IMPLEMENTED()fallback would fail at runtime for CUDA 11.3 users.Applies to: lines 70-75, 100-106, 163-169, 240-245, 318-324, 650-655, 661-666
🤖 Prompt for AI Agents