Update develop (#5)

* refactor
This commit is contained in:
Chao Liu
2021-08-06 16:11:15 -05:00
committed by GitHub
parent f6edda6119
commit d09ea4f4e5
58 changed files with 136 additions and 123 deletions

View File

@@ -2404,8 +2404,7 @@ unsigned int gamma(unsigned int arg)
0.0114684895434781459556 }; double t = arg + 4.65, s = p[0]; for(unsigned int i=0; i<5; ++i) 0.0114684895434781459556 }; double t = arg + 4.65, s = p[0]; for(unsigned int i=0; i<5; ++i)
s += p[i+1] / (arg+i); s += p[i+1] / (arg+i);
return std::log(s) + (arg-0.5)*std::log(t) - t; return std::log(s) + (arg-0.5)*std::log(t) - t;
*/ static const f31 pi(0xC90FDAA2, 1), */ static const f31 pi(0xC90FDAA2, 1), lbe(0xB8AA3B29, 0);
lbe(0xB8AA3B29, 0);
unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000; unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000;
bool bsign = sign != 0; bool bsign = sign != 0;
f31 z(abs), x = sign ? (z + f31(0x80000000, 0)) : z, t = x + f31(0x94CCCCCD, 2), f31 z(abs), x = sign ? (z + f31(0x80000000, 0)) : z, t = x + f31(0x94CCCCCD, 2),

View File

@@ -1,4 +1,4 @@
add_subdirectory(host_tensor) add_subdirectory(host_tensor)
add_subdirectory(online_compilation) add_subdirectory(online_compile)
add_subdirectory(driver_offline) add_subdirectory(driver_offline)
add_subdirectory(driver_online) add_subdirectory(driver_online)

View File

