SWDEV-470698 - fix formatting, add format check workflow (#657)

This commit is contained in:
Danylo Lytovchenko
2025-08-20 16:28:06 +02:00
committato da GitHub
parent 5840940caa
commit f7338717ae
1574 ha cambiato i file con 162972 aggiunte e 199346 eliminazioni
@@ -64,8 +64,7 @@ parameters of the respective block name.
#pragma clang diagnostic ignored "-Wunused-but-set-variable"
std::vector<std::string> get_combi_string_vec() {
picojson::array combi_string = get_array_parameters("Combi_CO",
"all_compier_options");
picojson::array combi_string = get_array_parameters("Combi_CO", "all_compier_options");
std::vector<std::string> combi_string_list;
for (auto& indx : combi_string) {
combi_string_list.push_back(indx.get<std::string>());
@@ -78,14 +77,12 @@ int split_comb_string(std::string option) {
int start_index = 0;
std::vector<std::string> combi_block_name;
while (start_collon_index != std::string::npos) {
std::string singleoption = option.substr(start_index,
start_collon_index - start_index);
std::string singleoption = option.substr(start_index, start_collon_index - start_index);
combi_block_name.push_back(singleoption);
start_index = start_collon_index + 1;
start_collon_index = option.find(':', start_index);
}
std::string last_option = option.substr(start_index,
option.length() - start_index);
std::string last_option = option.substr(start_index, option.length() - start_index);
combi_block_name.push_back(last_option);
return calling_combination_function(combi_block_name);
}
@@ -96,25 +93,22 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
int max_thread_position;
std::vector<std::string> hold_CO(combi_size, "");
const char** Combination_CO = new const char*[combi_size];
picojson::array undef_compiler_option = get_array_parameters(
"compiler_option", "undef_macro");
picojson::array undef_compiler_option = get_array_parameters("compiler_option", "undef_macro");
std::vector<std::string> undef_CO_vec;
for (auto& indx : undef_compiler_option) {
undef_CO_vec.push_back(indx.get<std::string>());
}
for (int i=0; i< combi_size; i++) {
for (int i = 0; i < combi_size; i++) {
if (combi_vec_list[i] == "max_thread") {
std::string ready_CO = get_string_parameters("ready_compiler_option",
combi_vec_list[i]);
std::string ready_CO = get_string_parameters("ready_compiler_option", combi_vec_list[i]);
hold_CO[i] = ready_CO;
if (combi_vec_list[i] == "max_thread") {
max_thread_position = i;
}
} else if (combi_vec_list[i] == "header_dir") {
std::string retrived_CO = get_string_parameters("compiler_option",
"header_dir");
std::string retrived_CO = get_string_parameters("compiler_option", "header_dir");
std::string str = "pwd";
const char *cmd = str.c_str();
const char* cmd = str.c_str();
CaptureStream capture(stdout);
capture.Begin();
system(cmd);
@@ -125,33 +119,26 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
std::string CO = retrived_CO + " " + break_dir + append_str;
hold_CO[i] = CO;
} else if (combi_vec_list[i] == "architecture") {
std::string retrived_CO = get_string_parameters("compiler_option",
"architecture");
std::string retrived_CO = get_string_parameters("compiler_option", "architecture");
hipDeviceProp_t prop;
HIP_CHECK(hipGetDeviceProperties(&prop, 0));
std::string actual_architecture = prop.gcnArchName;
std::string complete_CO = retrived_CO + actual_architecture;
hold_CO[i] = complete_CO;
} else if (check_positive_CO_present(combi_vec_list[i]) == 1) {
std::string positive_CO = get_string_parameters("compiler_option",
combi_vec_list[i]);
std::string positive_CO = get_string_parameters("compiler_option", combi_vec_list[i]);
hold_CO[i] = positive_CO;
if (combi_vec_list[i] == "fast_math")
fast_math_present = 1;
if (combi_vec_list[i] == "fast_math") fast_math_present = 1;
} else if (check_negative_CO_present(combi_vec_list[i]) == 1) {
std::string split_block_name = combi_vec_list[i].substr(3,
combi_vec_list[i].length() - 3);
std::string negative_CO = get_string_parameters(
"reverse_compiler_option", split_block_name);
std::string split_block_name = combi_vec_list[i].substr(3, combi_vec_list[i].length() - 3);
std::string negative_CO = get_string_parameters("reverse_compiler_option", split_block_name);
hold_CO[i] = negative_CO;
if (split_block_name == "fast_math")
fast_math_present = 0;
} else if ( combi_vec_list[i] == "conversion_error"
|| combi_vec_list[i] == "conversion_no_error"
|| combi_vec_list[i] == "conversion_no_warning"
|| combi_vec_list[i] == "conversion_warning") {
picojson::array compiler_option = get_array_parameters("compiler_option",
"error");
if (split_block_name == "fast_math") fast_math_present = 0;
} else if (combi_vec_list[i] == "conversion_error" ||
combi_vec_list[i] == "conversion_no_error" ||
combi_vec_list[i] == "conversion_no_warning" ||
combi_vec_list[i] == "conversion_warning") {
picojson::array compiler_option = get_array_parameters("compiler_option", "error");
std::vector<std::string> CO_vec;
for (auto& indx : compiler_option) {
CO_vec.push_back(indx.get<std::string>());
@@ -165,12 +152,10 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
} else if (combi_vec_list[i] == "conversion_no_warning") {
hold_CO[i] = CO_vec[3];
}
} else if (combi_vec_list[i] == "off_ffp_contract"
|| combi_vec_list[i] == "on_ffp_contract"
|| combi_vec_list[i] == "fast_ffp_contract"
|| combi_vec_list[i] == "pragmas_ffp_contract") {
picojson::array compiler_option = get_array_parameters("compiler_option",
"ffp_contract");
} else if (combi_vec_list[i] == "off_ffp_contract" || combi_vec_list[i] == "on_ffp_contract" ||
combi_vec_list[i] == "fast_ffp_contract" ||
combi_vec_list[i] == "pragmas_ffp_contract") {
picojson::array compiler_option = get_array_parameters("compiler_option", "ffp_contract");
std::vector<std::string> CO_vec;
for (auto& indx : compiler_option) {
CO_vec.push_back(indx.get<std::string>());
@@ -184,7 +169,7 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
} else if (combi_vec_list[i] == "pragmas_ffp_contract") {
hold_CO[i] = CO_vec[3];
}
} else if (combi_vec_list[i] =="undef_macro") {
} else if (combi_vec_list[i] == "undef_macro") {
hold_CO[i] = undef_CO_vec[1].c_str();
undef_present = 1;
} else {
@@ -193,10 +178,10 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
Combination_CO[i] = hold_CO[i].c_str();
}
int errors = 0;
for (int j = 0; j< combi_size; j++) {
for (int j = 0; j < combi_size; j++) {
std::string block_name = combi_vec_list[j].c_str();
if (!calling_resp_function(block_name, Combination_CO, combi_size,
max_thread_position, fast_math_present)) {
if (!calling_resp_function(block_name, Combination_CO, combi_size, max_thread_position,
fast_math_present)) {
errors++;
}
Combination_CO[j] = hold_CO[j].c_str();
@@ -205,171 +190,134 @@ int calling_combination_function(std::vector<std::string> combi_vec_list) {
}
int check_positive_CO_present(std::string find_string) {
static std::vector<std::string> positive_CO = {"macro", "warning", "rdc",
"denormals", "fp32_div_sqrt",
"Rpass_inline", "fast_math",
"slp_vectorize",
"amdgpu_ieee",
"unsafe_atomic",
"infinite_num", "NAN_num",
"slp_vectorize", "math_errno",
"associative_math",
"signed_zeros", "finite_math",
"trapping_math"};
if (std::find(positive_CO.begin(), positive_CO.end(),
find_string) != positive_CO.end())
static std::vector<std::string> positive_CO = {
"macro", "warning", "rdc", "denormals", "fp32_div_sqrt",
"Rpass_inline", "fast_math", "slp_vectorize", "amdgpu_ieee", "unsafe_atomic",
"infinite_num", "NAN_num", "slp_vectorize", "math_errno", "associative_math",
"signed_zeros", "finite_math", "trapping_math"};
if (std::find(positive_CO.begin(), positive_CO.end(), find_string) != positive_CO.end())
return 1;
else
return 0;
}
int check_negative_CO_present(std::string find_string) {
static std::vector<std::string> negative_CO = {"no_fast_math",
"no_fp32_div_sqrt",
"no_denormals",
"no_slp_vectorize",
"no_amdgpu_ieee",
"no_unsafe_atomic",
"no_infinite_num",
"no_slp_vectorize",
"no_NAN_num",
"no_math_errno",
"no_associative_math",
"no_signed_zeros",
"no_finite_math",
"no_trapping_math"};
if (std::find(negative_CO.begin(), negative_CO.end(),
find_string) != negative_CO.end())
static std::vector<std::string> negative_CO = {
"no_fast_math", "no_fp32_div_sqrt", "no_denormals", "no_slp_vectorize",
"no_amdgpu_ieee", "no_unsafe_atomic", "no_infinite_num", "no_slp_vectorize",
"no_NAN_num", "no_math_errno", "no_associative_math", "no_signed_zeros",
"no_finite_math", "no_trapping_math"};
if (std::find(negative_CO.begin(), negative_CO.end(), find_string) != negative_CO.end())
return 1;
else
return 0;
}
bool calling_resp_function(const std::string block_name,
const char** Combination_CO,
bool calling_resp_function(const std::string block_name, const char** Combination_CO,
int Combination_CO_size, int max_thread_position,
int fast_math_present) {
if (block_name == "max_thread") {
return check_max_thread(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_max_thread(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "architecture") {
return check_architecture(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_architecture(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "rdc") {
return check_rdc(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_rdc(Combination_CO, Combination_CO_size, max_thread_position, fast_math_present);
} else if (block_name == "denormals") {
return check_denormals_enabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_denormals_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_denormals") {
return check_denormals_disabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_denormals_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "warning") {
return check_warning(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_warning(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "conversion_error") {
return check_conversionerror_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_conversionerror_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "conversion_no_error") {
return check_conversionerror_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_conversionerror_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "conversion_warning") {
return check_conversionwarning_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_conversionwarning_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "conversion_no_warning") {
return check_conversionwarning_disabled(Combination_CO,
Combination_CO_size,
max_thread_position,
fast_math_present);
return check_conversionwarning_disabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
} else if (block_name == "Rpass_inline") {
return check_Rpass_inline(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_Rpass_inline(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "macro") {
return check_macro(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_macro(Combination_CO, Combination_CO_size, max_thread_position, fast_math_present);
} else if (block_name == "undef_macro") {
return check_undef_macro(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_undef_macro(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "header_dir") {
return check_header_dir(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_header_dir(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_fast_math") {
return check_fast_math_disabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_fast_math_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "fast_math") {
return check_fast_math_enabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_fast_math_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "off_ffp_contract") {
return check_ffp_contract_off(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_ffp_contract_off(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "on_ffp_contract") {
return check_ffp_contract_on(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_ffp_contract_on(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "fast_ffp_contract") {
return check_ffp_contract_fast(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_ffp_contract_fast(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_unsafe_atomic") {
return check_unsafe_atomic_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_unsafe_atomic_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "unsafe_atomic") {
return check_unsafe_atomic_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_unsafe_atomic_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_slp_vectorize") {
return check_slp_vectorize_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_slp_vectorize_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "slp_vectorize") {
return check_slp_vectorize_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_slp_vectorize_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "infinite_num") {
return check_infinite_num_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_infinite_num_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_infinite_num") {
return check_infinite_num_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_infinite_num_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "NAN_num") {
return check_NAN_num_enabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_NAN_num_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_NAN_num") {
return check_NAN_num_disabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_NAN_num_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "finite_math") {
return check_finite_math_enabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_finite_math_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_finite_math") {
return check_finite_math_disabled(Combination_CO, Combination_CO_size,
max_thread_position, fast_math_present);
return check_finite_math_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "associative_math") {
return check_associative_math_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_associative_math_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_associative_math") {
return check_associative_math_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_associative_math_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "signed_zeros") {
return check_signed_zeros_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_signed_zeros_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_signed_zeros") {
return check_signed_zeros_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_signed_zeros_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "trapping_math") {
return check_trapping_math_enabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_trapping_math_enabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else if (block_name == "no_trapping_math") {
return check_trapping_math_disabled(Combination_CO, Combination_CO_size,
max_thread_position,
return check_trapping_math_disabled(Combination_CO, Combination_CO_size, max_thread_position,
fast_math_present);
} else {
WARN("BLOCK NAME '" << block_name << "' not found");
@@ -379,7 +327,7 @@ bool calling_resp_function(const std::string block_name,
picojson::array getblock_fromconfig() {
std::string str = "pwd";
const char *cmd = str.c_str();
const char* cmd = str.c_str();
CaptureStream capture(stdout);
capture.Begin();
system(cmd);
@@ -395,7 +343,7 @@ picojson::array getblock_fromconfig() {
exit(0);
}
std::string json_str((std::istreambuf_iterator<char>(json_file)),
std::istreambuf_iterator<char>());
std::istreambuf_iterator<char>());
picojson::value v;
std::string err = picojson::parse(v, json_str);
if (!err.empty()) {
@@ -406,8 +354,7 @@ picojson::array getblock_fromconfig() {
return blocks;
}
std::string get_string_parameters(std::string para_name_to_retrieve,
std::string block_name) {
std::string get_string_parameters(std::string para_name_to_retrieve, std::string block_name) {
std::string returnValue = "";
picojson::array blocks = getblock_fromconfig();
for (picojson::value& block : blocks) {
@@ -415,23 +362,19 @@ std::string get_string_parameters(std::string para_name_to_retrieve,
std::string blk_name = block_obj.at("block_name").get<std::string>();
if (blk_name == block_name) {
if (para_name_to_retrieve == "compiler_option") {
std::string compiler_opt =
block_obj.at("compiler_option").get<std::string>();
std::string compiler_opt = block_obj.at("compiler_option").get<std::string>();
returnValue += compiler_opt;
} else if (para_name_to_retrieve == "Target_Vals") {
std::string Target_Vals =
block_obj.at("Target_Vals").get<std::string>();
std::string Target_Vals = block_obj.at("Target_Vals").get<std::string>();
returnValue += Target_Vals;
} else if (para_name_to_retrieve == "kernel_name") {
std::string ker_name = block_obj.at("kernel_name").get<std::string>();
returnValue += ker_name;
} else if (para_name_to_retrieve == "reverse_compiler_option") {
std::string reverse =
block_obj.at("reverse_compiler_option").get<std::string>();
std::string reverse = block_obj.at("reverse_compiler_option").get<std::string>();
returnValue += reverse;
} else if (para_name_to_retrieve == "ready_compiler_option") {
std::string ready_CO =
block_obj.at("ready_compiler_option").get<std::string>();
std::string ready_CO = block_obj.at("ready_compiler_option").get<std::string>();
returnValue += ready_CO;
} else {
WARN("REQUESTED FIELD not present : " << para_name_to_retrieve);
@@ -443,8 +386,7 @@ std::string get_string_parameters(std::string para_name_to_retrieve,
return returnValue;
}
picojson::array get_array_parameters(std::string para_name_to_retrieve,
std::string block_name) {
picojson::array get_array_parameters(std::string para_name_to_retrieve, std::string block_name) {
std::string returnValue = "";
picojson::array blocks = getblock_fromconfig();
for (picojson::value& block : blocks) {
@@ -452,48 +394,40 @@ picojson::array get_array_parameters(std::string para_name_to_retrieve,
std::string blk_name = block_obj.at("block_name").get<std::string>();
if (blk_name == block_name) {
if (para_name_to_retrieve == "Target_Vals") {
picojson::array& Target_Vals =
block_obj.at("Target_Vals").get<picojson::array>();
picojson::array& Target_Vals = block_obj.at("Target_Vals").get<picojson::array>();
return Target_Vals;
} else if (para_name_to_retrieve == "single_CO") {
picojson::array& single_CO =
block_obj.at("single_CO").get<picojson::array>();
picojson::array& single_CO = block_obj.at("single_CO").get<picojson::array>();
return single_CO;
} else if (para_name_to_retrieve == "Combi_CO") {
picojson::array& Combi_CO =
block_obj.at("Combi_CO").get<picojson::array>();
picojson::array& Combi_CO = block_obj.at("Combi_CO").get<picojson::array>();
return Combi_CO;
} else if (para_name_to_retrieve == "Input_Vals") {
picojson::array& Input_Vals =
block_obj.at("Input_Vals").get<picojson::array>();
picojson::array& Input_Vals = block_obj.at("Input_Vals").get<picojson::array>();
return Input_Vals;
} else if (para_name_to_retrieve == "Expected_Results") {
picojson::array& Expected =
block_obj.at("Expected_Results").get<picojson::array>();
picojson::array& Expected = block_obj.at("Expected_Results").get<picojson::array>();
return Expected;
} else if (para_name_to_retrieve == "Expected_Results_for_no") {
picojson::array& Expected_for_no =
block_obj.at("Expected_Results_for_no").get<picojson::array>();
block_obj.at("Expected_Results_for_no").get<picojson::array>();
return Expected_for_no;
} else if (para_name_to_retrieve == "compiler_option") {
picojson::array& compiler_option =
block_obj.at("compiler_option").get<picojson::array>();
picojson::array& compiler_option = block_obj.at("compiler_option").get<picojson::array>();
return compiler_option;
} else if (para_name_to_retrieve == "reverse_compiler_option") {
picojson::array& reverse_compiler_option =
block_obj.at("reverse_compiler_option").get<picojson::array>();
block_obj.at("reverse_compiler_option").get<picojson::array>();
return reverse_compiler_option;
} else if (para_name_to_retrieve == "Headers") {
picojson::array& Headers =
block_obj.at("Headers").get<picojson::array>();
picojson::array& Headers = block_obj.at("Headers").get<picojson::array>();
return Headers;
} else if (para_name_to_retrieve == "Src_headers") {
picojson::array& Src_headers =
block_obj.at("Src_headers").get<picojson::array>();
picojson::array& Src_headers = block_obj.at("Src_headers").get<picojson::array>();
return Src_headers;
} else if (para_name_to_retrieve == "depending_comp_optn") {
picojson::array& depending_comp_optn =
block_obj.at("depending_comp_optn").get<picojson::array>();
block_obj.at("depending_comp_optn").get<picojson::array>();
return depending_comp_optn;
} else {
WARN("REQUESTED FIELD not present : " << para_name_to_retrieve);