[Openmp-commits] [PATCH] D77071: [libomptarget][nfc] Move non-freestanding headers out of common

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 30 09:44:21 PDT 2020


JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, ABataev, grokos.
Herald added subscribers: openmp-commits, jvesely.
Herald added a project: OpenMP.
JonChesterfield marked an inline comment as done.
JonChesterfield added inline comments.


================
Comment at: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h:21
 
+#include <assert.h>
+#include <inttypes.h>
----------------
No stdio in amdgcn's target_impl as the only function used from it is printf, declared at the end of this header.

Can reduce amdgcn to wholly ffreestanding by providing an implementation of assert and two macros from inttypes, which may be a good idea as I think HIP is currently using the glibc versions of these headers for the device code.


[libomptarget][nfc] Move non-freestanding headers out of common

Lowers the bar for building deviceRTL.
Drops math.h entirely as it wasn't used and libm is a big dependency.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77071

Files:
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/debug.h
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h


Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h
@@ -12,7 +12,10 @@
 #ifndef _TARGET_IMPL_H_
 #define _TARGET_IMPL_H_
 
+#include <assert.h>
 #include <cuda.h>
+#include <inttypes.h>
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "nvptx_interface.h"
Index: openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
===================================================================
--- openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
+++ openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
@@ -11,7 +11,6 @@
 //===----------------------------------------------------------------------===//
 #include "common/omptarget.h"
 #include "target_impl.h"
-#include <stdio.h>
 
 // Return true if this is the master thread.
 INLINE static bool IsMasterThread(bool isSPMDExecutionMode) {
Index: openmp/libomptarget/deviceRTLs/common/omptarget.h
===================================================================
--- openmp/libomptarget/deviceRTLs/common/omptarget.h
+++ openmp/libomptarget/deviceRTLs/common/omptarget.h
@@ -14,11 +14,6 @@
 #ifndef OMPTARGET_H
 #define OMPTARGET_H
 
-// std includes
-#include <inttypes.h>
-#include <math.h>
-
-// local includes
 #include "target_impl.h"
 #include "common/debug.h"     // debug
 #include "interface.h" // interfaces with omp, compiler, and user
Index: openmp/libomptarget/deviceRTLs/common/debug.h
===================================================================
--- openmp/libomptarget/deviceRTLs/common/debug.h
+++ openmp/libomptarget/deviceRTLs/common/debug.h
@@ -127,7 +127,6 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 #if OMPTARGET_NVPTX_DEBUG || OMPTARGET_NVPTX_TEST || OMPTARGET_NVPTX_WARNING
-#include <stdio.h>
 #include "common/support.h"
 
 template <typename... Arguments>
@@ -138,7 +137,6 @@
 
 #endif
 #if OMPTARGET_NVPTX_TEST
-#include <assert.h>
 
 template <typename... Arguments>
 NOINLINE static void check(bool cond, const char *fmt,
Index: openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
===================================================================
--- openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
+++ openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
@@ -18,6 +18,8 @@
 
 #include "amdgcn_interface.h"
 
+#include <assert.h>
+#include <inttypes.h>
 #include <stddef.h>
 #include <stdint.h>
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77071.253616.patch
Type: text/x-patch
Size: 2558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200330/af53b85c/attachment-0001.bin>


More information about the Openmp-commits mailing list