@@ -1,6 +1,7 @@
include_directories(BEFORE include_directories(BEFORE
include include
${PROJECT_SOURCE_DIR}/host/host_tensor/include ${PROJECT_SOURCE_DIR}/host/host_tensor/include
${PROJECT_SOURCE_DIR}/host/solver/include
${PROJECT_SOURCE_DIR}/composable_kernel/include ${PROJECT_SOURCE_DIR}/composable_kernel/include
${PROJECT_SOURCE_DIR}/composable_kernel/include/utility ${PROJECT_SOURCE_DIR}/composable_kernel/include/utility
${PROJECT_SOURCE_DIR}/composable_kernel/include/tensor_description ${PROJECT_SOURCE_DIR}/composable_kernel/include/tensor_description

View File

@@ -1,8 +1,9 @@
include_directories(BEFORE include_directories(BEFORE
include include
${PROJECT_BINARY_DIR}/host/online_compilation/include ${PROJECT_BINARY_DIR}/host/online_compile/include
${PROJECT_SOURCE_DIR}/host/online_compilation/include ${PROJECT_SOURCE_DIR}/host/online_compile/include
${PROJECT_SOURCE_DIR}/host/host_tensor/include ${PROJECT_SOURCE_DIR}/host/host_tensor/include
${PROJECT_SOURCE_DIR}/host/solver/include
${PROJECT_SOURCE_DIR}/composable_kernel/include ${PROJECT_SOURCE_DIR}/composable_kernel/include
${PROJECT_SOURCE_DIR}/composable_kernel/include/utility ${PROJECT_SOURCE_DIR}/composable_kernel/include/utility
${PROJECT_SOURCE_DIR}/composable_kernel/include/tensor_description ${PROJECT_SOURCE_DIR}/composable_kernel/include/tensor_description
@@ -18,4 +19,4 @@ set(CONV_FWD_DRIVER_ONLINE_SOURCE conv_fwd_driver_online.cpp)
add_executable(conv_fwd_driver_online ${CONV_FWD_DRIVER_ONLINE_SOURCE}) add_executable(conv_fwd_driver_online ${CONV_FWD_DRIVER_ONLINE_SOURCE})
target_link_libraries(conv_fwd_driver_online PRIVATE host_tensor) target_link_libraries(conv_fwd_driver_online PRIVATE host_tensor)
target_link_libraries(conv_fwd_driver_online PRIVATE online_compilation) target_link_libraries(conv_fwd_driver_online PRIVATE online_compile)

View File

@@ -39,11 +39,11 @@ int main(int argc, char* argv[])
using size_t = std::size_t; using size_t = std::size_t;
hipStream_t stream; hipStream_t stream;
olCompile::Handle* handle; online_compile::Handle* handle;
MY_HIP_CHECK(hipStreamCreate(&stream)); MY_HIP_CHECK(hipStreamCreate(&stream));
handle = new olCompile::Handle(stream); handle = new online_compile::Handle(stream);
constexpr auto I0 = Number<0>{}; constexpr auto I0 = Number<0>{};
constexpr auto I1 = Number<1>{}; constexpr auto I1 = Number<1>{};

View File

@@ -216,7 +216,7 @@ template <typename TInWei,
typename InLeftPads, typename InLeftPads,
typename InRightPads> typename InRightPads>
void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_dlops_nchw_kcyx_nkhw( void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_dlops_nchw_kcyx_nkhw(
olCompile::Handle* handle, online_compile::Handle* handle,
const InLengths& in_n_c_hi_wi_lengths, const InLengths& in_n_c_hi_wi_lengths,
const WeiLengths& wei_k_c_y_x_lengths, const WeiLengths& wei_k_c_y_x_lengths,
const OutLengths& out_n_k_ho_wo_lengths, const OutLengths& out_n_k_ho_wo_lengths,

View File

@@ -212,7 +212,7 @@ template <typename TInWei,
typename InLeftPads, typename InLeftPads,
typename InRightPads> typename InRightPads>
void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_xdlops_nchw_kcyx_nkhw( void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_xdlops_nchw_kcyx_nkhw(
olCompile::Handle* handle, online_compile::Handle* handle,
const InLengths& in_n_c_hi_wi_lengths, const InLengths& in_n_c_hi_wi_lengths,
const WeiLengths& wei_k_c_y_x_lengths, const WeiLengths& wei_k_c_y_x_lengths,
const OutLengths& out_n_k_ho_wo_lengths, const OutLengths& out_n_k_ho_wo_lengths,

View File

@@ -213,7 +213,7 @@ template <typename TInWei,
typename InLeftPads, typename InLeftPads,
typename InRightPads> typename InRightPads>
void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_xdlops_nhwc_kyxc_nhwk( void online_device_dynamic_convolution_forward_implicit_gemm_v4r4_xdlops_nhwc_kyxc_nhwk(
olCompile::Handle* handle, online_compile::Handle* handle,
const InLengths& in_n_hi_wi_c_lengths, const InLengths& in_n_hi_wi_c_lengths,
const WeiLengths& wei_k_y_x_c_lengths, const WeiLengths& wei_k_y_x_c_lengths,
const OutLengths& out_n_ho_wo_k_lengths, const OutLengths& out_n_ho_wo_k_lengths,

View File

@@ -20,7 +20,7 @@ template <typename TInWei,
typename InLeftPads, typename InLeftPads,
typename InRightPads> typename InRightPads>
void online_device_dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcyx_nkhw( void online_device_dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcyx_nkhw(
olCompile::Handle* handle, online_compile::Handle* handle,
const InLengths& in_n_c_hi_wi_lengths, const InLengths& in_n_c_hi_wi_lengths,
const WeiLengths& wei_k_c_y_x_lengths, const WeiLengths& wei_k_c_y_x_lengths,
const OutLengths& out_n_k_ho_wo_lengths, const OutLengths& out_n_k_ho_wo_lengths,
@@ -100,13 +100,13 @@ void online_device_dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcy
"dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcyx_nkhw.cpp"; "dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcyx_nkhw.cpp";
std::string algo_name = "implicit_gemm_conv_fwd_v6r1_dlops_nchw"; std::string algo_name = "implicit_gemm_conv_fwd_v6r1_dlops_nchw";
std::string compile_param_string = " -std=c++17 " + compile_param.GetCompileParameterString(); std::string compile_param_string = get_ck_hip_online_compile_common_flag() + compile_param.GetCompileParameterString();
std::string network_config = compile_param_string; std::string network_config = compile_param_string;
std::vector<float> kernel1_times; std::vector<float> kernel1_times;
std::vector<float> kernel2_times; std::vector<float> kernel2_times;
for(index_t i = 0; i < nrepeat; ++i) for(index_t i = 0; i < nrepeat + 1; ++i)
{ {
KernelTimer timer1, timer2; KernelTimer timer1, timer2;
std::string kernel_name; std::string kernel_name;
@@ -164,11 +164,11 @@ void online_device_dynamic_convolution_forward_implicit_gemm_v6r1_dlops_nchw_kcy
auto ave_time1 = auto ave_time1 =
std::accumulate( std::accumulate(
std::next(kernel1_times.begin()), kernel1_times.end(), 0., std::plus<float>{}) / std::next(kernel1_times.begin()), kernel1_times.end(), 0., std::plus<float>{}) /
(nrepeat - 1); nrepeat;
auto ave_time2 = auto ave_time2 =
std::accumulate( std::accumulate(
std::next(kernel2_times.begin()), kernel2_times.end(), 0., std::plus<float>{}) / std::next(kernel2_times.begin()), kernel2_times.end(), 0., std::plus<float>{}) /
(nrepeat - 1); nrepeat;
float perf = (float)(conv_problem_desc.CalculateFlop()) / float perf = (float)(conv_problem_desc.CalculateFlop()) /
(std::size_t(1000) * 1000 * 1000) / (ave_time1 + ave_time2); (std::size_t(1000) * 1000 * 1000) / (ave_time1 + ave_time2);

View File

@@ -3,6 +3,13 @@
namespace ck_driver { namespace ck_driver {
inline auto get_ck_hip_online_compile_common_flag()
{
std::string param = " -std=c++17";
return param;
}
// greatest common divisor, aka highest common factor // greatest common divisor, aka highest common factor
inline int gcd(int x, int y) inline int gcd(int x, int y)
{ {

View File

@@ -67,10 +67,10 @@ else()
set(OLC_DEBUG 0) set(OLC_DEBUG 0)
endif() endif()
configure_file("${PROJECT_SOURCE_DIR}/host/online_compilation/include/config.h.in" "${PROJECT_BINARY_DIR}/host/online_compilation/include/config.h") configure_file("${PROJECT_SOURCE_DIR}/host/online_compile/include/config.h.in" "${PROJECT_BINARY_DIR}/host/online_compile/include/config.h")
include_directories(BEFORE include_directories(BEFORE
${PROJECT_BINARY_DIR}/host/online_compilation/include ${PROJECT_BINARY_DIR}/host/online_compile/include
) )
message(STATUS "Hip compiler flags: ${HIP_COMPILER_FLAGS}") message(STATUS "Hip compiler flags: ${HIP_COMPILER_FLAGS}")
@@ -97,7 +97,7 @@ set(ONLINE_COMPILATION_SOURCE
) )
include_directories(BEFORE include_directories(BEFORE
${PROJECT_BINARY_DIR}/host/online_compilation/include ${PROJECT_BINARY_DIR}/host/online_compile/include
include include
) )
@@ -152,17 +152,17 @@ add_custom_command(
) )
## the library target ## the library target
add_library(online_compilation SHARED ${ONLINE_COMPILATION_SOURCE}) add_library(online_compile SHARED ${ONLINE_COMPILATION_SOURCE})
target_include_directories(online_compilation PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/online_compilation/include/) target_include_directories(online_compile PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/online_compile/include/)
target_include_directories(online_compilation PRIVATE ${PROJECT_BINARY_DIR}) target_include_directories(online_compile PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(online_compilation PRIVATE ${PROJECT_SOURCE_DIR}/external/half/include/) target_include_directories(online_compile PRIVATE ${PROJECT_SOURCE_DIR}/external/half/include/)
target_link_libraries(online_compilation PRIVATE hip::device) target_link_libraries(online_compile PRIVATE hip::device)
target_link_libraries(online_compilation INTERFACE hip::host) target_link_libraries(online_compile INTERFACE hip::host)
target_link_libraries(online_compilation PRIVATE Boost::filesystem) target_link_libraries(online_compile PRIVATE Boost::filesystem)
target_compile_features(online_compilation PUBLIC) target_compile_features(online_compile PUBLIC)
set_target_properties(online_compilation PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(online_compile PROPERTIES POSITION_INDEPENDENT_CODE ON)
install(TARGETS online_compilation LIBRARY DESTINATION lib) install(TARGETS online_compile LIBRARY DESTINATION lib)

View File

@@ -35,7 +35,7 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
namespace olCompile { namespace online_compile {
OLC_DECLARE_ENV_VAR(OLC_DISABLE_CACHE) OLC_DECLARE_ENV_VAR(OLC_DISABLE_CACHE)
OLC_DECLARE_ENV_VAR(HOME) OLC_DECLARE_ENV_VAR(HOME)
@@ -62,14 +62,14 @@ boost::filesystem::path GetCachePath()
return user_path; return user_path;
} }
static bool IsCacheDisabled() { return olCompile::IsEnabled(OLC_DISABLE_CACHE{}); } static bool IsCacheDisabled() { return online_compile::IsEnabled(OLC_DISABLE_CACHE{}); }
boost::filesystem::path boost::filesystem::path
GetCacheFile(const std::string& device, const std::string& name, const std::string& args) GetCacheFile(const std::string& device, const std::string& name, const std::string& args)
{ {
// std::string filename = (is_kernel_str ? olCompile::md5(name) : name) + ".o"; // std::string filename = (is_kernel_str ? online_compile::md5(name) : name) + ".o";
std::string filename = name + ".o"; std::string filename = name + ".o";
return GetCachePath() / olCompile::md5(device + ":" + args) / filename; return GetCachePath() / online_compile::md5(device + ":" + args) / filename;
} }
boost::filesystem::path LoadBinary(const TargetProperties& target, boost::filesystem::path LoadBinary(const TargetProperties& target,
@@ -77,7 +77,7 @@ boost::filesystem::path LoadBinary(const TargetProperties& target,
const std::string& name, const std::string& name,
const std::string& args) const std::string& args)
{ {
if(olCompile::IsCacheDisabled()) if(online_compile::IsCacheDisabled())
return {}; return {};
(void)num_cu; (void)num_cu;
@@ -97,7 +97,7 @@ void SaveBinary(const boost::filesystem::path& binary_path,
const std::string& name, const std::string& name,
const std::string& args) const std::string& args)
{ {
if(olCompile::IsCacheDisabled()) if(online_compile::IsCacheDisabled())
{ {
boost::filesystem::remove(binary_path); boost::filesystem::remove(binary_path);
} }
@@ -109,4 +109,4 @@ void SaveBinary(const boost::filesystem::path& binary_path,
} }
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -38,7 +38,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif // __linux__ #endif // __linux__
namespace olCompile { namespace online_compile {
namespace exec { namespace exec {
int Run(const std::string& p, std::istream* in, std::ostream* out) int Run(const std::string& p, std::istream* in, std::ostream* out)
@@ -53,7 +53,7 @@ int Run(const std::string& p, std::istream* in, std::ostream* out)
OLC_MANAGE_PTR(FILE*, pclose) pipe{popen(p.c_str(), file_mode)}; OLC_MANAGE_PTR(FILE*, pclose) pipe{popen(p.c_str(), file_mode)};
if(!pipe) if(!pipe)
throw std::runtime_error("olCompile::exec::Run(): popen(" + p + ", " + file_mode + throw std::runtime_error("online_compile::exec::Run(): popen(" + p + ", " + file_mode +
") failed"); ") failed");
if(redirect_stdin || redirect_stdout) if(redirect_stdin || redirect_stdout)
@@ -74,7 +74,7 @@ int Run(const std::string& p, std::istream* in, std::ostream* out)
buffer[in->gcount()] = 0; buffer[in->gcount()] = 0;
if(fputs(buffer.data(), pipe.get()) == EOF) if(fputs(buffer.data(), pipe.get()) == EOF)
throw std::runtime_error("olCompile::exec::Run(): fputs() failed"); throw std::runtime_error("online_compile::exec::Run(): fputs() failed");
} }
} }
} }
@@ -90,4 +90,4 @@ int Run(const std::string& p, std::istream* in, std::ostream* out)
} }
} // namespace exec } // namespace exec
} // namespace olCompile } // namespace online_compile

View File

@@ -50,7 +50,7 @@
OLC_DECLARE_ENV_VAR(OLC_DEVICE_CU) OLC_DECLARE_ENV_VAR(OLC_DEVICE_CU)
namespace olCompile { namespace online_compile {
std::size_t GetAvailableMemory() std::size_t GetAvailableMemory()
{ {
@@ -182,24 +182,24 @@ KernelInvoke Handle::Run(Kernel k) const { return k.Invoke(this->GetStream()); }
Program Handle::LoadProgram(const std::string& program_name, std::string params) const Program Handle::LoadProgram(const std::string& program_name, std::string params) const
{ {
if((!olCompile::EndsWith(program_name, ".mlir-cpp")) && if((!online_compile::EndsWith(program_name, ".mlir-cpp")) &&
(!olCompile::EndsWith(program_name, ".mlir"))) (!online_compile::EndsWith(program_name, ".mlir")))
{ {
params += " -mcpu=" + this->GetTargetProperties().Name(); params += " -mcpu=" + this->GetTargetProperties().Name();
} }
auto hsaco = olCompile::LoadBinary( auto hsaco = online_compile::LoadBinary(
this->GetTargetProperties(), this->GetMaxComputeUnits(), program_name, params); this->GetTargetProperties(), this->GetMaxComputeUnits(), program_name, params);
if(hsaco.empty()) if(hsaco.empty())
{ {
auto p = HIPOCProgram{program_name, params, this->GetTargetProperties()}; auto p = HIPOCProgram{program_name, params, this->GetTargetProperties()};
auto path = olCompile::GetCachePath() / boost::filesystem::unique_path(); auto path = online_compile::GetCachePath() / boost::filesystem::unique_path();
if(p.IsCodeObjectInMemory()) if(p.IsCodeObjectInMemory())
olCompile::WriteFile(p.GetCodeObjectBlob(), path); online_compile::WriteFile(p.GetCodeObjectBlob(), path);
else else
boost::filesystem::copy_file(p.GetCodeObjectPathname(), path); boost::filesystem::copy_file(p.GetCodeObjectPathname(), path);
olCompile::SaveBinary(path, this->GetTargetProperties(), program_name, params); online_compile::SaveBinary(path, this->GetTargetProperties(), program_name, params);
return p; return p;
} }
@@ -245,7 +245,7 @@ std::size_t Handle::GetGlobalMemorySize() const
std::size_t Handle::GetMaxComputeUnits() const std::size_t Handle::GetMaxComputeUnits() const
{ {
int result; int result;
const char* const num_cu = olCompile::GetStringEnv(OLC_DEVICE_CU{}); const char* const num_cu = online_compile::GetStringEnv(OLC_DEVICE_CU{});
if(num_cu != nullptr && strlen(num_cu) > 0) if(num_cu != nullptr && strlen(num_cu) > 0)
{ {
return boost::lexical_cast<std::size_t>(num_cu); return boost::lexical_cast<std::size_t>(num_cu);
@@ -282,4 +282,4 @@ std::ostream& Handle::Print(std::ostream& os) const
return os; return os;
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -45,7 +45,7 @@ OLC_DECLARE_ENV_VAR(OLC_DEBUG_HIP_DUMP)
#define OLC_HIP_COMPILER "/opt/rocm/llvm/bin/clang++" #define OLC_HIP_COMPILER "/opt/rocm/llvm/bin/clang++"
namespace olCompile { namespace online_compile {
bool IsHccCompiler() bool IsHccCompiler()
{ {
@@ -155,12 +155,12 @@ static boost::filesystem::path HipBuildImpl(boost::optional<TmpDir>& tmp_dir,
params += " -mllvm -amdgpu-function-calls=false"; params += " -mllvm -amdgpu-function-calls=false";
} }
if(olCompile::IsEnabled(OLC_DEBUG_HIP_VERBOSE{})) if(online_compile::IsEnabled(OLC_DEBUG_HIP_VERBOSE{}))
{ {
params += " -v"; params += " -v";
} }
if(olCompile::IsEnabled(OLC_DEBUG_HIP_DUMP{})) if(online_compile::IsEnabled(OLC_DEBUG_HIP_DUMP{}))
{ {
if(IsHccCompiler()) if(IsHccCompiler())
{ {
@@ -247,7 +247,7 @@ static external_tool_version_t HipCompilerVersionImpl()
break; break;
std::stringstream out; std::stringstream out;
if(olCompile::exec::Run(path + " --version", nullptr, &out) != 0) if(online_compile::exec::Run(path + " --version", nullptr, &out) != 0)
break; break;
std::string line; std::string line;
@@ -343,4 +343,4 @@ bool operator<=(const external_tool_version_t& lhs, const external_tool_version_
return !(lhs > rhs); return !(lhs > rhs);
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -34,7 +34,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
namespace olCompile { namespace online_compile {
void HIPOCKernelInvoke::run(void* args, std::size_t size) const void HIPOCKernelInvoke::run(void* args, std::size_t size) const
{ {
@@ -81,4 +81,4 @@ HIPOCKernelInvoke HIPOCKernel::Invoke(hipStream_t stream,
{ {
return HIPOCKernelInvoke{stream, fun, ldims, gdims, name, callback}; return HIPOCKernelInvoke{stream, fun, ldims, gdims, name, callback};
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -39,7 +39,7 @@
#include <unistd.h> #include <unistd.h>
namespace olCompile { namespace online_compile {
static hipModulePtr CreateModule(const boost::filesystem::path& hsaco_file) static hipModulePtr CreateModule(const boost::filesystem::path& hsaco_file)
{ {
@@ -89,7 +89,7 @@ void HIPOCProgramImpl::BuildCodeObjectInFile(std::string& params,
this->dir.emplace(filename); this->dir.emplace(filename);
hsaco_file = dir->path / (filename + ".o"); hsaco_file = dir->path / (filename + ".o");
if(olCompile::EndsWith(filename, ".cpp")) if(online_compile::EndsWith(filename, ".cpp"))
{ {
hsaco_file = HipBuild(dir, filename, src, params, target); hsaco_file = HipBuild(dir, filename, src, params, target);
} }
@@ -104,7 +104,7 @@ void HIPOCProgramImpl::BuildCodeObject(std::string params)
{ {
std::string filename = program; std::string filename = program;
if(olCompile::EndsWith(filename, ".cpp")) if(online_compile::EndsWith(filename, ".cpp"))
{ {
params += " -Wno-everything"; params += " -Wno-everything";
} }
@@ -136,4 +136,4 @@ std::string HIPOCProgram::GetCodeObjectBlob() const
bool HIPOCProgram::IsCodeObjectInMemory() const { return !impl->binary.empty(); }; bool HIPOCProgram::IsCodeObjectInMemory() const { return !impl->binary.empty(); };
} // namespace olCompile } // namespace online_compile

View File

@@ -31,7 +31,7 @@
#include <kernel_build_params.hpp> #include <kernel_build_params.hpp>
#include <stringutils.hpp> #include <stringutils.hpp>
namespace olCompile { namespace online_compile {
static std::string GenerateDefines(const std::vector<KernelBuildParameter>& options, static std::string GenerateDefines(const std::vector<KernelBuildParameter>& options,
const std::string& prefix) const std::string& prefix)
@@ -63,4 +63,4 @@ static std::string GenerateDefines(const std::vector<KernelBuildParameter>& opti
return JoinStrings(strs, " "); return JoinStrings(strs, " ");
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -46,7 +46,7 @@
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
namespace olCompile { namespace online_compile {
const std::vector<Kernel>& KernelCache::GetKernels(const std::string& algorithm, const std::vector<Kernel>& KernelCache::GetKernels(const std::string& algorithm,
const std::string& network_config) const std::string& network_config)
@@ -151,4 +151,4 @@ void KernelCache::ClearKernels(const std::string& algorithm, const std::string&
KernelCache::KernelCache() {} KernelCache::KernelCache() {}
} // namespace olCompile } // namespace online_compile

View File

@@ -5,7 +5,7 @@
using namespace std; using namespace std;
namespace olCompile { namespace online_compile {
#if OLC_DEBUG #if OLC_DEBUG
static LogLevel defLevel = LogLevel::Info2; static LogLevel defLevel = LogLevel::Info2;
@@ -27,7 +27,7 @@ string LogLevelString(LogLevel level)
ostream& fdt_log(LogLevel level, const char* header, const char* content) ostream& fdt_log(LogLevel level, const char* header, const char* content)
{ {
if(level > olCompile::defLevel) if(level > online_compile::defLevel)
{ {
return (cerr); return (cerr);
}; };
@@ -40,4 +40,4 @@ ostream& fdt_log(LogLevel level, const char* header, const char* content)
ostream& fdt_log() { return (cerr); }; ostream& fdt_log() { return (cerr); };
void fdt_log_flush() { cerr << endl; } void fdt_log_flush() { cerr << endl; }
}; // namespace olCompile }; // namespace online_compile

View File

@@ -298,7 +298,7 @@ static void MD5_Final(unsigned char* result, MD5_CTX* ctx)
memset(ctx, 0, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx));
} }
namespace olCompile { namespace online_compile {
std::string md5(std::string s) std::string md5(std::string s)
{ {
@@ -316,4 +316,4 @@ std::string md5(std::string s)
return sout.str(); return sout.str();
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -32,7 +32,7 @@
OLC_DECLARE_ENV_VAR(OLC_DEBUG_ENFORCE_DEVICE) OLC_DECLARE_ENV_VAR(OLC_DEBUG_ENFORCE_DEVICE)
namespace olCompile { namespace online_compile {
static std::string GetDeviceNameFromMap(const std::string& in) static std::string GetDeviceNameFromMap(const std::string& in)
{ {
@@ -53,7 +53,7 @@ static std::string GetDeviceNameFromMap(const std::string& in)
{"10.3.0 Sienna_Cichlid 18", "gfx1030"}, {"10.3.0 Sienna_Cichlid 18", "gfx1030"},
}; };
const char* const p_asciz = olCompile::GetStringEnv(OLC_DEBUG_ENFORCE_DEVICE{}); const char* const p_asciz = online_compile::GetStringEnv(OLC_DEBUG_ENFORCE_DEVICE{});
if(p_asciz != nullptr && strlen(p_asciz) > 0) if(p_asciz != nullptr && strlen(p_asciz) > 0)
return {p_asciz}; return {p_asciz};
@@ -116,4 +116,4 @@ void TargetProperties::InitDbId()
dbId += "_xnack"; dbId += "_xnack";
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -31,7 +31,7 @@
OLC_DECLARE_ENV_VAR(OLC_DEBUG_SAVE_TEMP_DIR) OLC_DECLARE_ENV_VAR(OLC_DEBUG_SAVE_TEMP_DIR)
namespace olCompile { namespace online_compile {
void SystemCmd(std::string cmd) void SystemCmd(std::string cmd)
{ {
@@ -43,7 +43,7 @@ void SystemCmd(std::string cmd)
TmpDir::TmpDir(std::string prefix) TmpDir::TmpDir(std::string prefix)
: path(boost::filesystem::temp_directory_path() / : path(boost::filesystem::temp_directory_path() /
boost::filesystem::unique_path("olCompile-" + prefix + "-%%%%-%%%%-%%%%-%%%%")) boost::filesystem::unique_path("online_compile-" + prefix + "-%%%%-%%%%-%%%%-%%%%"))
{ {
boost::filesystem::create_directories(this->path); boost::filesystem::create_directories(this->path);
} }
@@ -57,10 +57,10 @@ void TmpDir::Execute(std::string exe, std::string args) const
TmpDir::~TmpDir() TmpDir::~TmpDir()
{ {
if(!olCompile::IsEnabled(OLC_DEBUG_SAVE_TEMP_DIR{})) if(!online_compile::IsEnabled(OLC_DEBUG_SAVE_TEMP_DIR{}))
{ {
boost::filesystem::remove_all(this->path); boost::filesystem::remove_all(this->path);
} }
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -31,7 +31,7 @@
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <string> #include <string>
namespace olCompile { namespace online_compile {
boost::filesystem::path boost::filesystem::path
GetCacheFile(const std::string& device, const std::string& name, const std::string& args); GetCacheFile(const std::string& device, const std::string& name, const std::string& args);
@@ -47,6 +47,6 @@ void SaveBinary(const boost::filesystem::path& binary_path,
const std::string& name, const std::string& name,
const std::string& args); const std::string& args);
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -31,7 +31,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace olCompile { namespace online_compile {
/// \todo Rework: Case-insensitive string compare, ODR, (?) move to .cpp /// \todo Rework: Case-insensitive string compare, ODR, (?) move to .cpp
@@ -101,23 +101,23 @@ inline const char* GetStringEnv(T)
template <class T> template <class T>
inline bool IsEnabled(T) inline bool IsEnabled(T)
{ {
static const bool result = olCompile::IsEnvvarValueEnabled(T::value()); static const bool result = online_compile::IsEnvvarValueEnabled(T::value());
return result; return result;
} }
template <class T> template <class T>
inline bool IsDisabled(T) inline bool IsDisabled(T)
{ {
static const bool result = olCompile::IsEnvvarValueDisabled(T::value()); static const bool result = online_compile::IsEnvvarValueDisabled(T::value());
return result; return result;
} }
template <class T> template <class T>
inline unsigned long int Value(T, unsigned long int fallback = 0) inline unsigned long int Value(T, unsigned long int fallback = 0)
{ {
static const auto result = olCompile::EnvvarValue(T::value(), fallback); static const auto result = online_compile::EnvvarValue(T::value(), fallback);
return result; return result;
} }
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -30,13 +30,13 @@
#include <ostream> #include <ostream>
#include <string> #include <string>
namespace olCompile { namespace online_compile {
namespace exec { namespace exec {
/// Redirecting both input and output is not supported. /// Redirecting both input and output is not supported.
int Run(const std::string& p, std::istream* in, std::ostream* out); int Run(const std::string& p, std::istream* in, std::ostream* out);
} // namespace exec } // namespace exec
} // namespace olCompile } // namespace online_compile
#endif // EXEC_UTILS_HPP #endif // EXEC_UTILS_HPP

View File

@@ -40,7 +40,7 @@
#include <vector> #include <vector>
#include <unordered_map> #include <unordered_map>
namespace olCompile { namespace online_compile {
struct HandleImpl; struct HandleImpl;
@@ -140,6 +140,6 @@ struct Handle
inline std::ostream& operator<<(std::ostream& os, const Handle& handle) { return handle.Print(os); } inline std::ostream& operator<<(std::ostream& os, const Handle& handle) { return handle.Print(os); }
} // namespace olCompile } // namespace online_compile
#endif // GUARD_OLC_HANDLE_HPP_ #endif // GUARD_OLC_HANDLE_HPP_

View File

@@ -31,9 +31,9 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <string> #include <string>
namespace olCompile { namespace online_compile {
boost::filesystem::path HipBuild(boost::optional<olCompile::TmpDir>& tmp_dir, boost::filesystem::path HipBuild(boost::optional<online_compile::TmpDir>& tmp_dir,
const std::string& filename, const std::string& filename,
std::string src, std::string src,
std::string params, std::string params,
@@ -92,6 +92,6 @@ class LcOptionTargetStrings
} }
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -36,7 +36,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
namespace olCompile { namespace online_compile {
using HipEventPtr = OLC_MANAGE_PTR(hipEvent_t, hipEventDestroy); using HipEventPtr = OLC_MANAGE_PTR(hipEvent_t, hipEventDestroy);
inline HipEventPtr make_hip_event() inline HipEventPtr make_hip_event()
@@ -169,6 +169,6 @@ struct HIPOCKernel
std::function<void(hipEvent_t, hipEvent_t)> callback = nullptr) const; std::function<void(hipEvent_t, hipEvent_t)> callback = nullptr) const;
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -33,7 +33,7 @@
#include <hip/hip_runtime_api.h> #include <hip/hip_runtime_api.h>
#include <string> #include <string>
namespace olCompile { namespace online_compile {
struct HIPOCProgramImpl; struct HIPOCProgramImpl;
struct HIPOCProgram struct HIPOCProgram
@@ -59,6 +59,6 @@ struct HIPOCProgram
/// False if CO resides on filesystem. /// False if CO resides on filesystem.
bool IsCodeObjectInMemory() const; bool IsCodeObjectInMemory() const;
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -33,7 +33,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <hip/hip_runtime_api.h> #include <hip/hip_runtime_api.h>
namespace olCompile { namespace online_compile {
using hipModulePtr = OLC_MANAGE_PTR(hipModule_t, hipModuleUnload); using hipModulePtr = OLC_MANAGE_PTR(hipModule_t, hipModuleUnload);
@@ -57,5 +57,5 @@ struct HIPOCProgramImpl
BuildCodeObjectInFile(std::string& params, const std::string& src, const std::string& filename); BuildCodeObjectInFile(std::string& params, const std::string& src, const std::string& filename);
void BuildCodeObject(std::string params); void BuildCodeObject(std::string params);
}; };
} // namespace olCompile } // namespace online_compile
#endif // GUARD_OLC_HIPOC_PROGRAM_IMPL_HPP #endif // GUARD_OLC_HIPOC_PROGRAM_IMPL_HPP

View File

@@ -30,7 +30,7 @@
#include <vector> #include <vector>
#include <hipoc_kernel.hpp> #include <hipoc_kernel.hpp>
namespace olCompile { namespace online_compile {
std::string GetKernelSrc(std::string name); std::string GetKernelSrc(std::string name);
std::string GetKernelInc(std::string key); std::string GetKernelInc(std::string key);
std::vector<std::string> GetKernelIncList(); std::vector<std::string> GetKernelIncList();
@@ -40,6 +40,6 @@ using Kernel = HIPOCKernel;
using KernelInvoke = HIPOCKernelInvoke; using KernelInvoke = HIPOCKernelInvoke;
using Program = HIPOCProgram; using Program = HIPOCProgram;
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -32,7 +32,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace olCompile { namespace online_compile {
namespace kbp { namespace kbp {
struct Option struct Option
@@ -132,6 +132,6 @@ class KernelBuildParameters
} }
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -49,7 +49,7 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
namespace olCompile { namespace online_compile {
/** /**
* @brief The KernelCache class Build and cache kernels * @brief The KernelCache class Build and cache kernels
@@ -92,6 +92,6 @@ class KernelCache
ProgramMap program_map; ProgramMap program_map;
}; };
} // namespace olCompile } // namespace online_compile
#endif // GUARD_OLC_KERNEL_CACHE_HPP_ #endif // GUARD_OLC_KERNEL_CACHE_HPP_

View File

@@ -3,7 +3,7 @@
#include <fstream> #include <fstream>
namespace olCompile { namespace online_compile {
enum class LogLevel enum class LogLevel
{ {
@@ -18,6 +18,6 @@ std::ostream& fdt_log(LogLevel level, const char* header, const char* content);
std::ostream& fdt_log(); std::ostream& fdt_log();
void fdt_log_flush(); void fdt_log_flush();
}; // namespace olCompile }; // namespace online_compile
#endif #endif

View File

@@ -29,7 +29,7 @@
#include <memory> #include <memory>
#include <type_traits> #include <type_traits>
namespace olCompile { namespace online_compile {
template <class F, F f> template <class F, F f>
struct manage_deleter struct manage_deleter
@@ -68,9 +68,9 @@ using remove_ptr = typename std::
template <class T> template <class T>
using shared = std::shared_ptr<remove_ptr<T>>; using shared = std::shared_ptr<remove_ptr<T>>;
} // namespace olCompile } // namespace online_compile
#define OLC_MANAGE_PTR(T, F) \ #define OLC_MANAGE_PTR(T, F) \
olCompile::manage_ptr<typename std::remove_pointer<T>::type, decltype(&F), &F> // NOLINT online_compile::manage_ptr<typename std::remove_pointer<T>::type, decltype(&F), &F> // NOLINT
#endif #endif

View File

@@ -3,10 +3,10 @@
#include <string> #include <string>
namespace olCompile { namespace online_compile {
std::string md5(std::string s); std::string md5(std::string s);
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -6,6 +6,9 @@
#include <half.hpp> #include <half.hpp>
#include <boost/container/small_vector.hpp> #include <boost/container/small_vector.hpp>
namespace online_compile {
struct OpKernelArg struct OpKernelArg
{ {
@@ -32,4 +35,6 @@ struct OpKernelArg
bool is_ptr = false; bool is_ptr = false;
}; };
} // namespace online_compile
#endif #endif

View File

@@ -29,7 +29,7 @@
#include <string> #include <string>
namespace olCompile { namespace online_compile {
struct SimpleHash struct SimpleHash
{ {
size_t operator()(const std::pair<std::string, std::string>& p) const size_t operator()(const std::pair<std::string, std::string>& p) const
@@ -39,6 +39,6 @@ struct SimpleHash
} }
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -36,7 +36,7 @@
#define OLC_STRINGIZE_1(...) #__VA_ARGS__ #define OLC_STRINGIZE_1(...) #__VA_ARGS__
#define OLC_STRINGIZE(...) OLC_STRINGIZE_1(__VA_ARGS__) #define OLC_STRINGIZE(...) OLC_STRINGIZE_1(__VA_ARGS__)
namespace olCompile { namespace online_compile {
inline std::string inline std::string
ReplaceString(std::string subject, const std::string& search, const std::string& replace) ReplaceString(std::string subject, const std::string& search, const std::string& replace)
@@ -128,6 +128,6 @@ inline std::vector<std::string> SplitSpaceSeparated(const std::string& in,
return rv; return rv;
} }
} // namespace olCompile } // namespace online_compile
#endif // GUARD_OLC_STRINGUTILS_HPP #endif // GUARD_OLC_STRINGUTILS_HPP

View File

@@ -29,7 +29,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <string> #include <string>
namespace olCompile { namespace online_compile {
struct Handle; struct Handle;
@@ -51,6 +51,6 @@ struct TargetProperties
boost::optional<bool> sramecc_reported = boost::none; boost::optional<bool> sramecc_reported = boost::none;
}; };
} // namespace olCompile } // namespace online_compile
#endif // GUARD_OLC_TARGET_PROPERTIES_HPP #endif // GUARD_OLC_TARGET_PROPERTIES_HPP

View File

@@ -4,7 +4,7 @@
#include <string> #include <string>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
namespace olCompile { namespace online_compile {
void SystemCmd(std::string cmd); void SystemCmd(std::string cmd);
@@ -21,6 +21,6 @@ struct TmpDir
~TmpDir(); ~TmpDir();
}; };
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -5,7 +5,7 @@
#include <manage_ptr.hpp> #include <manage_ptr.hpp>
#include <fstream> #include <fstream>
namespace olCompile { namespace online_compile {
using FilePtr = OLC_MANAGE_PTR(FILE*, std::fclose); using FilePtr = OLC_MANAGE_PTR(FILE*, std::fclose);
@@ -25,6 +25,6 @@ inline void WriteFile(const std::vector<char>& content, const boost::filesystem:
throw std::runtime_error("Failed to write to file"); throw std::runtime_error("Failed to write to file");
} }
} // namespace olCompile } // namespace online_compile
#endif #endif

View File

@@ -31,7 +31,7 @@
${KERNELS_DECLS} ${KERNELS_DECLS}
// clang-format on // clang-format on
namespace olCompile { namespace online_compile {
const std::map<std::string, std::string>& kernels() const std::map<std::string, std::string>& kernels()
{ {
@@ -67,4 +67,4 @@ std::string GetKernelSrc(std::string name)
return it->second; return it->second;
} }
} // namespace olCompile } // namespace online_compile

View File

@@ -29,7 +29,7 @@
#include <stdexcept> #include <stdexcept>
#include <vector> #include <vector>
namespace olCompile { namespace online_compile {
static inline bool EndsWith(const std::string& value, const std::string& suffix) static inline bool EndsWith(const std::string& value, const std::string& suffix)
{ {
@@ -77,4 +77,4 @@ std::vector<std::string> GetHipKernelIncList()
return keys; return keys;
} }
} // namespace olCompile } // namespace online_compile