Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ais-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ jobs:
platform: ${{ inputs.platform }}
rocm_version: ${{ inputs.rocm_version }}
upload_artifacts: true
build_and_test_cxx20:
if: ${{ !cancelled() && needs.build_AIS_CI_image.outputs.ci_image_build_satisfied == 'true' }}
needs: [AIS_CI_Pre-check, build_AIS_CI_image]
uses: ./.github/workflows/build-ais.yml
with:
ci_image: ${{ needs.build_AIS_CI_image.outputs.ci_image }}
cxx_compiler: amdclang++
cxx_standard: 20
platform: ${{ inputs.platform }}
rocm_version: ${{ inputs.rocm_version }}
upload_artifacts: false
generate_coverage: false
build_and_test_other_compilers:
# Try building on other compilers, but keep as separate job.
# Removes issues regarding matrix job overwriting outputs and
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/build-ais.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env:
AIS_INPUT_BUILD_ID: ${{ inputs.build_id }}
AIS_INPUT_CI_IMAGE: ${{ inputs.ci_image }}
AIS_INPUT_CXX_COMPILER: ${{ inputs.cxx_compiler }}
AIS_INPUT_CXX_STANDARD: ${{ inputs.cxx_standard }}
AIS_INPUT_JOB_DESIGNATOR: ${{ inputs.job_designator }}
AIS_INPUT_PLATFORM: ${{ inputs.platform }}
AIS_INPUT_UPLOAD_ARTIFACTS: ${{ inputs.upload_artifacts }}
Expand All @@ -18,7 +19,7 @@ env:
AIS_PKG_TYPE: ${{ inputs.platform == 'ubuntu' && 'DEB' || 'RPM' }}
AIS_INPUT_ROCM_VERSION: ${{ inputs.rocm_version }}
# Code coverage report only vetted to work for amdclang++ on Ubuntu
AIS_USE_CODE_COVERAGE: ${{ inputs.cxx_compiler == 'amdclang++' && inputs.platform == 'ubuntu' }}
AIS_USE_CODE_COVERAGE: ${{ inputs.cxx_compiler == 'amdclang++' && inputs.platform == 'ubuntu' && inputs.generate_coverage }}
AIS_HIP_ARCHITECTURES: gfx950;gfx1201;gfx1200;gfx1101;gfx1100;gfx1030;gfx942;gfx90a;gfx908
on:
workflow_call:
Expand All @@ -34,6 +35,15 @@ on:
cxx_compiler:
required: true
type: string
cxx_standard:
required: false
type: number
default: 17
generate_coverage:
default: true
description: "Allow coverage to be generated"
required: false
type: boolean
job_designator:
description: "Qualifies the type of job building hipFile."
required: false
Expand Down Expand Up @@ -67,7 +77,7 @@ permissions:
packages: read
jobs:
compile_on_AMD:
name: compile_on_AMD (${{ inputs.cxx_compiler }})
name: compile_on_AMD (${{ inputs.cxx_compiler }} C++${{ inputs.cxx_standard}})
outputs:
ais_hipfile_pkg_dev_filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_DEV_FILENAME }}
ais_hipfile_pkg_filename: ${{ steps.pkg-metadata.outputs.AIS_HIPFILE_PKG_FILENAME }}
Expand All @@ -90,7 +100,7 @@ jobs:
# We should expect that there are multiple instances of this job with different cxx_compilers.
# On non-pull_request triggering workflows, AIS_PR_NUMBER may be empty.
run: |
echo "AIS_CONTAINER_NAME=${AIS_PR_NUMBER:=${GITHUB_RUN_ID}}_${GITHUB_JOB}_${AIS_INPUT_PLATFORM}_${AIS_INPUT_ROCM_VERSION}_${AIS_SAFE_COMPILER_NAME}" >> "${GITHUB_ENV}"
echo "AIS_CONTAINER_NAME=${AIS_PR_NUMBER:=${GITHUB_RUN_ID}}_${GITHUB_JOB}_${AIS_INPUT_PLATFORM}_${AIS_INPUT_ROCM_VERSION}_${AIS_SAFE_COMPILER_NAME}_${AIS_INPUT_CXX_STANDARD}" >> "${GITHUB_ENV}"
- name: Fetching code repository...
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
Expand Down Expand Up @@ -142,6 +152,7 @@ jobs:
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER="${_AIS_INPUT_CXX_COMPILER}" \
-DAIS_CXX_STANDARD="${{ env.AIS_INPUT_CXX_STANDARD }}" \
-DCMAKE_CXX_FLAGS="-Werror" \
-DCMAKE_HIP_ARCHITECTURES="${{ env.AIS_HIP_ARCHITECTURES }}" \
-DCMAKE_HIP_PLATFORM=amd \
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ set(HIPFILE_SRC_COMMON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/common")
set(HIPFILE_TEST_COMMON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/common")
set(HIPFILE_AMD_TEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/test/amd_detail")

set(AIS_CXX_STANDARD "17" CACHE STRING "C++ standard to build with")
set_property(CACHE AIS_CXX_STANDARD PROPERTY STRINGS "17" "20")

# Set the list of build types for ccmake/CMake GUI
#
# This turns the build type box into a multi-select so you don't have to
Expand Down
2 changes: 1 addition & 1 deletion cmake/AISAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(ais_add_executable)
ais_set_compiler_flags(${arg_NAME})

# Set C++ standard
target_compile_features(${arg_NAME} PRIVATE cxx_std_17)
target_compile_features(${arg_NAME} PRIVATE cxx_std_${AIS_CXX_STANDARD})
set_target_properties(${arg_NAME} PROPERTIES CXX_EXTENSIONS OFF)

# Turn sanitizers off for executables
Expand Down
2 changes: 1 addition & 1 deletion cmake/AISAddLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function(ais_add_libraries)
add_library(${arg_NAME} ${arg_SRCS})

# Set C++ standard
target_compile_features(${arg_NAME} PUBLIC cxx_std_17)
target_compile_features(${arg_NAME} PUBLIC cxx_std_${AIS_CXX_STANDARD})
set_target_properties(${arg_NAME} PROPERTIES CXX_EXTENSIONS OFF)

# Set position-independent code
Expand Down
13 changes: 13 additions & 0 deletions shared/hipfile-cpp20.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Copyright (c) Advanced Micro Devices, Inc. All rights reserved.
*
* SPDX-License-Identifier: MIT
*/

#pragma once

#if __cplusplus >= 202002L
#include <concepts>
#define HIPFILE_REQUIRES(...) requires(__VA_ARGS__)
#else
#define HIPFILE_REQUIRES(...)
#endif
13 changes: 6 additions & 7 deletions src/amd_detail/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "configuration.h"
#include "environment.h"
#include "hip.h"
#include "static.h"

#include <optional>

Expand All @@ -15,9 +14,9 @@ using namespace hipFile;
bool
Configuration::fastpath() const noexcept
{
HIPFILE_STATIC bool fastpath_env{!Environment::force_compat_mode().value_or(false)};
HIPFILE_STATIC bool readExists{!!getHipAmdFileReadPtr()};
HIPFILE_STATIC bool writeExists{!!getHipAmdFileWritePtr()};
static bool fastpath_env{!Environment::force_compat_mode().value_or(false)};
static bool readExists{!!getHipAmdFileReadPtr()};
static bool writeExists{!!getHipAmdFileWritePtr()};
return readExists && writeExists && m_fastpath_override.value_or(fastpath_env);
}

Expand All @@ -30,7 +29,7 @@ Configuration::fastpath(bool enabled) noexcept
bool
Configuration::fallback() const noexcept
{
HIPFILE_STATIC bool fallback_env{Environment::allow_compat_mode().value_or(true)};
static bool fallback_env{Environment::allow_compat_mode().value_or(true)};
return m_fallback_override.value_or(fallback_env);
}

Expand All @@ -43,13 +42,13 @@ Configuration::fallback(bool enabled) noexcept
unsigned int
Configuration::statsLevel() const noexcept
{
HIPFILE_STATIC unsigned int stats_level_env{Environment::stats_level().value_or(0)};
static unsigned int stats_level_env{Environment::stats_level().value_or(0)};
return stats_level_env;
}

bool
Configuration::unsupportedFileSystems() const noexcept
{
HIPFILE_STATIC bool unsupported_file_systems_env{Environment::unsupported_file_systems().value_or(false)};
static bool unsupported_file_systems_env{Environment::unsupported_file_systems().value_or(false)};
return unsupported_file_systems_env;
}
12 changes: 3 additions & 9 deletions src/amd_detail/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,19 @@

#include "context.h"
#include "hip.h"
#include "hipfile-warnings.h"
#include "state.h"
#include "stats.h"
#include "sys.h"

namespace hipFile {

HipFileInit::HipFileInit()
void
hipFileInit()
{
Context<Hip>::get();
Context<Sys>::get();
Context<StatsServer>::get();
Context<IStatsServer>::get();
Context<DriverState>::get();
}

HIPFILE_WARN_NO_GLOBAL_CTOR_OFF
HIPFILE_WARN_NO_EXIT_DTOR_OFF
static HipFileInit *hipfile_init = Context<HipFileInit>::get();
HIPFILE_WARN_NO_EXIT_DTOR_ON
HIPFILE_WARN_NO_GLOBAL_CTOR_ON

}
29 changes: 21 additions & 8 deletions src/amd_detail/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,33 @@

#pragma once

#include "hipfile-cpp20.h"
#include "hipfile-warnings.h"
#include "stats.h"

#include <stdexcept>
#ifdef AIS_TESTING
#include <mutex>
#endif

#define HIPFILE_CONTEXT_DEFAULT_IMPL(T, Impl) \
template <> struct ContextDefaultImpl<T> : ContextDefaultImplChecked<T, Impl> {}

namespace hipFile {

template <typename T> struct ContextOverride;

template <typename T, typename Impl>
HIPFILE_REQUIRES(std::derived_from<Impl, T>)
struct ContextDefaultImplChecked {
using type = Impl;
};

template <typename T> struct ContextDefaultImpl : ContextDefaultImplChecked<T, T> {};
HIPFILE_CONTEXT_DEFAULT_IMPL(IStatsServer, StatsServer);

template <typename T> struct Context {
using DefaultImpl = typename ContextDefaultImpl<T>::type;
Context() = delete;
Context(const Context &) = delete;
Context(Context &&) = delete;
Expand All @@ -31,11 +47,11 @@ template <typename T> struct Context {
static T *get()
{
std::lock_guard<std::mutex> lock{m};
HIPFILE_WARN_NO_EXIT_DTOR_OFF
static T standard{};
HIPFILE_WARN_NO_EXIT_DTOR_ON
if (replacement)
return replacement;
HIPFILE_WARN_NO_EXIT_DTOR_OFF
static DefaultImpl standard{};
HIPFILE_WARN_NO_EXIT_DTOR_ON
return &standard;
}

Expand Down Expand Up @@ -67,7 +83,7 @@ template <typename T> struct Context {
static T *get()
{
HIPFILE_WARN_NO_EXIT_DTOR_OFF
static T context{};
static DefaultImpl context{};
HIPFILE_WARN_NO_EXIT_DTOR_ON
return &context;
}
Expand All @@ -92,9 +108,6 @@ template <typename T> struct ContextOverride {
};
#endif

class HipFileInit {
HipFileInit();
friend struct Context<HipFileInit>;
};
void hipFileInit();

}
5 changes: 2 additions & 3 deletions src/amd_detail/hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "context.h"
#include "hip.h"
#include "static.h"

#include <cstdlib>
#include <system_error>
Expand All @@ -25,15 +24,15 @@ catch (...) {
hipAmdFileRead_t
getHipAmdFileReadPtr()
{
HIPFILE_STATIC hipAmdFileRead_t hipAmdFileReadPtr{
static hipAmdFileRead_t hipAmdFileReadPtr{
reinterpret_cast<hipAmdFileRead_t>(hipGetProcAddressHelper("hipAmdFileRead"))};
return hipAmdFileReadPtr;
}

hipAmdFileWrite_t
getHipAmdFileWritePtr()
{
HIPFILE_STATIC hipAmdFileWrite_t hipAmdFileWritePtr{
static hipAmdFileWrite_t hipAmdFileWritePtr{
reinterpret_cast<hipAmdFileWrite_t>(hipGetProcAddressHelper("hipAmdFileWrite"))};
return hipAmdFileWritePtr;
}
Expand Down
Loading
Loading