[llvm] [OFFLOAD] Remove weak from __kmpc_* calls and gather them in one header (PR #164613)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 22 05:30:48 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Alex Duran (adurang)
<details>
<summary>Changes</summary>
Continuation from #<!-- -->162652
---
Full diff: https://github.com/llvm/llvm-project/pull/164613.diff
4 Files Affected:
- (modified) offload/include/OffloadPolicy.h (-1)
- (modified) offload/include/OpenMP/InternalTypes.h (+24-6)
- (modified) offload/libomptarget/OpenMP/API.cpp (-23)
- (modified) offload/libomptarget/OpenMP/InteropAPI.cpp (-8)
``````````diff
diff --git a/offload/include/OffloadPolicy.h b/offload/include/OffloadPolicy.h
index 800fefb224326..6656e2dd9b595 100644
--- a/offload/include/OffloadPolicy.h
+++ b/offload/include/OffloadPolicy.h
@@ -22,7 +22,6 @@ enum kmp_target_offload_kind_t {
tgt_mandatory = 2
};
-extern "C" int __kmpc_get_target_offload(void) __attribute__((weak));
class OffloadPolicy {
diff --git a/offload/include/OpenMP/InternalTypes.h b/offload/include/OpenMP/InternalTypes.h
index bd84c38fb2011..ce339f3f5358b 100644
--- a/offload/include/OpenMP/InternalTypes.h
+++ b/offload/include/OpenMP/InternalTypes.h
@@ -70,10 +70,28 @@ typedef struct kmp_task {
int32_t part_id;
} kmp_task_t;
-int32_t __kmpc_global_thread_num(void *) __attribute__((weak));
-bool __kmpc_omp_has_task_team(int32_t gtid) __attribute__((weak));
-void **__kmpc_omp_get_target_async_handle_ptr(int32_t gtid)
- __attribute__((weak));
+// Implemented in libomp, they are called from within __tgt_* functions.
+int32_t __kmpc_global_thread_num(void *);
+bool __kmpc_omp_has_task_team(int32_t gtid);
+void **__kmpc_omp_get_target_async_handle_ptr(int32_t gtid);
+int __kmpc_get_target_offload(void);
+int __kmpc_get_target_offload(void);
+kmp_task_t *__kmpc_omp_task_alloc(ident_t *loc_ref, int32_t gtid, int32_t flags,
+ size_t sizeof_kmp_task_t,
+ size_t sizeof_shareds,
+ kmp_routine_entry_t task_entry);
+kmp_task_t *
+__kmpc_omp_target_task_alloc(ident_t *loc_ref, int32_t gtid, int32_t flags,
+ size_t sizeof_kmp_task_t, size_t sizeof_shareds,
+ kmp_routine_entry_t task_entry, int64_t device_id);
+int32_t __kmpc_omp_task_with_deps(ident_t *loc_ref, int32_t gtid,
+ kmp_task_t *new_task, int32_t ndeps,
+ kmp_depend_info_t *dep_list,
+ int32_t ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list);
+void __kmpc_omp_wait_deps(ident_t *loc_ref, int32_t gtid, int32_t ndeps,
+ kmp_depend_info_t *dep_list, int32_t ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list);
/**
* The argument set that is passed from asynchronous memory copy to block
@@ -120,7 +138,7 @@ struct TargetMemcpyArgsTy {
: Dst(Dst), Src(Src), DstDevice(DstDevice), SrcDevice(SrcDevice),
IsRectMemcpy(false), Length(Length), DstOffset(DstOffset),
SrcOffset(SrcOffset), ElementSize(0), NumDims(0), Volume(0),
- DstOffsets(0), SrcOffsets(0), DstDimensions(0), SrcDimensions(0){};
+ DstOffsets(0), SrcOffsets(0), DstDimensions(0), SrcDimensions(0) {};
/**
* Constructor for rectangle dimensional copy
@@ -134,7 +152,7 @@ struct TargetMemcpyArgsTy {
IsRectMemcpy(true), Length(0), DstOffset(0), SrcOffset(0),
ElementSize(ElementSize), NumDims(NumDims), Volume(Volume),
DstOffsets(DstOffsets), SrcOffsets(SrcOffsets),
- DstDimensions(DstDimensions), SrcDimensions(SrcDimensions){};
+ DstDimensions(DstDimensions), SrcDimensions(SrcDimensions) {};
};
struct TargetMemsetArgsTy {
diff --git a/offload/libomptarget/OpenMP/API.cpp b/offload/libomptarget/OpenMP/API.cpp
index b0f0573833713..941d2a7d74c50 100644
--- a/offload/libomptarget/OpenMP/API.cpp
+++ b/offload/libomptarget/OpenMP/API.cpp
@@ -48,29 +48,6 @@ void *targetLockExplicit(void *HostPtr, size_t Size, int DeviceNum,
const char *Name);
void targetUnlockExplicit(void *HostPtr, int DeviceNum, const char *Name);
-// Implemented in libomp, they are called from within __tgt_* functions.
-extern "C" {
-int __kmpc_get_target_offload(void) __attribute__((weak));
-kmp_task_t *__kmpc_omp_task_alloc(ident_t *loc_ref, int32_t gtid, int32_t flags,
- size_t sizeof_kmp_task_t,
- size_t sizeof_shareds,
- kmp_routine_entry_t task_entry)
- __attribute__((weak));
-
-kmp_task_t *
-__kmpc_omp_target_task_alloc(ident_t *loc_ref, int32_t gtid, int32_t flags,
- size_t sizeof_kmp_task_t, size_t sizeof_shareds,
- kmp_routine_entry_t task_entry, int64_t device_id)
- __attribute__((weak));
-
-int32_t __kmpc_omp_task_with_deps(ident_t *loc_ref, int32_t gtid,
- kmp_task_t *new_task, int32_t ndeps,
- kmp_depend_info_t *dep_list,
- int32_t ndeps_noalias,
- kmp_depend_info_t *noalias_dep_list)
- __attribute__((weak));
-}
-
EXTERN int omp_get_num_devices(void) {
TIMESCOPE();
OMPT_IF_BUILT(ReturnAddressSetterRAII RA(__builtin_return_address(0)));
diff --git a/offload/libomptarget/OpenMP/InteropAPI.cpp b/offload/libomptarget/OpenMP/InteropAPI.cpp
index d6ef17c06355c..b307011445170 100644
--- a/offload/libomptarget/OpenMP/InteropAPI.cpp
+++ b/offload/libomptarget/OpenMP/InteropAPI.cpp
@@ -18,14 +18,6 @@
#include <cstdlib>
#include <cstring>
-extern "C" {
-
-void __kmpc_omp_wait_deps(ident_t *loc_ref, int32_t gtid, int32_t ndeps,
- kmp_depend_info_t *dep_list, int32_t ndeps_noalias,
- kmp_depend_info_t *noalias_dep_list);
-
-} // extern "C"
-
namespace {
omp_interop_rc_t getPropertyErrorType(omp_interop_property_t Property) {
switch (Property) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/164613
More information about the llvm-commits
mailing list