From: Martin Quinson Date: Thu, 17 Mar 2022 20:19:06 +0000 (+0000) Subject: Merge branch 'add_semaphore_python_bindings' into 'master' X-Git-Tag: v3.31~58 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/992c3a8621f205aedc022a0d5a5d3fc7bb75e6a1?hp=f5ca2d068fb43ce1099d4a91d4a3710f55625a46 Merge branch 'add_semaphore_python_bindings' into 'master' Add Semaphore Python bindings See merge request simgrid/simgrid!91 --- diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index 82d16d8bb4..d090776c38 100644 --- a/include/simgrid/s4u/ConditionVariable.hpp +++ b/include/simgrid/s4u/ConditionVariable.hpp @@ -28,7 +28,7 @@ class XBT_PUBLIC ConditionVariable { private: #ifndef DOXYGEN friend kernel::activity::ConditionVariableImpl; - friend void kernel::activity::intrusive_ptr_release(kernel::activity::ConditionVariableImpl* cond); + friend XBT_PUBLIC void kernel::activity::intrusive_ptr_release(kernel::activity::ConditionVariableImpl* cond); #endif kernel::activity::ConditionVariableImpl* const pimpl_; diff --git a/include/simgrid/s4u/Mutex.hpp b/include/simgrid/s4u/Mutex.hpp index 8418ca9a44..cebeca7dc1 100644 --- a/include/simgrid/s4u/Mutex.hpp +++ b/include/simgrid/s4u/Mutex.hpp @@ -32,7 +32,7 @@ class XBT_PUBLIC Mutex { #ifndef DOXYGEN friend ConditionVariable; friend kernel::activity::MutexImpl; - friend void kernel::activity::intrusive_ptr_release(kernel::activity::MutexImpl* mutex); + friend XBT_PUBLIC void kernel::activity::intrusive_ptr_release(kernel::activity::MutexImpl* mutex); #endif kernel::activity::MutexImpl* const pimpl_; diff --git a/include/xbt/automaton.hpp b/include/xbt/automaton.hpp index 49d55f5492..8c4ac2e9b5 100644 --- a/include/xbt/automaton.hpp +++ b/include/xbt/automaton.hpp @@ -23,7 +23,7 @@ template xbt_automaton_propositional_symbol_t add_proposition(const_xb { auto* callback = new F(std::move(f)); return xbt_automaton_propositional_symbol_new_callback( - a, id, [](void* cb) -> int { return (*(F*)cb)(); }, callback, [](void* cb) -> void { delete (F*)cb; }); + a, id, [](auto* cb) -> int { return (*(F*)cb)(); }, callback, [](auto* cb) -> void { delete (F*)cb; }); } } diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 1bb1e36e5e..9509d49aa8 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -37,11 +37,10 @@ public: } void operator()() const { - const int argc = args_->size(); std::vector args = *args_; std::vector argv(args.size() + 1); // argv[argc] is nullptr std::transform(begin(args), end(args), begin(argv), [](std::string& s) { return &s.front(); }); - code_(argc, argv.data()); + code_(static_cast(args.size()), argv.data()); } }; diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index 9cebe1d918..48ce17e83c 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -238,7 +238,7 @@ template boost::optional Parmap::next() */ template void Parmap::work() { - unsigned length = common_data->size(); + unsigned length = static_cast(common_data->size()); unsigned index = common_index.fetch_add(1, std::memory_order_relaxed); while (index < length) { worker_fun((*common_data)[index]); diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 5edb48e4ec..68126bca04 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -90,7 +90,7 @@ public: // Support for the boost::intrusive_ptr datatype friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity); friend XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity); - int get_refcount() const { return refcount_; } // For debugging purpose + int get_refcount() const { return static_cast(refcount_); } // For debugging purpose static xbt::signal on_suspended; static xbt::signal on_resumed; diff --git a/src/kernel/activity/ExecImpl.hpp b/src/kernel/activity/ExecImpl.hpp index f69b6eea78..71331543e5 100644 --- a/src/kernel/activity/ExecImpl.hpp +++ b/src/kernel/activity/ExecImpl.hpp @@ -46,7 +46,7 @@ public: ExecImpl& set_thread_count(int thread_count); ExecImpl& set_hosts(const std::vector& hosts); - unsigned int get_host_number() const { return hosts_.size(); } + unsigned int get_host_number() const { return static_cast(hosts_.size()); } double get_seq_remaining_ratio(); double get_par_remaining_ratio(); double get_remaining() const override; diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index 9979c40e24..d822f6df1c 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -114,7 +114,7 @@ private: std::atomic_int_fast32_t refcount_{0}; public: - int get_refcount() const { return refcount_; } + int get_refcount() const { return static_cast(refcount_); } friend void intrusive_ptr_add_ref(ActorImpl* actor) { // This whole memory consistency semantic drives me nuts. diff --git a/src/kernel/resource/profile/Profile.cpp b/src/kernel/resource/profile/Profile.cpp index 342209403e..0f17aa7dd1 100644 --- a/src/kernel/resource/profile/Profile.cpp +++ b/src/kernel/resource/profile/Profile.cpp @@ -42,10 +42,9 @@ Event* Profile::schedule(FutureEvtSet* fes, resource::Resource* resource) cb(event_list); if(event_list.empty()) { - event->free_me = false; + event->free_me = true; + tmgr_trace_event_unref(&event); } else { - //FIXME: This is a bug, but keep old behaviour for now - //fes_->add_event(0, event); fes_->add_event(event_list[0].date_, event); } return event; diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp index bfd883ceac..3d1384b896 100644 --- a/src/smpi/include/smpi_file.hpp +++ b/src/smpi/include/smpi_file.hpp @@ -165,13 +165,13 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta } // what do I need to read ? MPI_Offset totreads = 0; - for (unsigned i = 0; i < chunks.size(); i++) { - if (chunks[i].second < my_chunk_start) + for (auto const& chunk : chunks) { + if (chunk.second < my_chunk_start) continue; - else if (chunks[i].first > my_chunk_end) + else if (chunk.first > my_chunk_end) continue; else - totreads += (std::min(chunks[i].second, my_chunk_end - 1) - std::max(chunks[i].first, my_chunk_start)); + totreads += (std::min(chunk.second, my_chunk_end - 1) - std::max(chunk.first, my_chunk_start)); } XBT_CDEBUG(smpi_pmpi, "will have to access %lld from my chunk", totreads); diff --git a/teshsuite/smpi/MBI/MBI.py b/teshsuite/smpi/MBI/MBI.py index bed5d752d8..9c384a4048 100755 --- a/teshsuite/smpi/MBI/MBI.py +++ b/teshsuite/smpi/MBI/MBI.py @@ -9,7 +9,6 @@ import sys import os -import re from MBIutils import * import simgrid @@ -31,10 +30,10 @@ simgrid = simgrid.Tool() (name, path, binary, filename) = sys.argv for test in parse_one_code(filename): - execcmd = re.sub("mpirun", f"{path}/smpi_script/bin/smpirun -wrapper '{path}/bin/simgrid-mc --log=mc_safety.t:info' -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000", test['cmd']) - execcmd = re.sub('\${EXE}', binary, execcmd) - execcmd = re.sub('\$zero_buffer', "--cfg=smpi/buffering:zero", execcmd) - execcmd = re.sub('\$infty_buffer', "--cfg=smpi/buffering:infty", execcmd) + execcmd = test['cmd'].replace("mpirun", f"{path}/smpi_script/bin/smpirun -wrapper '{path}/bin/simgrid-mc --log=mc_safety.t:info' -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000") + execcmd = execcmd.replace('${EXE}', binary) + execcmd = execcmd.replace('$zero_buffer', "--cfg=smpi/buffering:zero") + execcmd = execcmd.replace('$infty_buffer', "--cfg=smpi/buffering:infty") if os.path.exists(f'{filename}.txt'): os.remove(f'{filename}.txt') @@ -46,4 +45,4 @@ for test in parse_one_code(filename): if res_category != "TRUE_NEG" and res_category != "TRUE_POS": print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n") print(f"SimGrid gave the wrong result ({outcome} instead of {test['expect']}).") - sys.exit(1) \ No newline at end of file + sys.exit(1) diff --git a/teshsuite/smpi/MBI/MBIutils.py b/teshsuite/smpi/MBI/MBIutils.py index 433466f41c..070d3218a8 100644 --- a/teshsuite/smpi/MBI/MBIutils.py +++ b/teshsuite/smpi/MBI/MBIutils.py @@ -113,12 +113,12 @@ def parse_one_code(filename): if state == 0: state = 1 else: - raise Exception(f"MBI_TESTS header appears a second time at line {line_num}: \n{line}") + raise ValueError(f"MBI_TESTS header appears a second time at line {line_num}: \n{line}") elif re.match(".*END_MBI_TESTS.*", line): if state == 1: state = 2 else: - raise Exception(f"Unexpected end of MBI_TESTS header at line {line_num}: \n{line}") + raise ValueError(f"Unexpected end of MBI_TESTS header at line {line_num}: \n{line}") if state == 1 and re.match("\s+\$ ?.*", line): m = re.match('\s+\$ ?(.*)', line) cmd = m.group(1) @@ -129,12 +129,12 @@ def parse_one_code(filename): else: m = re.match('[ |]*ERROR: *(.*)', nextline) if not m: - raise Exception( + raise ValueError( f"\n{filename}:{line_num}: MBI parse error: Test not followed by a proper 'ERROR' line:\n{line}{nextline}") expect = 'ERROR' detail = m.group(1) if detail not in possible_details: - raise Exception( + raise ValueError( f"\n{filename}:{line_num}: MBI parse error: Detailled outcome {detail} is not one of the allowed ones.") test = {'filename': filename, 'id': test_num, 'cmd': cmd, 'expect': expect, 'detail': detail} res.append(test.copy()) @@ -142,12 +142,12 @@ def parse_one_code(filename): line_num += 1 if state == 0: - raise Exception(f"MBI_TESTS header not found in file '{filename}'.") + raise ValueError(f"MBI_TESTS header not found in file '{filename}'.") if state == 1: - raise Exception(f"MBI_TESTS header not properly ended in file '{filename}'.") + raise ValueError(f"MBI_TESTS header not properly ended in file '{filename}'.") if len(res) == 0: - raise Exception(f"No test found in {filename}. Please fix it.") + raise ValueError(f"No test found in {filename}. Please fix it.") return res def categorize(tool, toolname, test_id, expected): @@ -157,7 +157,7 @@ def categorize(tool, toolname, test_id, expected): if outcome == 'failure': elapsed = 0 else: - raise Exception(f"Invalid test result: {test_id}.txt exists but not {test_id}.elapsed") + raise ValueError(f"Invalid test result: {test_id}.txt exists but not {test_id}.elapsed") else: with open(f'{test_id}.elapsed' if os.path.exists(f'{test_id}.elapsed') else f'logs/{toolname}/{test_id}.elapsed', 'r') as infile: elapsed = infile.read() @@ -193,7 +193,7 @@ def categorize(tool, toolname, test_id, expected): res_category = 'TRUE_POS' diagnostic = f'correctly detected an error' else: - raise Exception(f"Unexpected expectation: {expected} (must be OK or ERROR)") + raise ValueError(f"Unexpected expectation: {expected} (must be OK or ERROR)") return (res_category, elapsed, diagnostic, outcome) diff --git a/teshsuite/smpi/MBI/generator_utils.py b/teshsuite/smpi/MBI/generator_utils.py index e978b1e427..3ef5d5c937 100644 --- a/teshsuite/smpi/MBI/generator_utils.py +++ b/teshsuite/smpi/MBI/generator_utils.py @@ -433,12 +433,12 @@ def find_line(content, target, filename): #print(f'Found {target} at {line}') return res res += 1 - raise Exception(f"Line target {target} not found in {filename}.") + raise ValueError(f"Line target {target} not found in {filename}.") def make_file(template, filename, replace): output = template - filename = re.sub("_MPI_", "_", filename) + filename = filename.replace("_MPI_", "_") replace['filename'] = filename # Replace all variables that don't have a ':' in their name while re.search("@\{[^@:]*\}@", output): @@ -449,7 +449,7 @@ def make_file(template, filename, replace): output = re.sub(f'@\{{{target}\}}@', replace[target], output) #print(f"Replace {target} -> {replace[target]}") else: - raise Exception(f"Variable {target} used in template, but not defined.") + raise ValueError(f"Variable {target} used in template, but not defined.") # Now replace all variables with a ':' in their name: line targets are like that, and we don't want to resolve them before the others change the lines while re.search("@\{([^:@]*):([^@]*)\}@", output): m = re.search("@\{([^:@]*):([^@]*)\}@", output) @@ -459,7 +459,7 @@ def make_file(template, filename, replace): #print(f"Replace @{{line:{target}}}@ with '{replace}'") output = re.sub(f'@\{{line:{target}\}}@', replace, output) else: - raise Exception(f"Unknown variable kind: {kind}:{target}") + raise ValueError(f"Unknown variable kind: {kind}:{target}") if os.path.exists(filename): with open(filename, 'r') as file: diff --git a/teshsuite/smpi/MBI/simgrid.py b/teshsuite/smpi/MBI/simgrid.py index b4f4158291..049ece11a2 100644 --- a/teshsuite/smpi/MBI/simgrid.py +++ b/teshsuite/smpi/MBI/simgrid.py @@ -48,12 +48,12 @@ class Tool(AbstractTool): outfile.write(' \n') outfile.write('\n') - execcmd = re.sub("mpirun", "smpirun -wrapper simgrid-mc -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000", execcmd) + execcmd = execcmd.replace("mpirun", "smpirun -wrapper simgrid-mc -platform ./cluster.xml -analyze --cfg=smpi/finalization-barrier:on --cfg=smpi/list-leaks:10 --cfg=model-check/max-depth:10000") if re.search("Concurrency", binary): # DPOR reduction in simgrid cannot deal with RMA calls as they contain mutexes - execcmd = re.sub("smpirun", "smpirun --cfg=model-check/reduction:none", execcmd) - execcmd = re.sub('\${EXE}', binary, execcmd) - execcmd = re.sub('\$zero_buffer', "--cfg=smpi/buffering:zero", execcmd) - execcmd = re.sub('\$infty_buffer', "--cfg=smpi/buffering:infty", execcmd) + execcmd = execcmd.replace("smpirun", "smpirun --cfg=model-check/reduction:none") + execcmd = execcmd.replace('${EXE}', binary) + execcmd = execcmd.replace('$zero_buffer', "--cfg=smpi/buffering:zero") + execcmd = execcmd.replace('$infty_buffer', "--cfg=smpi/buffering:infty") run_cmd( buildcmd=f"smpicc {filename} -trace-call-location -g -Wl,-znorelro -Wl,-znoseparate-code -o {binary}",