Files
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

194 lines
4.3 KiB
C++

//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#ifndef DEFINITIONS_H
#define DEFINITIONS_H
#include <map>
#include <string>
#include <type_traits>
#include <vector>
#include <fmt/format.h>
enum class Mmio
{
Disabled,
Enabled,
};
inline std::string mmio(Mmio m)
{
static const char* mmio_map[]{
"",
".mmio",
};
return mmio_map[std::underlying_type_t<Mmio>(m)];
}
inline std::string mmio_tag(Mmio m)
{
static const char* mmio_map[]{
"__atomic_cuda_mmio_disable",
"__atomic_cuda_mmio_enable",
};
return mmio_map[std::underlying_type_t<Mmio>(m)];
}
enum class Operand
{
Floating,
Unsigned,
Signed,
Bit,
};
inline std::string operand(Operand op)
{
static std::map op_map = {
std::pair{Operand::Floating, "f"},
std::pair{Operand::Unsigned, "u"},
std::pair{Operand::Signed, "s"},
std::pair{Operand::Bit, "b"},
};
return op_map[op];
}
inline std::string operand_proxy_type(Operand op, size_t sz)
{
if (op == Operand::Floating)
{
if (sz == 32)
{
return {"float"};
}
else
{
return {"double"};
}
}
else if (op == Operand::Signed)
{
return fmt::format("int{}_t", sz);
}
// Binary and unsigned can be the same proxy_type
return fmt::format("uint{}_t", sz);
}
inline std::string constraints(Operand op, size_t sz)
{
static std::map constraint_map = {
std::pair{32,
std::map{
std::pair{Operand::Bit, "r"},
std::pair{Operand::Unsigned, "r"},
std::pair{Operand::Signed, "r"},
std::pair{Operand::Floating, "f"},
}},
std::pair{64,
std::map{
std::pair{Operand::Bit, "l"},
std::pair{Operand::Unsigned, "l"},
std::pair{Operand::Signed, "l"},
std::pair{Operand::Floating, "d"},
}},
std::pair{128,
std::map{
std::pair{Operand::Bit, "l"},
std::pair{Operand::Unsigned, "l"},
std::pair{Operand::Signed, "l"},
std::pair{Operand::Floating, "d"},
}},
};
if (sz == 16)
{
return {"h"};
}
else
{
return constraint_map[sz][op];
}
}
enum class Semantic
{
Relaxed,
Release,
Acquire,
Acq_Rel,
Seq_Cst,
Volatile,
};
inline std::string semantic(Semantic sem)
{
static std::map sem_map = {
std::pair{Semantic::Relaxed, ".relaxed"},
std::pair{Semantic::Release, ".release"},
std::pair{Semantic::Acquire, ".acquire"},
std::pair{Semantic::Acq_Rel, ".acq_rel"},
std::pair{Semantic::Seq_Cst, ".sc"},
std::pair{Semantic::Volatile, ""},
};
return sem_map[sem];
}
inline std::string semantic_tag(Semantic sem)
{
static std::map sem_map = {
std::pair{Semantic::Relaxed, "__atomic_cuda_relaxed"},
std::pair{Semantic::Release, "__atomic_cuda_release"},
std::pair{Semantic::Acquire, "__atomic_cuda_acquire"},
std::pair{Semantic::Acq_Rel, "__atomic_cuda_acq_rel"},
std::pair{Semantic::Seq_Cst, "__atomic_cuda_seq_cst"},
std::pair{Semantic::Volatile, "__atomic_cuda_volatile"},
};
return sem_map[sem];
}
enum class Scope
{
Thread,
Warp,
CTA,
Cluster,
GPU,
System,
};
inline std::string scope(Scope sco)
{
static std::map sco_map = {
std::pair{Scope::Thread, ""},
std::pair{Scope::Warp, ""},
std::pair{Scope::CTA, ".cta"},
std::pair{Scope::Cluster, ".cluster"},
std::pair{Scope::GPU, ".gpu"},
std::pair{Scope::System, ".sys"},
};
return sco_map[sco];
}
inline std::string scope_tag(Scope sco)
{
static std::map sco_map = {
std::pair{Scope::Thread, "__thread_scope_thread_tag"},
std::pair{Scope::Warp, ""},
std::pair{Scope::CTA, "__thread_scope_block_tag"},
std::pair{Scope::Cluster, "__thread_scope_cluster_tag"},
std::pair{Scope::GPU, "__thread_scope_device_tag"},
std::pair{Scope::System, "__thread_scope_system_tag"},
};
return sco_map[sco];
}
#endif // DEFINITIONS_H