From b92dbb4b0aa97356c55b1fcb7eaddaba531ca71f Mon Sep 17 00:00:00 2001 From: George Rokos Date: Tue, 21 Nov 2017 18:26:41 +0000 Subject: [PATCH] [Clang][OpenMP] New clang/libomptarget map interface: new function signatures, libomptarget-side This is the libomptarget-side patch which changes the __tgt_* API function signatures in preparation for the new map interface. Changes are: Device IDs 32bits --> 64bits, Flags 32bits --> 64bits Differential revision: https://reviews.llvm.org/D40313 llvm-svn: 318790 --- openmp/libomptarget/src/omptarget.cpp | 72 +++++++++++++++++------------------ openmp/libomptarget/src/omptarget.h | 42 ++++++++++---------- 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp index ca1d41a..87680e9 100644 --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -52,7 +52,7 @@ static const char *RTLNames[] = { // forward declarations struct RTLInfoTy; -static int target(int32_t device_id, void *host_ptr, int32_t arg_num, +static int target(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, int32_t team_num, int32_t thread_limit, int IsTeamConstruct); @@ -1446,7 +1446,7 @@ struct combined_entry_t { }; static void translate_map(int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, int32_t &new_arg_num, + int64_t *arg_sizes, int64_t *arg_types, int32_t &new_arg_num, void **&new_args_base, void **&new_args, int64_t *&new_arg_sizes, int64_t *&new_arg_types, bool is_target_construct) { if (arg_num <= 0) { @@ -1465,7 +1465,7 @@ static void translate_map(int32_t arg_num, void **args_base, void **args, // old entry is member of member_of[old] cmb_entry int *member_of = (int *) alloca(arg_num * sizeof(int)); // temporary storage for modifications of the original arg_types - int32_t *mod_arg_types = (int32_t *) alloca(arg_num *sizeof(int32_t)); + int64_t *mod_arg_types = (int64_t *) alloca(arg_num *sizeof(int64_t)); DP("Translating %d map entries\n", arg_num); for (int i = 0; i < arg_num; ++i) { @@ -1754,8 +1754,8 @@ static int target_data_begin(DeviceTy &Device, int32_t arg_num, return rc; } -EXTERN void __tgt_target_data_begin_nowait(int32_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types, +EXTERN void __tgt_target_data_begin_nowait(int64_t device_id, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { if (depNum + noAliasDepNum > 0) @@ -1768,19 +1768,19 @@ EXTERN void __tgt_target_data_begin_nowait(int32_t device_id, int32_t arg_num, /// creates host-to-target data mapping, stores it in the /// libomptarget.so internal structure (an entry in a stack of data maps) /// and passes the data to the device. -EXTERN void __tgt_target_data_begin(int32_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types) { - DP("Entering data begin region for device %d with %d mappings\n", device_id, +EXTERN void __tgt_target_data_begin(int64_t device_id, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { + DP("Entering data begin region for device %ld with %d mappings\n", device_id, arg_num); // No devices available? if (device_id == OFFLOAD_DEVICE_DEFAULT) { device_id = omp_get_default_device(); - DP("Use default device id %d\n", device_id); + DP("Use default device id %ld\n", device_id); } if (CheckDevice(device_id) != OFFLOAD_SUCCESS) { - DP("Failed to get device %d ready\n", device_id); + DP("Failed to get device %ld ready\n", device_id); return; } @@ -1913,8 +1913,8 @@ static int target_data_end(DeviceTy &Device, int32_t arg_num, void **args_base, /// passes data from the target, releases target memory and destroys /// the host-target mapping (top entry from the stack of data maps) /// created by the last __tgt_target_data_begin. -EXTERN void __tgt_target_data_end(int32_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types) { +EXTERN void __tgt_target_data_end(int64_t device_id, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { DP("Entering data end region with %d mappings\n", arg_num); // No devices available? @@ -1926,7 +1926,7 @@ EXTERN void __tgt_target_data_end(int32_t device_id, int32_t arg_num, size_t Devices_size = Devices.size(); RTLsMtx.unlock(); if (Devices_size <= (size_t)device_id) { - DP("Device ID %d does not have a matching RTL.\n", device_id); + DP("Device ID %ld does not have a matching RTL.\n", device_id); return; } @@ -1954,8 +1954,8 @@ EXTERN void __tgt_target_data_end(int32_t device_id, int32_t arg_num, new_arg_types, arg_num, args_base); } -EXTERN void __tgt_target_data_end_nowait(int32_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types, +EXTERN void __tgt_target_data_end_nowait(int64_t device_id, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { if (depNum + noAliasDepNum > 0) @@ -1966,8 +1966,8 @@ EXTERN void __tgt_target_data_end_nowait(int32_t device_id, int32_t arg_num, } /// passes data to/from the target. -EXTERN void __tgt_target_data_update(int32_t device_id, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types) { +EXTERN void __tgt_target_data_update(int64_t device_id, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { DP("Entering data update with %d mappings\n", arg_num); // No devices available? @@ -1976,7 +1976,7 @@ EXTERN void __tgt_target_data_update(int32_t device_id, int32_t arg_num, } if (CheckDevice(device_id) != OFFLOAD_SUCCESS) { - DP("Failed to get device %d ready\n", device_id); + DP("Failed to get device %ld ready\n", device_id); return; } @@ -2044,8 +2044,8 @@ EXTERN void __tgt_target_data_update(int32_t device_id, int32_t arg_num, } EXTERN void __tgt_target_data_update_nowait( - int32_t device_id, int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, int32_t depNum, void *depList, + int64_t device_id, int32_t arg_num, void **args_base, void **args, + int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, 0); @@ -2060,7 +2060,7 @@ EXTERN void __tgt_target_data_update_nowait( /// performs the same action as data_update and data_end above. This function /// returns 0 if it was able to transfer the execution to a target and an /// integer different from zero otherwise. -static int target(int32_t device_id, void *host_ptr, int32_t arg_num, +static int target(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types, int32_t team_num, int32_t thread_limit, int IsTeamConstruct) { DeviceTy &Device = Devices[device_id]; @@ -2247,9 +2247,9 @@ static int target(int32_t device_id, void *host_ptr, int32_t arg_num, return rc; } -EXTERN int __tgt_target(int32_t device_id, void *host_ptr, int32_t arg_num, - void **args_base, void **args, int64_t *arg_sizes, int32_t *arg_types) { - DP("Entering target region with entry point " DPxMOD " and device Id %d\n", +EXTERN int __tgt_target(int64_t device_id, void *host_ptr, int32_t arg_num, + void **args_base, void **args, int64_t *arg_sizes, int64_t *arg_types) { + DP("Entering target region with entry point " DPxMOD " and device Id %ld\n", DPxPTR(host_ptr), device_id); if (device_id == OFFLOAD_DEVICE_DEFAULT) { @@ -2257,7 +2257,7 @@ EXTERN int __tgt_target(int32_t device_id, void *host_ptr, int32_t arg_num, } if (CheckDevice(device_id) != OFFLOAD_SUCCESS) { - DP("Failed to get device %d ready\n", device_id); + DP("Failed to get device %ld ready\n", device_id); return OFFLOAD_FAIL; } @@ -2282,9 +2282,9 @@ EXTERN int __tgt_target(int32_t device_id, void *host_ptr, int32_t arg_num, return rc; } -EXTERN int __tgt_target_nowait(int32_t device_id, void *host_ptr, +EXTERN int __tgt_target_nowait(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, + int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, 0); @@ -2293,10 +2293,10 @@ EXTERN int __tgt_target_nowait(int32_t device_id, void *host_ptr, arg_types); } -EXTERN int __tgt_target_teams(int32_t device_id, void *host_ptr, +EXTERN int __tgt_target_teams(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types, int32_t team_num, int32_t thread_limit) { - DP("Entering target region with entry point " DPxMOD " and device Id %d\n", + int64_t *arg_types, int32_t team_num, int32_t thread_limit) { + DP("Entering target region with entry point " DPxMOD " and device Id %ld\n", DPxPTR(host_ptr), device_id); if (device_id == OFFLOAD_DEVICE_DEFAULT) { @@ -2304,7 +2304,7 @@ EXTERN int __tgt_target_teams(int32_t device_id, void *host_ptr, } if (CheckDevice(device_id) != OFFLOAD_SUCCESS) { - DP("Failed to get device %d ready\n", device_id); + DP("Failed to get device %ld ready\n", device_id); return OFFLOAD_FAIL; } @@ -2330,9 +2330,9 @@ EXTERN int __tgt_target_teams(int32_t device_id, void *host_ptr, return rc; } -EXTERN int __tgt_target_teams_nowait(int32_t device_id, void *host_ptr, +EXTERN int __tgt_target_teams_nowait(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types, int32_t team_num, int32_t thread_limit, int32_t depNum, + int64_t *arg_types, int32_t team_num, int32_t thread_limit, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList) { if (depNum + noAliasDepNum > 0) __kmpc_omp_taskwait(NULL, 0); @@ -2343,18 +2343,18 @@ EXTERN int __tgt_target_teams_nowait(int32_t device_id, void *host_ptr, // The trip count mechanism will be revised - this scheme is not thread-safe. -EXTERN void __kmpc_push_target_tripcount(int32_t device_id, +EXTERN void __kmpc_push_target_tripcount(int64_t device_id, uint64_t loop_tripcount) { if (device_id == OFFLOAD_DEVICE_DEFAULT) { device_id = omp_get_default_device(); } if (CheckDevice(device_id) != OFFLOAD_SUCCESS) { - DP("Failed to get device %d ready\n", device_id); + DP("Failed to get device %ld ready\n", device_id); return; } - DP("__kmpc_push_target_tripcount(%d, %" PRIu64 ")\n", device_id, + DP("__kmpc_push_target_tripcount(%ld, %" PRIu64 ")\n", device_id, loop_tripcount); Devices[device_id].loopTripCnt = loop_tripcount; } diff --git a/openmp/libomptarget/src/omptarget.h b/openmp/libomptarget/src/omptarget.h index 1e464e8..556efa5 100644 --- a/openmp/libomptarget/src/omptarget.h +++ b/openmp/libomptarget/src/omptarget.h @@ -127,12 +127,12 @@ void __tgt_unregister_lib(__tgt_bin_desc *desc); // creates the host to target data mapping, stores it in the // libomptarget.so internal structure (an entry in a stack of data maps) and // passes the data to the device; -void __tgt_target_data_begin(int32_t device_id, int32_t arg_num, +void __tgt_target_data_begin(int64_t device_id, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types); -void __tgt_target_data_begin_nowait(int32_t device_id, int32_t arg_num, + int64_t *arg_types); +void __tgt_target_data_begin_nowait(int64_t device_id, int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, + int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList); @@ -140,21 +140,21 @@ void __tgt_target_data_begin_nowait(int32_t device_id, int32_t arg_num, // passes data from the target, release target memory and destroys the // host-target mapping (top entry from the stack of data maps) created by // the last __tgt_target_data_begin -void __tgt_target_data_end(int32_t device_id, int32_t arg_num, void **args_base, - void **args, int64_t *arg_sizes, int32_t *arg_types); -void __tgt_target_data_end_nowait(int32_t device_id, int32_t arg_num, +void __tgt_target_data_end(int64_t device_id, int32_t arg_num, void **args_base, + void **args, int64_t *arg_sizes, int64_t *arg_types); +void __tgt_target_data_end_nowait(int64_t device_id, int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, + int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList); /// passes data to/from the target -void __tgt_target_data_update(int32_t device_id, int32_t arg_num, +void __tgt_target_data_update(int64_t device_id, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types); -void __tgt_target_data_update_nowait(int32_t device_id, int32_t arg_num, + int64_t *arg_types); +void __tgt_target_data_update_nowait(int64_t device_id, int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, + int64_t *arg_sizes, int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList); @@ -165,25 +165,25 @@ void __tgt_target_data_update_nowait(int32_t device_id, int32_t arg_num, // same action as data_end above. The following types are used; this // function returns 0 if it was able to transfer the execution to a // target and an int different from zero otherwise. -int __tgt_target(int32_t device_id, void *host_ptr, int32_t arg_num, +int __tgt_target(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types); -int __tgt_target_nowait(int32_t device_id, void *host_ptr, int32_t arg_num, + int64_t *arg_types); +int __tgt_target_nowait(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types, int32_t depNum, void *depList, + int64_t *arg_types, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList); -int __tgt_target_teams(int32_t device_id, void *host_ptr, int32_t arg_num, +int __tgt_target_teams(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, int64_t *arg_sizes, - int32_t *arg_types, int32_t num_teams, + int64_t *arg_types, int32_t num_teams, int32_t thread_limit); -int __tgt_target_teams_nowait(int32_t device_id, void *host_ptr, +int __tgt_target_teams_nowait(int64_t device_id, void *host_ptr, int32_t arg_num, void **args_base, void **args, - int64_t *arg_sizes, int32_t *arg_types, + int64_t *arg_sizes, int64_t *arg_types, int32_t num_teams, int32_t thread_limit, int32_t depNum, void *depList, int32_t noAliasDepNum, void *noAliasDepList); -void __kmpc_push_target_tripcount(int32_t device_id, uint64_t loop_tripcount); +void __kmpc_push_target_tripcount(int64_t device_id, uint64_t loop_tripcount); #ifdef __cplusplus } -- 2.7.4