[clang] [llvm] [OpenMP][Clang] Migrate OpenMP UserDefinedMapper from Clang to OMPIRBuilder (PR #110001)

2024-10-08 Thread Dhruva Chakrabarti via cfe-commits


@@ -2801,6 +2801,67 @@ class OpenMPIRBuilder {
   using GenMapInfoCallbackTy =
   function_ref;
 
+private:
+  /// Emit the array initialization or deletion portion for user-defined mapper
+  /// code generation. First, it evaluates whether an array section is mapped
+  /// and whether the \a MapType instructs to delete this section. If \a IsInit
+  /// is true, and \a MapType indicates to not delete this array, array
+  /// initialization code is generated. If \a IsInit is false, and \a MapType
+  /// indicates to not this array, array deletion code is generated.

dhruvachak wrote:

typo: indicates to not this array
please rephrase ^^


https://github.com/llvm/llvm-project/pull/110001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [OpenMP][Clang] Migrate OpenMP UserDefinedMapper from Clang to OMPIRBuilder (PR #110001)

2024-10-08 Thread Dhruva Chakrabarti via cfe-commits


@@ -2801,6 +2801,67 @@ class OpenMPIRBuilder {
   using GenMapInfoCallbackTy =
   function_ref;
 
+private:
+  /// Emit the array initialization or deletion portion for user-defined mapper
+  /// code generation. First, it evaluates whether an array section is mapped
+  /// and whether the \a MapType instructs to delete this section. If \a IsInit
+  /// is true, and \a MapType indicates to not delete this array, array
+  /// initialization code is generated. If \a IsInit is false, and \a MapType
+  /// indicates to not this array, array deletion code is generated.
+  void emitUDMapperArrayInitOrDel(Function *MapperFn, llvm::Value *Handle,

dhruvachak wrote:

Document Handle, e.g. add a \param for it.

https://github.com/llvm/llvm-project/pull/110001
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][AMDGPU] Stop defaulting to `one-as` for all atomic scopes (PR #120095)

2024-12-16 Thread Dhruva Chakrabarti via cfe-commits


@@ -537,7 +537,11 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const 
LangOptions &LangOpts,
 break;
   }
 
-  if (Ordering != llvm::AtomicOrdering::SequentiallyConsistent) {
+  // OpenCL assumes by default that atomic scopes are per-address space for
+  // non-sequentially consistent operations.
+  if (Scope >= SyncScope::OpenCLWorkGroup &&

dhruvachak wrote:

Can you explain which scopes will generate the one-as versions with this 
change? I don't know which ones are in that range: agent, workgroup, wavefront, 
singlethread are the possible candidates. 

I also don't understand why the one-as should be generated for a specific range 
of scopes. How do we know that will not lead to mis-compilation?

https://github.com/llvm/llvm-project/pull/120095
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][AMDGPU] Stop defaulting to `one-as` for all atomic scopes (PR #120095)

2024-12-16 Thread Dhruva Chakrabarti via cfe-commits


@@ -537,7 +537,11 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const 
LangOptions &LangOpts,
 break;
   }
 
-  if (Ordering != llvm::AtomicOrdering::SequentiallyConsistent) {
+  // OpenCL assumes by default that atomic scopes are per-address space for
+  // non-sequentially consistent operations.
+  if (Scope >= SyncScope::OpenCLWorkGroup &&

dhruvachak wrote:

Ok, so here's the enum. 

enum class SyncScope {
  SystemScope,
  DeviceScope,
  WorkgroupScope,
  WavefrontScope,
  SingleScope,
  HIPSingleThread,
  HIPWavefront,
  HIPWorkgroup,
  HIPAgent,
  HIPSystem,
  OpenCLWorkGroup,
  OpenCLDevice,
  OpenCLAllSVMDevices,
  OpenCLSubGroup,
  Last = OpenCLSubGroup
};

So like you said, the OpenCL ones. If Matt agrees, I am fine with this change 
though I don't see how it is better than explicitly checking for OpenCL. Just 
more cryptic. Either way, please add a comment.

https://github.com/llvm/llvm-project/pull/120095
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][AMDGPU] Stop defaulting to `one-as` for all atomic scopes (PR #120095)

2024-12-16 Thread Dhruva Chakrabarti via cfe-commits

https://github.com/dhruvachak edited 
https://github.com/llvm/llvm-project/pull/120095
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][AMDGPU] Stop defaulting to `one-as` for all atomic scopes (PR #120095)

2024-12-16 Thread Dhruva Chakrabarti via cfe-commits


@@ -537,7 +537,11 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(const 
LangOptions &LangOpts,
 break;
   }
 
-  if (Ordering != llvm::AtomicOrdering::SequentiallyConsistent) {
+  // OpenCL assumes by default that atomic scopes are per-address space for
+  // non-sequentially consistent operations.
+  if (Scope >= SyncScope::OpenCLWorkGroup &&

dhruvachak wrote:

> There's already a comment though?

oh, ok, I see the comment now. Somehow missed it earlier.

https://github.com/llvm/llvm-project/pull/120095
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits