diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..614b903 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "run_gen", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/scripts/run_gen.py", + "args": [ + "--config-file", + "${workspaceFolder}/scripts/test_sets_win.txt", + "--target", + "msvc clangcl" + ], + "console": "integratedTerminal", + "justMyCode": true + } + ] +} \ No newline at end of file diff --git a/scripts/common.py b/scripts/common.py index 564adfc..27eb653 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -27,6 +27,7 @@ import errno import logging import os +import platform import shutil import signal import subprocess @@ -231,7 +232,7 @@ def check_dir_and_create(directory): print_and_exit("Can't use '" + norm_dir + "' directory") -def run_cmd(cmd, time_out=None, num=-1, memory_limit=None): +def run_cmd(cmd, time_out=None, num=-1, memory_limit=None, compilation_cmd=True): is_time_expired = False shell = False if memory_limit is not None: @@ -239,6 +240,12 @@ def run_cmd(cmd, time_out=None, num=-1, memory_limit=None): new_cmd = "ulimit -v " + str(memory_limit) + " ; " new_cmd += " ".join(i for i in cmd) cmd = new_cmd + if platform.system() == "Windows" and compilation_cmd: + shell = True + new_cmd = "\"/mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat\" ; " + new_cmd += " ".join(i for i in cmd) + cmd = new_cmd + start_time = os.times() with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True, shell=shell) as process: try: diff --git a/scripts/gen_test_makefile.py b/scripts/gen_test_makefile.py index a97e552..fee3d7e 100755 --- a/scripts/gen_test_makefile.py +++ b/scripts/gen_test_makefile.py @@ -23,6 +23,7 @@ import argparse import logging import os +import platform import sys import re @@ -31,9 +32,10 @@ Test_Makefile_name = "Test_Makefile" license_file_name = "LICENSE.txt" check_isa_file_name = "check_isa.cpp" -default_test_sets_file_name = "test_sets.txt" -default_config_file = "test_sets.txt" +default_test_sets_file_name = "test_sets_win.txt" if (platform.system() == "Windows") else "test_sets.txt" + +default_config_file = default_test_sets_file_name comp_specs_line = "Compiler specs:" spec_list_len = 5 test_sets_line = "Testing sets:" @@ -268,6 +270,8 @@ def parse_config(file_name): def detect_native_arch(): check_isa_file = os.path.abspath(common.yarpgen_scripts + os.sep + check_isa_file_name) check_isa_binary = os.path.abspath(common.yarpgen_scripts + os.sep + check_isa_file_name.replace(".cpp", "")) + if (platform.system() == 'Windows'): + check_isa_binary += ".exe" sys_compiler = "" for key in CompilerSpecs.all_comp_specs: @@ -281,12 +285,16 @@ def detect_native_arch(): if not common.if_exec_exist(check_isa_binary): if not os.path.exists(check_isa_file): common.print_and_exit("Can't find " + check_isa_file) - ret_code, output, err_output, time_expired, elapsed_time = \ - common.run_cmd([sys_compiler, check_isa_file, "-o", check_isa_binary], None) + if (platform.system() == 'Windows'): + ret_code, output, err_output, time_expired, elapsed_time = \ + common.run_cmd([sys_compiler, check_isa_file, "/Fe:\""+check_isa_binary+"\""], None) + else: + ret_code, output, err_output, time_expired, elapsed_time = \ + common.run_cmd([sys_compiler, check_isa_file, "-o", check_isa_binary], None) if ret_code != 0: common.print_and_exit("Can't compile " + check_isa_file + ": " + str(err_output, "utf-8")) - ret_code, output, err_output, time_expired, elapsed_time = common.run_cmd([check_isa_binary], None) + ret_code, output, err_output, time_expired, elapsed_time = common.run_cmd(cmd=[check_isa_binary], time_out=None, compilation_cmd=False) if ret_code != 0: common.print_and_exit("Error while executing " + check_isa_binary) native_arch_str = str(output, "utf-8").split()[0] @@ -333,7 +341,7 @@ def gen_makefile(out_file_name, force, config_file, only_target=None, inject_bla compiler_name = target.specs.comp_c_name if common.selected_standard.is_cxx(): compiler_name = target.specs.comp_cxx_name - output += target.name + ": " + "COMPILER=" + compiler_name + "\n" + output += target.name + ": " + "COMPILER=\"" + compiler_name + "\"\n" optflags_str = target.name + ": " + "OPTFLAGS=" + target.args if target.arch.comp_name != "": @@ -341,7 +349,7 @@ def gen_makefile(out_file_name, force, config_file, only_target=None, inject_bla optflags_str += "\n" output += optflags_str # For performance reasons driver should always be compiled with -O0 - output += re.sub("-O\d", "-O0", (optflags_str.replace("OPTFLAGS", "DRIVER_OPTFLAGS"))) + output += re.sub("/O\d", "/O0", (optflags_str.replace("OPTFLAGS", "DRIVER_OPTFLAGS"))) if inject_blame_opt is not None: output += target.name + ": " + "BLAMEOPTS=" + inject_blame_opt + "\n" @@ -358,7 +366,7 @@ def gen_makefile(out_file_name, force, config_file, only_target=None, inject_bla output += "$(SOURCES:" + common.get_file_ext() + "=.o))\n" else: output += "$(patsubst %.ispc,%.o," + "$(SOURCES:" + common.get_file_ext() + "=.o))" + ")\n" - output += "\t" + "$(COMPILER) $(LDFLAGS) $(STDFLAGS) $(OPTFLAGS) -o $(EXECUTABLE) $^\n\n" + output += "\t" + "$(COMPILER) $(LDFLAGS) $(STDFLAGS) $(OPTFLAGS) /Fe:$(EXECUTABLE).exe $^\n\n" if stat_targets is not None and len(stat_targets) != 0: common.log_msg(logging.WARNING, "Can't find relevant stat_targets: " + str(stat_targets), forced_duplication=True) @@ -377,7 +385,7 @@ def gen_makefile(out_file_name, force, config_file, only_target=None, inject_bla output += "%" + source_name + ".o: " + source_prefix + source + force_str # For performance reasons driver should always be compiled with -O0 optflags_name = "$(OPTFLAGS)" if source_name != "driver" else "$(DRIVER_OPTFLAGS)" - output += "\t" + "$(COMPILER) $(CXXFLAGS) $(STDFLAGS) " + optflags_name + " -o $@ -c $<" + output += "\t" + "$(COMPILER) $(CXXFLAGS) $(STDFLAGS) " + optflags_name + " /Fe:$@.exe -c $<" if source_name == "func": output += " $(STATFLAGS) " if inject_blame_opt is not None: diff --git a/scripts/run_gen.py b/scripts/run_gen.py index 03ad5d1..eebb686 100755 --- a/scripts/run_gen.py +++ b/scripts/run_gen.py @@ -29,6 +29,8 @@ import multiprocessing import multiprocessing.managers import os +import platform +import platform import re import shutil import stat @@ -1510,6 +1512,9 @@ def prepare_env_and_start_testing(out_dir, timeout, targets, num_jobs, config_fi # Check for binary of generator yarpgen_bin = os.path.abspath(common.yarpgen_scripts + os.sep + "yarpgen") + if (platform.system() == 'Windows') : + yarpgen_bin += ".exe" + common.check_and_copy(yarpgen_bin, out_dir) ret_code, output, err_output, time_expired, elapsed_time = common.run_cmd([yarpgen_bin, "-v"], yarpgen_timeout, 0) common.yarpgen_version_str = str(output, "utf-8") diff --git a/scripts/test_sets_win.txt b/scripts/test_sets_win.txt new file mode 100644 index 0000000..b665de9 --- /dev/null +++ b/scripts/test_sets_win.txt @@ -0,0 +1,66 @@ +############################################################################### +# +# Copyright (c) 2016-2023, Intel Corporation +# Copyright (c) 2019-2020, University of Utah +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +############################################################################### +# README: +# Testing configuration file +# You can start single-line comment with #. Don't use indentation at the beginning of line! +# Config can contain only one "Compiler specs" and "Testing sets" blocks! +# You should always specify "Compiler specs" before "Testing sets"! +############################################################################### + +Compiler specs: +# Spec name - codename for compiler and its options +# Executable name - name of compiler binary file. It should be in your PATH +# Common arguments - arguments which will be passed to every compiler run +# Arch prefix - prefix for specifying different architectures (it will be concatenated with Compiler arch value) + + +# Spec name | C++ executable name | C executable name | Common arguments | Arch prefix +msvc | /mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe | /mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe | | +clangcl | /mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe | /mnt/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe | | +#gcc | g++ | gcc | -fPIC -mcmodel=large -w -fpermissive | -march= +#clang | clang++ | clang | -fPIC -mcmodel=large -w -fopenmp-simd | -march= +#polly | clang++ | clang | -fPIC -mcmodel=large -w -fopenmp-simd -mllvm -polly -mllvm -polly-vectorizer=stripmine | -march= +# Ubsan is clang or gcc with sanitizer options. It is used for generator check. +# If you want to use sanitizer with -m32, please make sure that you pass "-rtlib=compiler-rt -lgcc_s" options if you are using clang. +# Otherwise it may fail with "undefined reference to `__mulodi4'" error message. +# See https://bugs.llvm.org//show_bug.cgi?id=16404 for more information +# Note that -fpermissive option for gcc is required to allow reduction of ubsan_gcc fails. +# Otherwise result of reduction is empty program. + +Testing sets: +# Set name - codename for testing set +# Spec name - codename of spec, it should be described in Compiler specs +# Arguments - compiler options for this testing set +# Compiler arch - architecture which will be passed to compiler +# Sde arch - architecture which will be passed to SDE + +# Set name | Spec name | Arguments | Compiler arch | Sde arch + +msvc_no_opt | msvc | | | +msvc_opt | msvc | /O2 | | +clangcl_no_opt | clangcl | | | +clangcl_opt | clangcl | /O2 | | +#gcc_no_opt | gcc | -O0 | | +#gcc_opt | gcc | -O3 | | + +#clang_no_opt | clang | -O0 | | +#clang_opt | clang | -O3 | | + +Options for statistics' capture: +#Spec name | Arguments diff --git a/src/gen_policy.cpp b/src/gen_policy.cpp index 432be8f..2f2e855 100644 --- a/src/gen_policy.cpp +++ b/src/gen_policy.cpp @@ -537,7 +537,8 @@ void GenPolicy::uniformProbFromMax(std::vector> &distr, template void GenPolicy::removeProbability(std::vector> &orig, U id) { - std::remove_if( + auto new_end = std::remove_if( orig.begin(), orig.end(), [&id](Probability &elem) -> bool { return elem.getId() == id; }); + orig.erase(new_end, orig.end()); } diff --git a/src/stmt.cpp b/src/stmt.cpp index 4048648..449facd 100644 --- a/src/stmt.cpp +++ b/src/stmt.cpp @@ -592,7 +592,7 @@ void LoopNestStmt::populate(std::shared_ptr ctx) { auto gen_pol = ctx->getGenPolicy(); auto new_ctx = std::make_shared(ctx); bool old_ctx_state = new_ctx->isTaken(); - std::vector>::iterator taken_switch_id; + auto taken_switch_id = loops.end(); auto simd_switch_id = loops.end(); auto mul_val_loop_idx = loops.end(); for (auto i = loops.begin(); i != loops.end(); ++i) {