[clang] [OpenMP] Introduce -fopenmp-force-usm flag (PR #75468)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 05:57:19 PST 2023


================
@@ -129,6 +129,22 @@ AMDGPUOpenMPToolChain::GetCXXStdlibType(const ArgList &Args) const {
 void AMDGPUOpenMPToolChain::AddClangSystemIncludeArgs(
     const ArgList &DriverArgs, ArgStringList &CC1Args) const {
   HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
+
+  CC1Args.push_back("-internal-isystem");
+  SmallString<128> P(HostTC.getDriver().ResourceDir);
+  llvm::sys::path::append(P, "include/cuda_wrappers");
+  CC1Args.push_back(DriverArgs.MakeArgString(P));
+
+  // Force USM mode will forcefully include #pragma omp requires
+  // unified_shared_memory via the force_usm header
+  // XXX This may result in a compilation error if the source
+  // file already includes that pragma.
+  if (DriverArgs.hasArg(options::OPT_fopenmp_force_usm)) {
+    CC1Args.push_back("-include");
+    CC1Args.push_back(
+        DriverArgs.MakeArgString(HostTC.getDriver().ResourceDir +
+                                 "/include/openmp_wrappers/force_usm.h"));
----------------
jhuber6 wrote:

I don't think this is a good way to handle this. We should make this a CC1 argument, forward it in the standard way, and make `CGOpenMPRuntime` always emit the associated runtime call.

Also note that I'm planning on removing the current "requires" handling because emitting spurious global constructors into the runtime is difficult to work around.

https://github.com/llvm/llvm-project/pull/75468


More information about the cfe-commits mailing list