[Openmp-commits] [openmp] a733bbb - [libomptarget][amdgpu][nfc] Refactor #includes

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Wed Jul 21 09:28:24 PDT 2021


Author: Jon Chesterfield
Date: 2021-07-21T17:28:07+01:00
New Revision: a733bbbd17129aff930ae27ac5c83707308d88c1

URL: https://github.com/llvm/llvm-project/commit/a733bbbd17129aff930ae27ac5c83707308d88c1
DIFF: https://github.com/llvm/llvm-project/commit/a733bbbd17129aff930ae27ac5c83707308d88c1.diff

LOG: [libomptarget][amdgpu][nfc] Refactor #includes

Create a hsa_api.h header that includes the ROCr headers in use
Drop some unused headers and _cplusplus macros

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D106455

Added: 
    openmp/libomptarget/plugins/amdgpu/impl/hsa_api.h

Modified: 
    openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
    openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.h
    openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
    openmp/libomptarget/plugins/amdgpu/impl/data.cpp
    openmp/libomptarget/plugins/amdgpu/impl/internal.h
    openmp/libomptarget/plugins/amdgpu/impl/machine.cpp
    openmp/libomptarget/plugins/amdgpu/impl/machine.h
    openmp/libomptarget/plugins/amdgpu/impl/rt.h
    openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
index 32dd7ea8b913f..46f80f9ebecde 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
@@ -4,10 +4,9 @@
  * This file is distributed under the MIT License. See LICENSE.txt for details.
  *===------------------------------------------------------------------------*/
 #include "atmi_runtime.h"
+#include "hsa_api.h"
 #include "internal.h"
 #include "rt.h"
-#include <hsa.h>
-#include <hsa_ext_amd.h>
 #include <memory>
 
 /*

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.h b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.h
index b656f7664fcf0..834597b52e286 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.h
@@ -7,16 +7,14 @@
 #define INCLUDE_ATMI_INTEROP_HSA_H_
 
 #include "atmi_runtime.h"
-#include "hsa.h"
-#include "hsa_ext_amd.h"
+#include "hsa_api.h"
 #include "internal.h"
 
 #include <map>
 #include <string>
 
-#ifdef __cplusplus
 extern "C" {
-#endif
+
 /** \defgroup interop_hsa_functions ATMI-HSA Interop
  *  @{
  */
@@ -80,8 +78,6 @@ hsa_status_t atmi_interop_hsa_get_kernel_info(
 
 /** @} */
 
-#ifdef __cplusplus
 }
-#endif
 
 #endif // INCLUDE_ATMI_INTEROP_HSA_H_

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h b/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
index 1d7dee118628e..b0aae5876a137 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
@@ -7,16 +7,9 @@
 #define INCLUDE_ATMI_RUNTIME_H_
 
 #include "atmi.h"
-#include "hsa.h"
-#include <inttypes.h>
-#include <stdlib.h>
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif
+#include "hsa_api.h"
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 /** \defgroup module_functions ATMI Module
  * @{
@@ -68,8 +61,6 @@ hsa_status_t atmi_memcpy_d2h(hsa_signal_t sig, void *hostDest,
 
 /** @} */
 
-#ifdef __cplusplus
 }
-#endif
 
 #endif // INCLUDE_ATMI_RUNTIME_H_

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp
index e3bb6bbec747e..ad30cbfa61a17 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/data.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/data.cpp
@@ -4,15 +4,13 @@
  * This file is distributed under the MIT License. See LICENSE.txt for details.
  *===------------------------------------------------------------------------*/
 #include "atmi_runtime.h"
+#include "hsa_api.h"
 #include "internal.h"
 #include "machine.h"
 #include "rt.h"
 #include <cassert>
-#include <hsa.h>
-#include <hsa_ext_amd.h>
 #include <stdio.h>
 #include <string.h>
-#include <thread>
 #include <vector>
 
 using core::TaskImpl;

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/hsa_api.h b/openmp/libomptarget/plugins/amdgpu/impl/hsa_api.h
new file mode 100644
index 0000000000000..b956c57cc85d9
--- /dev/null
+++ b/openmp/libomptarget/plugins/amdgpu/impl/hsa_api.h
@@ -0,0 +1,14 @@
+//===------- hsa_api.h --------------------------------------- C++ --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef AMDGPU_HSA_API_H_INCLUDED
+#define AMDGPU_HSA_API_H_INCLUDED
+
+#include "hsa.h"
+#include "hsa_ext_amd.h"
+
+#endif

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/internal.h b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
index 268d81210520b..21f0cc15ad7cb 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/internal.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/internal.h
@@ -12,18 +12,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <atomic>
 #include <cstring>
-#include <deque>
 #include <map>
 #include <queue>
 #include <string>
 #include <utility>
 #include <vector>
 
-#include "hsa.h"
-#include "hsa_ext_amd.h"
-#include "hsa_ext_finalize.h"
+#include "hsa_api.h"
 
 #include "atmi.h"
 #include "atmi_runtime.h"
@@ -44,9 +40,7 @@ typedef struct atmi_implicit_args_s {
   unsigned long kernarg_template_ptr;
 } atmi_implicit_args_t;
 
-#ifdef __cplusplus
 extern "C" {
-#endif
 
 #ifdef DEBUG
 #define DEBUG_PRINT(fmt, ...)                                                  \
@@ -65,9 +59,7 @@ typedef struct hsa_signal_s {
 } hsa_signal_t;
 #endif
 
-#ifdef __cplusplus
 }
-#endif
 
 /* ---------------------------------------------------------------------------------
  * Simulated CPU Data Structures and API

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/machine.cpp b/openmp/libomptarget/plugins/amdgpu/impl/machine.cpp
index fecd954a02eb4..84645a21a747f 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/machine.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/machine.cpp
@@ -5,10 +5,9 @@
  *===------------------------------------------------------------------------*/
 #include "machine.h"
 #include "atmi_runtime.h"
+#include "hsa_api.h"
 #include "internal.h"
 #include <cassert>
-#include <hsa.h>
-#include <hsa_ext_amd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <vector>

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/machine.h b/openmp/libomptarget/plugins/amdgpu/impl/machine.h
index fc4a95b3c0f66..c8120e31367e3 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/machine.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/machine.h
@@ -6,9 +6,8 @@
 #ifndef SRC_RUNTIME_INCLUDE_MACHINE_H_
 #define SRC_RUNTIME_INCLUDE_MACHINE_H_
 #include "atmi.h"
+#include "hsa_api.h"
 #include "internal.h"
-#include <hsa.h>
-#include <hsa_ext_amd.h>
 #include <vector>
 
 class ATLMemory;

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/rt.h b/openmp/libomptarget/plugins/amdgpu/impl/rt.h
index d09eabf5a61d8..d8aa45977b526 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/rt.h
+++ b/openmp/libomptarget/plugins/amdgpu/impl/rt.h
@@ -7,7 +7,7 @@
 #define SRC_RUNTIME_INCLUDE_RT_H_
 
 #include "atmi_runtime.h"
-#include "hsa.h"
+#include "hsa_api.h"
 #include <string>
 
 namespace core {

diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index 2c8d860a63ca3..21901365b7714 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -24,7 +24,6 @@
 #include <memory>
 #include <mutex>
 #include <shared_mutex>
-#include <thread>
 #include <unordered_map>
 #include <vector>
 


        


More information about the Openmp-commits mailing list