diff --git a/profiling/all/impl/Kokkos_Profiling_C_Interface.h b/profiling/all/impl/Kokkos_Profiling_C_Interface.h index c4aa9cce3..8c3194e43 100644 --- a/profiling/all/impl/Kokkos_Profiling_C_Interface.h +++ b/profiling/all/impl/Kokkos_Profiling_C_Interface.h @@ -1,3 +1,4 @@ +/* //@HEADER // ************************************************************************ // @@ -9,10 +10,11 @@ // the U.S. Government retains certain rights in this software. // // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. -// See https://kokkos.org/LICENSE for license information. +// // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER +*/ #ifndef KOKKOS_PROFILING_C_INTERFACE_HPP #define KOKKOS_PROFILING_C_INTERFACE_HPP @@ -26,10 +28,14 @@ #include #endif -#define KOKKOSP_INTERFACE_VERSION 20210623 +#define KOKKOSP_INTERFACE_VERSION 20211015 // Profiling +#ifdef __cplusplus +extern "C" { +#endif + struct Kokkos_Profiling_KokkosPDeviceInfo { size_t deviceID; }; @@ -265,4 +271,8 @@ struct Kokkos_Profiling_EventSet { // changing struct layout }; +#ifdef __cplusplus +} +#endif + #endif // KOKKOS_PROFILING_C_INTERFACE_HPP diff --git a/profiling/all/impl/Kokkos_Profiling_Interface.hpp b/profiling/all/impl/Kokkos_Profiling_Interface.hpp index 82ba15d19..b66886d9f 100644 --- a/profiling/all/impl/Kokkos_Profiling_Interface.hpp +++ b/profiling/all/impl/Kokkos_Profiling_Interface.hpp @@ -19,6 +19,7 @@ #include #include +#include #include @@ -45,6 +46,7 @@ enum struct DeviceType { HPX, Threads, SYCL, + OpenACC, Unknown }; @@ -53,6 +55,12 @@ struct ExecutionSpaceIdentifier { uint32_t device_id; uint32_t instance_id; }; + +constexpr const uint32_t num_type_bits = 8; +constexpr const uint32_t num_device_bits = 7; +constexpr const uint32_t num_instance_bits = 17; +constexpr const uint32_t num_avail_bits = sizeof(uint32_t) * CHAR_BIT; + inline DeviceType devicetype_from_uint32t(const uint32_t in) { switch (in) { case 0: return DeviceType::Serial; @@ -63,37 +71,35 @@ inline DeviceType devicetype_from_uint32t(const uint32_t in) { case 5: return DeviceType::HPX; case 6: return DeviceType::Threads; case 7: return DeviceType::SYCL; + case 8: return DeviceType::OpenACC; default: return DeviceType::Unknown; // TODO: error out? } } inline ExecutionSpaceIdentifier identifier_from_devid(const uint32_t in) { - // ExecutionSpaceIdentifier out; - // out.type = in >> 24; - // out.device_id = in >> 17; - // out.instance_id = ((uint32_t(-1)) << 17 ) & in; - return {devicetype_from_uint32t(in >> 24), - (~((uint32_t(-1)) << 24)) & (in >> 17), - (~((uint32_t(-1)) << 17)) & in}; + constexpr const uint32_t shift = num_avail_bits - num_type_bits; + + return {devicetype_from_uint32t(in >> shift), /*First 8 bits*/ + (~((uint32_t(-1)) << num_device_bits)) & + (in >> num_instance_bits), /*Next 7 bits */ + (~((uint32_t(-1)) << num_instance_bits)) & in}; /*Last 17 bits*/ } template struct DeviceTypeTraits; -constexpr const size_t device_type_bits = 8; -constexpr const size_t instance_bits = 24; template constexpr uint32_t device_id_root() { - /** uncomment when C++14 is enabled constexpr auto device_id = static_cast(DeviceTypeTraits::id); - return (device_id << instance_bits); - */ - return 0; + return (device_id << (num_instance_bits + num_device_bits)); } template inline uint32_t device_id(ExecutionSpace const& space) noexcept { - return device_id_root() + space.impl_instance_id(); + return device_id_root() + + (DeviceTypeTraits::device_id(space) + << num_instance_bits) + + space.impl_instance_id(); } } // namespace Experimental } // namespace Tools