Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove_if called without erase #194

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
9 changes: 8 additions & 1 deletion scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import errno
import logging
import os
import platform
import shutil
import signal
import subprocess
Expand Down Expand Up @@ -231,14 +232,20 @@ 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:
shell = True
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:
Expand Down
26 changes: 17 additions & 9 deletions scripts/gen_test_makefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import argparse
import logging
import os
import platform
import sys
import re

Expand All @@ -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:"
Expand Down Expand Up @@ -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:
Expand All @@ -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]
Expand Down Expand Up @@ -333,15 +341,15 @@ 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 != "":
optflags_str += " " + target.specs.arch_prefix + target.arch.comp_name
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"
Expand All @@ -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)
Expand All @@ -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:[email protected] -c $<"
if source_name == "func":
output += " $(STATFLAGS) "
if inject_blame_opt is not None:
Expand Down
5 changes: 5 additions & 0 deletions scripts/run_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import multiprocessing
import multiprocessing.managers
import os
import platform
import platform
import re
import shutil
import stat
Expand Down Expand Up @@ -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")
Expand Down
66 changes: 66 additions & 0 deletions scripts/test_sets_win.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/gen_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ void GenPolicy::uniformProbFromMax(std::vector<Probability<T>> &distr,

template <class T, class U>
void GenPolicy::removeProbability(std::vector<Probability<T>> &orig, U id) {
std::remove_if(
auto new_end = std::remove_if(
orig.begin(), orig.end(),
[&id](Probability<T> &elem) -> bool { return elem.getId() == id; });
orig.erase(new_end, orig.end());
}
2 changes: 1 addition & 1 deletion src/stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void LoopNestStmt::populate(std::shared_ptr<PopulateCtx> ctx) {
auto gen_pol = ctx->getGenPolicy();
auto new_ctx = std::make_shared<PopulateCtx>(ctx);
bool old_ctx_state = new_ctx->isTaken();
std::vector<std::shared_ptr<LoopHead>>::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) {
Expand Down
Loading