SWDEV-528351 - Clean up hipJitOptions (#439)
This commit is contained in:
committed by
GitHub
parent
da61c5d1da
commit
0d9428135c
@@ -1119,12 +1119,6 @@ bool IsCompatibleWithGenericTarget(const std::string& coTarget, const std::strin
|
|||||||
std::vector<std::string> getLinkOptions(const LinkArguments& args) {
|
std::vector<std::string> getLinkOptions(const LinkArguments& args) {
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
|
|
||||||
{ // process optimization level
|
|
||||||
std::string opt("-O");
|
|
||||||
opt += std::to_string(args.optimization_level_);
|
|
||||||
res.push_back(opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto irArgCount = args.linker_ir2isa_args_count_;
|
const auto irArgCount = args.linker_ir2isa_args_count_;
|
||||||
if (irArgCount > 0) {
|
if (irArgCount > 0) {
|
||||||
res.reserve(irArgCount);
|
res.reserve(irArgCount);
|
||||||
@@ -1257,103 +1251,11 @@ bool LinkProgram::isLinkerValid(LinkProgram* link_program) {
|
|||||||
bool LinkProgram::AddLinkerOptions(unsigned int num_options, hipJitOption* options_ptr,
|
bool LinkProgram::AddLinkerOptions(unsigned int num_options, hipJitOption* options_ptr,
|
||||||
void** options_vals_ptr) {
|
void** options_vals_ptr) {
|
||||||
for (size_t opt_idx = 0; opt_idx < num_options; ++opt_idx) {
|
for (size_t opt_idx = 0; opt_idx < num_options; ++opt_idx) {
|
||||||
if ( options_vals_ptr[opt_idx] == nullptr) {
|
if (options_vals_ptr[opt_idx] == nullptr) {
|
||||||
LogError("Options value can not be nullptr");
|
LogError("Options value can not be nullptr");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (options_ptr[opt_idx]) {
|
switch (options_ptr[opt_idx]) {
|
||||||
case hipJitOptionMaxRegisters:
|
|
||||||
link_args_.max_registers_ = *(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionThreadsPerBlock:
|
|
||||||
link_args_.threads_per_block_ =
|
|
||||||
*(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionWallTime:
|
|
||||||
link_args_.wall_time_ = *(reinterpret_cast<long*>(options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionInfoLogBuffer: {
|
|
||||||
link_args_.info_log_ = (reinterpret_cast<char*>(options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case hipJitOptionInfoLogBufferSizeBytes:
|
|
||||||
link_args_.info_log_size_ = (reinterpret_cast<size_t>(options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionErrorLogBuffer: {
|
|
||||||
link_args_.error_log_ = reinterpret_cast<char*>(options_vals_ptr[opt_idx]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case hipJitOptionErrorLogBufferSizeBytes:
|
|
||||||
link_args_.error_log_size_ = (reinterpret_cast<size_t>(options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionOptimizationLevel:
|
|
||||||
link_args_.optimization_level_ =
|
|
||||||
*(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionTargetFromContext:
|
|
||||||
link_args_.target_from_hip_context_ =
|
|
||||||
*(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionTarget:
|
|
||||||
link_args_.jit_target_ = *(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionFallbackStrategy:
|
|
||||||
link_args_.fallback_strategy_ =
|
|
||||||
*(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionGenerateDebugInfo:
|
|
||||||
link_args_.generate_debug_info_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionLogVerbose:
|
|
||||||
link_args_.log_verbose_ = reinterpret_cast<size_t>(options_vals_ptr[opt_idx]);
|
|
||||||
break;
|
|
||||||
case hipJitOptionGenerateLineInfo:
|
|
||||||
link_args_.generate_line_info_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionCacheMode:
|
|
||||||
link_args_.cache_mode_ = *(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionSm3xOpt:
|
|
||||||
link_args_.sm3x_opt_ = *(reinterpret_cast<bool*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionFastCompile:
|
|
||||||
link_args_.fast_compile_ = *(reinterpret_cast<bool*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionGlobalSymbolNames: {
|
|
||||||
link_args_.global_symbol_names_ = reinterpret_cast<const char**>(options_vals_ptr[opt_idx]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case hipJitOptionGlobalSymbolAddresses: {
|
|
||||||
link_args_.global_symbol_addresses_ = reinterpret_cast<void**>(options_vals_ptr[opt_idx]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case hipJitOptionGlobalSymbolCount:
|
|
||||||
link_args_.global_symbol_count_ =
|
|
||||||
*(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionLto:
|
|
||||||
link_args_.lto_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionFtz:
|
|
||||||
link_args_.ftz_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionPrecDiv:
|
|
||||||
link_args_.prec_div_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionPrecSqrt:
|
|
||||||
link_args_.prec_sqrt_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionFma:
|
|
||||||
link_args_.fma_ = *(reinterpret_cast<int*>(&options_vals_ptr[opt_idx]));
|
|
||||||
break;
|
|
||||||
case hipJitOptionPositionIndependentCode:
|
|
||||||
link_args_.pic_ = *(reinterpret_cast<int *>(&options_vals_ptr[opt_idx]));
|
|
||||||
case hipJitOptionMinCTAPerSM:
|
|
||||||
link_args_.min_cta_per_sm_ = *(reinterpret_cast<int *>(&options_vals_ptr[opt_idx]));
|
|
||||||
case hipJitOptionMaxThreadsPerBlock:
|
|
||||||
link_args_.max_threads_per_block_ = *(reinterpret_cast<int *>(&options_vals_ptr[opt_idx]));
|
|
||||||
case hipJitOptionOverrideDirectiveValues:
|
|
||||||
link_args_.override_directive_values_ = *(reinterpret_cast<int *>(&options_vals_ptr[opt_idx]));
|
|
||||||
case hipJitOptionIRtoISAOptExt: {
|
case hipJitOptionIRtoISAOptExt: {
|
||||||
link_args_.linker_ir2isa_args_ = reinterpret_cast<const char**>(options_vals_ptr[opt_idx]);
|
link_args_.linker_ir2isa_args_ = reinterpret_cast<const char**>(options_vals_ptr[opt_idx]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -82,70 +82,10 @@ bool IsCompatibleWithGenericTarget(const std::string& coTarget, const std::strin
|
|||||||
} // namespace helpers
|
} // namespace helpers
|
||||||
|
|
||||||
struct LinkArguments {
|
struct LinkArguments {
|
||||||
unsigned int max_registers_;
|
|
||||||
unsigned int threads_per_block_;
|
|
||||||
float wall_time_;
|
|
||||||
size_t info_log_size_;
|
|
||||||
char* info_log_;
|
|
||||||
size_t error_log_size_;
|
|
||||||
char* error_log_;
|
|
||||||
unsigned int optimization_level_;
|
|
||||||
unsigned int target_from_hip_context_;
|
|
||||||
unsigned int jit_target_;
|
|
||||||
unsigned int fallback_strategy_;
|
|
||||||
int generate_debug_info_;
|
|
||||||
long log_verbose_;
|
|
||||||
int generate_line_info_;
|
|
||||||
unsigned int cache_mode_;
|
|
||||||
bool sm3x_opt_;
|
|
||||||
bool fast_compile_;
|
|
||||||
const char** global_symbol_names_;
|
|
||||||
void** global_symbol_addresses_;
|
|
||||||
unsigned int global_symbol_count_;
|
|
||||||
int lto_;
|
|
||||||
int ftz_;
|
|
||||||
int prec_div_;
|
|
||||||
int prec_sqrt_;
|
|
||||||
int fma_;
|
|
||||||
int pic_;
|
|
||||||
int min_cta_per_sm_;
|
|
||||||
int max_threads_per_block_;
|
|
||||||
int override_directive_values_;
|
|
||||||
const char** linker_ir2isa_args_;
|
const char** linker_ir2isa_args_;
|
||||||
size_t linker_ir2isa_args_count_;
|
size_t linker_ir2isa_args_count_;
|
||||||
|
|
||||||
LinkArguments()
|
LinkArguments() : linker_ir2isa_args_{nullptr}, linker_ir2isa_args_count_{0} {}
|
||||||
: max_registers_{0},
|
|
||||||
threads_per_block_{0},
|
|
||||||
wall_time_{0.0f},
|
|
||||||
info_log_size_{0},
|
|
||||||
info_log_{nullptr},
|
|
||||||
error_log_size_{0},
|
|
||||||
error_log_{nullptr},
|
|
||||||
optimization_level_{3},
|
|
||||||
target_from_hip_context_{0},
|
|
||||||
jit_target_{0},
|
|
||||||
fallback_strategy_{0},
|
|
||||||
generate_debug_info_{0},
|
|
||||||
log_verbose_{0},
|
|
||||||
generate_line_info_{0},
|
|
||||||
cache_mode_{0},
|
|
||||||
sm3x_opt_{false},
|
|
||||||
fast_compile_{false},
|
|
||||||
global_symbol_names_{nullptr},
|
|
||||||
global_symbol_addresses_{nullptr},
|
|
||||||
global_symbol_count_{0},
|
|
||||||
lto_{0},
|
|
||||||
ftz_{0},
|
|
||||||
prec_div_{1},
|
|
||||||
prec_sqrt_{1},
|
|
||||||
fma_{1},
|
|
||||||
pic_{0},
|
|
||||||
min_cta_per_sm_{0},
|
|
||||||
max_threads_per_block_{0},
|
|
||||||
override_directive_values_{0},
|
|
||||||
linker_ir2isa_args_{nullptr},
|
|
||||||
linker_ir2isa_args_count_{0} {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RTCProgram {
|
class RTCProgram {
|
||||||
|
|||||||
@@ -1093,9 +1093,47 @@ hipError_t hipLinkCreate(unsigned int num_options, hipJitOption* options_ptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (num_options != 0) {
|
if (num_options != 0) {
|
||||||
for (int i = 0; i < num_options; i++) {
|
if (options_ptr == nullptr || options_vals_pptr == nullptr) {
|
||||||
if (options_ptr == nullptr || options_vals_pptr == nullptr) {
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
HIP_RETURN(hipErrorInvalidValue);
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < num_options; ++i) {
|
||||||
|
switch (options_ptr[i]) {
|
||||||
|
// CUDA only options
|
||||||
|
case hipJitOptionMaxRegisters:
|
||||||
|
case hipJitOptionThreadsPerBlock:
|
||||||
|
case hipJitOptionWallTime:
|
||||||
|
case hipJitOptionInfoLogBuffer:
|
||||||
|
case hipJitOptionInfoLogBufferSizeBytes:
|
||||||
|
case hipJitOptionErrorLogBuffer:
|
||||||
|
case hipJitOptionErrorLogBufferSizeBytes:
|
||||||
|
case hipJitOptionOptimizationLevel:
|
||||||
|
case hipJitOptionTargetFromContext:
|
||||||
|
case hipJitOptionTarget:
|
||||||
|
case hipJitOptionFallbackStrategy:
|
||||||
|
case hipJitOptionGenerateDebugInfo:
|
||||||
|
case hipJitOptionLogVerbose:
|
||||||
|
case hipJitOptionGenerateLineInfo:
|
||||||
|
case hipJitOptionCacheMode:
|
||||||
|
case hipJitOptionSm3xOpt:
|
||||||
|
case hipJitOptionFastCompile:
|
||||||
|
case hipJitOptionGlobalSymbolNames:
|
||||||
|
case hipJitOptionGlobalSymbolAddresses:
|
||||||
|
case hipJitOptionGlobalSymbolCount:
|
||||||
|
case hipJitOptionLto:
|
||||||
|
case hipJitOptionFtz:
|
||||||
|
case hipJitOptionPrecDiv:
|
||||||
|
case hipJitOptionPrecSqrt:
|
||||||
|
case hipJitOptionFma:
|
||||||
|
case hipJitOptionPositionIndependentCode:
|
||||||
|
case hipJitOptionMinCTAPerSM:
|
||||||
|
case hipJitOptionMaxThreadsPerBlock:
|
||||||
|
case hipJitOptionOverrideDirectiveValues:
|
||||||
|
case hipJitOptionNumOptions:
|
||||||
|
HIP_RETURN(hipErrorInvalidValue);
|
||||||
|
default:
|
||||||
|
// everything else is fine
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user