mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-04-20 06:49:15 +00:00
Build codegen as standalone (#1556)
* Build codegen as standalone * Add exception for device tests * Use local filesystem header * add a codegen test CI stage and daily build --------- Co-authored-by: illsilin <Illia.Silin@amd.com> Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
find_package(hip)
|
||||
file(GLOB RTC_SOURCES CONFIGURE_DEPENDS src/*.cpp)
|
||||
add_library(ck_rtc ${RTC_SOURCES})
|
||||
target_include_directories(ck_rtc PUBLIC include)
|
||||
target_link_libraries(ck_rtc PUBLIC hip::host)
|
||||
target_link_libraries(ck_rtc PUBLIC -lstdc++fs)
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
#define GUARD_HOST_TEST_RTC_INCLUDE_RTC_COMPILE_KERNEL
|
||||
|
||||
#include <rtc/kernel.hpp>
|
||||
#include <ck/filesystem.hpp>
|
||||
#include <rtc/filesystem.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
struct src_file
|
||||
{
|
||||
CK::fs::path path;
|
||||
fs::path path;
|
||||
std::string_view content;
|
||||
};
|
||||
|
||||
|
||||
60
codegen/test/rtc/include/rtc/filesystem.hpp
Normal file
60
codegen/test/rtc/include/rtc/filesystem.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#ifndef GUARD_TEST_HOST_RTC_FILESYSTEM_HPP
|
||||
#define GUARD_TEST_HOST_RTC_FILESYSTEM_HPP
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
// clang-format off
|
||||
#if defined(CPPCHECK)
|
||||
#define RTC_HAS_FILESYSTEM 1
|
||||
#define RTC_HAS_FILESYSTEM_TS 1
|
||||
#elif defined(_WIN32)
|
||||
#if _MSC_VER >= 1920
|
||||
#define RTC_HAS_FILESYSTEM 1
|
||||
#define RTC_HAS_FILESYSTEM_TS 0
|
||||
#elif _MSC_VER >= 1900
|
||||
#define RTC_HAS_FILESYSTEM 0
|
||||
#define RTC_HAS_FILESYSTEM_TS 1
|
||||
#else
|
||||
#define RTC_HAS_FILESYSTEM 0
|
||||
#define RTC_HAS_FILESYSTEM_TS 0
|
||||
#endif
|
||||
#elif defined(__has_include)
|
||||
#if __has_include(<filesystem>) && __cplusplus >= 201703L
|
||||
#define RTC_HAS_FILESYSTEM 1
|
||||
#else
|
||||
#define RTC_HAS_FILESYSTEM 0
|
||||
#endif
|
||||
#if __has_include(<experimental/filesystem>) && __cplusplus >= 201103L
|
||||
#define RTC_HAS_FILESYSTEM_TS 1
|
||||
#else
|
||||
#define RTC_HAS_FILESYSTEM_TS 0
|
||||
#endif
|
||||
#else
|
||||
#define RTC_HAS_FILESYSTEM 0
|
||||
#define RTC_HAS_FILESYSTEM_TS 0
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#if RTC_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
#elif RTC_HAS_FILESYSTEM_TS
|
||||
#include <experimental/filesystem>
|
||||
#else
|
||||
#error "No filesystem include available"
|
||||
#endif
|
||||
|
||||
namespace rtc {
|
||||
|
||||
#if RTC_HAS_FILESYSTEM
|
||||
namespace fs = ::std::filesystem;
|
||||
#elif RTC_HAS_FILESYSTEM_TS
|
||||
namespace fs = ::std::experimental::filesystem;
|
||||
#endif
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // GUARD_RTC_FILESYSTEM_HPP_
|
||||
@@ -2,13 +2,13 @@
|
||||
#define GUARD_HOST_TEST_RTC_INCLUDE_RTC_TMP_DIR
|
||||
|
||||
#include <string>
|
||||
#include <ck/filesystem.hpp>
|
||||
#include <rtc/filesystem.hpp>
|
||||
|
||||
namespace rtc {
|
||||
|
||||
struct tmp_dir
|
||||
{
|
||||
CK::fs::path path;
|
||||
fs::path path;
|
||||
tmp_dir(const std::string& prefix = "");
|
||||
|
||||
void execute(const std::string& cmd) const;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "rtc/hip.hpp"
|
||||
#include <rtc/hip.hpp>
|
||||
#include <rtc/compile_kernel.hpp>
|
||||
#include <rtc/tmp_dir.hpp>
|
||||
#include <stdexcept>
|
||||
@@ -70,9 +70,9 @@ kernel compile_kernel(const std::vector<src_file>& srcs, compile_options options
|
||||
|
||||
for(const auto& src : srcs)
|
||||
{
|
||||
CK::fs::path full_path = td.path / src.path;
|
||||
CK::fs::path parent_path = full_path.parent_path();
|
||||
CK::fs::create_directories(parent_path);
|
||||
fs::path full_path = td.path / src.path;
|
||||
fs::path parent_path = full_path.parent_path();
|
||||
fs::create_directories(parent_path);
|
||||
write_string(full_path.string(), src.content);
|
||||
if(src.path.extension().string() == ".cpp")
|
||||
{
|
||||
@@ -86,7 +86,7 @@ kernel compile_kernel(const std::vector<src_file>& srcs, compile_options options
|
||||
td.execute(compiler() + options.flags);
|
||||
|
||||
auto out_path = td.path / out;
|
||||
if(not CK::fs::exists(out_path))
|
||||
if(not fs::exists(out_path))
|
||||
throw std::runtime_error("Output file missing: " + out);
|
||||
|
||||
auto obj = read_buffer(out_path.string());
|
||||
|
||||
@@ -31,10 +31,10 @@ std::string unique_string(const std::string& prefix)
|
||||
}
|
||||
|
||||
tmp_dir::tmp_dir(const std::string& prefix)
|
||||
: path(CK::fs::temp_directory_path() /
|
||||
: path(fs::temp_directory_path() /
|
||||
unique_string(prefix.empty() ? "ck-rtc" : "ck-rtc-" + prefix))
|
||||
{
|
||||
CK::fs::create_directories(this->path);
|
||||
fs::create_directories(this->path);
|
||||
}
|
||||
|
||||
void tmp_dir::execute(const std::string& cmd) const
|
||||
@@ -43,6 +43,6 @@ void tmp_dir::execute(const std::string& cmd) const
|
||||
std::system(s.c_str());
|
||||
}
|
||||
|
||||
tmp_dir::~tmp_dir() { CK::fs::remove_all(this->path); }
|
||||
tmp_dir::~tmp_dir() { fs::remove_all(this->path); }
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
Reference in New Issue
Block a user