From c9f323aa94f6865ff4b491f5008a346d2d329df3 Mon Sep 17 00:00:00 2001 From: Brice Videau Date: Fri, 4 Oct 2024 15:21:57 -0500 Subject: [PATCH] Update Kokkos profiling headers to version 4.4.01. --- .../impl/Kokkos_Profiling_C_Interface.h | 52 +++++------ .../impl/Kokkos_Profiling_DeviceInfo.hpp | 56 +++--------- .../impl/Kokkos_Profiling_Interface.hpp | 89 ++++++++----------- 3 files changed, 72 insertions(+), 125 deletions(-) diff --git a/connectors/kokkos/include/impl/Kokkos_Profiling_C_Interface.h b/connectors/kokkos/include/impl/Kokkos_Profiling_C_Interface.h index 277c1fb3..8c3194e4 100644 --- a/connectors/kokkos/include/impl/Kokkos_Profiling_C_Interface.h +++ b/connectors/kokkos/include/impl/Kokkos_Profiling_C_Interface.h @@ -1,33 +1,19 @@ /* - //@HEADER - // ************************************************************************ - // - // Kokkos v. 3.0 -// Copyright (2020) National Technology & Engineering +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). - // - // Under the terms of Contract DE-NA0003525 with NTESS, - // the U.S. Government retains certain rights in this software. - // -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. +// +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - // Questions? Contact Christian R. Trott (crtrott@sandia.gov) -// @HEADER +//@HEADER */ #ifndef KOKKOS_PROFILING_C_INTERFACE_HPP @@ -42,10 +28,14 @@ #include #endif -#define KOKKOSP_INTERFACE_VERSION 20210225 +#define KOKKOSP_INTERFACE_VERSION 20211015 // Profiling +#ifdef __cplusplus +extern "C" { +#endif + struct Kokkos_Profiling_KokkosPDeviceInfo { size_t deviceID; }; @@ -168,7 +158,7 @@ enum Kokkos_Tools_OptimizationType { Kokkos_Tools_Maximize }; -struct Kokkos_Tools_OptimzationGoal { +struct Kokkos_Tools_OptimizationGoal { size_t type_id; enum Kokkos_Tools_OptimizationType goal; }; @@ -234,7 +224,7 @@ typedef void (*Kokkos_Tools_contextBeginFunction)(const size_t); typedef void (*Kokkos_Tools_contextEndFunction)( const size_t, struct Kokkos_Tools_VariableValue); typedef void (*Kokkos_Tools_optimizationGoalDeclarationFunction)( - const size_t, const struct Kokkos_Tools_OptimzationGoal goal); + const size_t, const struct Kokkos_Tools_OptimizationGoal goal); struct Kokkos_Profiling_EventSet { Kokkos_Profiling_initFunction init; @@ -281,4 +271,8 @@ struct Kokkos_Profiling_EventSet { // changing struct layout }; +#ifdef __cplusplus +} +#endif + #endif // KOKKOS_PROFILING_C_INTERFACE_HPP diff --git a/connectors/kokkos/include/impl/Kokkos_Profiling_DeviceInfo.hpp b/connectors/kokkos/include/impl/Kokkos_Profiling_DeviceInfo.hpp index be6f756d..1db44815 100644 --- a/connectors/kokkos/include/impl/Kokkos_Profiling_DeviceInfo.hpp +++ b/connectors/kokkos/include/impl/Kokkos_Profiling_DeviceInfo.hpp @@ -1,46 +1,18 @@ -/* - //@HEADER - // ************************************************************************ - // - // Kokkos v. 3.0 -// Copyright (2020) National Technology & Engineering +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). - // - // Under the terms of Contract DE-NA0003525 with NTESS, - // the U.S. Government retains certain rights in this software. - // - // Redistribution and use in source and binary forms, with or without - // modification, are permitted provided that the following conditions are - // met: - // - // 1. Redistributions of source code must retain the above copyright - // notice, this list of conditions and the following disclaimer. - // - // 2. Redistributions in binary form must reproduce the above copyright - // notice, this list of conditions and the following disclaimer in the - // documentation and/or other materials provided with the distribution. - // - // 3. Neither the name of the Corporation nor the names of the - // contributors may be used to endorse or promote products derived from - // this software without specific prior written permission. - // - // THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY - // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE - // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // - // Questions? Contact Christian R. Trott (crtrott@sandia.gov) - // - // ************************************************************************ - //@HEADER -*/ +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// 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 KOKKOSP_DEVICE_INFO_HPP #define KOKKOSP_DEVICE_INFO_HPP diff --git a/connectors/kokkos/include/impl/Kokkos_Profiling_Interface.hpp b/connectors/kokkos/include/impl/Kokkos_Profiling_Interface.hpp index a7aec2e6..b66886d9 100644 --- a/connectors/kokkos/include/impl/Kokkos_Profiling_Interface.hpp +++ b/connectors/kokkos/include/impl/Kokkos_Profiling_Interface.hpp @@ -1,52 +1,25 @@ -/* - //@HEADER - // ************************************************************************ - // - // Kokkos v. 3.0 -// Copyright (2020) National Technology & Engineering +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). - // - // Under the terms of Contract DE-NA0003525 with NTESS, - // the U.S. Government retains certain rights in this software. - // - // Redistribution and use in source and binary forms, with or without - // modification, are permitted provided that the following conditions are - // met: - // - // 1. Redistributions of source code must retain the above copyright - // notice, this list of conditions and the following disclaimer. - // - // 2. Redistributions in binary form must reproduce the above copyright - // notice, this list of conditions and the following disclaimer in the - // documentation and/or other materials provided with the distribution. - // - // 3. Neither the name of the Corporation nor the names of the - // contributors may be used to endorse or promote products derived from - // this software without specific prior written permission. - // - // THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY - // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE - // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // - // Questions? Contact Christian R. Trott (crtrott@sandia.gov) - // - // ************************************************************************ - //@HEADER - */ +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// 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 KOKKOSP_INTERFACE_HPP #define KOKKOSP_INTERFACE_HPP #include #include +#include #include @@ -73,6 +46,7 @@ enum struct DeviceType { HPX, Threads, SYCL, + OpenACC, Unknown }; @@ -81,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; @@ -91,34 +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() { constexpr auto device_id = static_cast(DeviceTypeTraits::id); - return (device_id << instance_bits); + 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 @@ -245,7 +226,7 @@ using ValueType = Kokkos_Tools_VariableInfo_ValueType; using CandidateValueType = Kokkos_Tools_VariableInfo_CandidateValueType; using SetOrRange = Kokkos_Tools_VariableInfo_SetOrRange; using VariableInfo = Kokkos_Tools_VariableInfo; -using OptimizationGoal = Kokkos_Tools_OptimzationGoal; +using OptimizationGoal = Kokkos_Tools_OptimizationGoal; using TuningString = Kokkos_Tools_Tuning_String; using VariableValue = Kokkos_Tools_VariableValue;