Skip to content

Commit

Permalink
Update Kokkos profiling headers to version 4.4.01.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Oct 4, 2024
1 parent 95a2756 commit c9f323a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 125 deletions.
52 changes: 23 additions & 29 deletions connectors/kokkos/include/impl/Kokkos_Profiling_C_Interface.h
Original file line number Diff line number Diff line change
@@ -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 ([email protected])
// @HEADER
//@HEADER
*/

#ifndef KOKKOS_PROFILING_C_INTERFACE_HPP
Expand All @@ -42,10 +28,14 @@
#include <stdbool.h>
#endif

#define KOKKOSP_INTERFACE_VERSION 20210225
#define KOKKOSP_INTERFACE_VERSION 20211015

// Profiling

#ifdef __cplusplus
extern "C" {
#endif

struct Kokkos_Profiling_KokkosPDeviceInfo {
size_t deviceID;
};
Expand Down Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -281,4 +271,8 @@ struct Kokkos_Profiling_EventSet {
// changing struct layout
};

#ifdef __cplusplus
}
#endif

#endif // KOKKOS_PROFILING_C_INTERFACE_HPP
56 changes: 14 additions & 42 deletions connectors/kokkos/include/impl/Kokkos_Profiling_DeviceInfo.hpp
Original file line number Diff line number Diff line change
@@ -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 ([email protected])
//
// ************************************************************************
//@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
Expand Down
89 changes: 35 additions & 54 deletions connectors/kokkos/include/impl/Kokkos_Profiling_Interface.hpp
Original file line number Diff line number Diff line change
@@ -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 ([email protected])
//
// ************************************************************************
//@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 <cinttypes>
#include <cstddef>
#include <climits>

#include <cstdlib>

Expand All @@ -73,6 +46,7 @@ enum struct DeviceType {
HPX,
Threads,
SYCL,
OpenACC,
Unknown
};

Expand All @@ -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;
Expand All @@ -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 <typename ExecutionSpace>
struct DeviceTypeTraits;

constexpr const size_t device_type_bits = 8;
constexpr const size_t instance_bits = 24;
template <typename ExecutionSpace>
constexpr uint32_t device_id_root() {
constexpr auto device_id =
static_cast<uint32_t>(DeviceTypeTraits<ExecutionSpace>::id);
return (device_id << instance_bits);
return (device_id << (num_instance_bits + num_device_bits));
}
template <typename ExecutionSpace>
inline uint32_t device_id(ExecutionSpace const& space) noexcept {
return device_id_root<ExecutionSpace>() + space.impl_instance_id();
return device_id_root<ExecutionSpace>() +
(DeviceTypeTraits<ExecutionSpace>::device_id(space)
<< num_instance_bits) +
space.impl_instance_id();
}
} // namespace Experimental
} // namespace Tools
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c9f323a

Please sign in to comment.