Files
TheRock/rocm-libraries/projects/rocthrust/thrust/detail/static_map.h
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

160 lines
4.4 KiB
C++

/*
* Copyright 2008-2013 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <thrust/detail/config.h>
THRUST_NAMESPACE_BEGIN
namespace detail
{
namespace static_map_detail
{
template <unsigned int k, unsigned int v>
struct key_value
{
static const unsigned int key = k;
static const unsigned int value = v;
};
template <typename Head, typename Tail = void>
struct cons
{
template <unsigned int key, unsigned int default_value>
struct static_get
{
static const unsigned int value =
(key == Head::key) ? (Head::value) : Tail::template static_get<key, default_value>::value;
};
template <unsigned int default_value>
THRUST_HOST_DEVICE static unsigned int get(unsigned int key)
{
return (key == Head::key) ? (Head::value) : Tail::template get<default_value>(key);
}
};
template <typename Head>
struct cons<Head, void>
{
template <unsigned int key, unsigned int default_value>
struct static_get
{
static const unsigned int value = (key == Head::key) ? (Head::value) : default_value;
};
template <unsigned int default_value>
THRUST_HOST_DEVICE static unsigned int get(unsigned int key)
{
return (key == Head::key) ? (Head::value) : default_value;
}
};
template <unsigned int default_value,
unsigned int key0 = 0,
unsigned int value0 = default_value,
unsigned int key1 = 0,
unsigned int value1 = default_value,
unsigned int key2 = 0,
unsigned int value2 = default_value,
unsigned int key3 = 0,
unsigned int value3 = default_value,
unsigned int key4 = 0,
unsigned int value4 = default_value,
unsigned int key5 = 0,
unsigned int value5 = default_value,
unsigned int key6 = 0,
unsigned int value6 = default_value,
unsigned int key7 = 0,
unsigned int value7 = default_value>
struct static_map
{
using impl = cons<
key_value<key0, value0>,
cons<key_value<key1, value1>,
cons<key_value<key2, value2>,
cons<key_value<key3, value3>,
cons<key_value<key4, value4>,
cons<key_value<key5, value5>, cons<key_value<key6, value6>, cons<key_value<key7, value7>>>>>>>>>;
template <unsigned int key>
struct static_get
{
static const unsigned int value = impl::template static_get<key, default_value>::value;
};
THRUST_HOST_DEVICE static unsigned int get(unsigned int key)
{
return impl::template get<default_value>(key);
}
};
} // end namespace static_map_detail
template <unsigned int default_value,
unsigned int key0 = 0,
unsigned int value0 = default_value,
unsigned int key1 = 0,
unsigned int value1 = default_value,
unsigned int key2 = 0,
unsigned int value2 = default_value,
unsigned int key3 = 0,
unsigned int value3 = default_value,
unsigned int key4 = 0,
unsigned int value4 = default_value,
unsigned int key5 = 0,
unsigned int value5 = default_value,
unsigned int key6 = 0,
unsigned int value6 = default_value,
unsigned int key7 = 0,
unsigned int value7 = default_value>
struct static_map
: static_map_detail::static_map<
default_value,
key0,
value0,
key1,
value1,
key2,
value2,
key3,
value3,
key4,
value4,
key5,
value5,
key6,
value6,
key7,
value7>
{};
template <unsigned int key, typename StaticMap>
struct static_lookup
{
static const unsigned int value = StaticMap::template static_get<key>::value;
};
template <typename StaticMap>
THRUST_HOST_DEVICE unsigned int lookup(unsigned int key)
{
return StaticMap::get(key);
}
} // end namespace detail
THRUST_NAMESPACE_END