diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8139f23 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +* +!/**/ +!*.* + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# QtCreator +relacy.* + +Makefile +*.cmake +CMakeFiles +*.txt +Testing diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..f154925 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 2.8.12) + +add_subdirectory(cli_ws_deque) +add_subdirectory(condvar) +add_subdirectory(java_ws_deque) +add_subdirectory(mutex_business_logic) +add_subdirectory(peterson) +add_subdirectory(proxy_collector) +add_subdirectory(ref_counting) +add_subdirectory(smr) +add_subdirectory(spsc_queue) +add_subdirectory(ws_deque) +add_subdirectory(stack) diff --git a/example/cli_ws_deque/CMakeLists.txt b/example/cli_ws_deque/CMakeLists.txt new file mode 100644 index 0000000..3ea5922 --- /dev/null +++ b/example/cli_ws_deque/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(cli_ws_deque cli_ws_deque.cpp stdafx.cpp) diff --git a/example/cli_ws_deque/cli_ws_deque.cpp b/example/cli_ws_deque/cli_ws_deque.cpp index 199311f..614f898 100644 --- a/example/cli_ws_deque/cli_ws_deque.cpp +++ b/example/cli_ws_deque/cli_ws_deque.cpp @@ -127,9 +127,7 @@ class ws_deque }; - - -struct ws_deque_test : rl::test_suite +struct ws_deque_test { ws_deque q; bool state [2]; @@ -146,6 +144,8 @@ struct ws_deque_test : rl::test_suite RL_ASSERT(state[1] == false); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -190,6 +190,8 @@ struct ws_deque_test : rl::test_suite int main() { - rl::simulate(); + rl::test_params p; + p.static_thread_count = 2; + rl::simulate(p); } diff --git a/example/cli_ws_deque/msvc8/cli_ws_deque.sln b/example/cli_ws_deque/msvc8/cli_ws_deque.sln deleted file mode 100644 index d1a1b80..0000000 --- a/example/cli_ws_deque/msvc8/cli_ws_deque.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cli_ws_deque", "cli_ws_deque.vcproj", "{0B597F19-DEBB-4832-B520-9A93A286D595}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.ActiveCfg = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.Build.0 = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/cli_ws_deque/msvc8/cli_ws_deque.vcproj b/example/cli_ws_deque/msvc8/cli_ws_deque.vcproj deleted file mode 100644 index 98bef69..0000000 --- a/example/cli_ws_deque/msvc8/cli_ws_deque.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/condvar/CMakeLists.txt b/example/condvar/CMakeLists.txt new file mode 100644 index 0000000..456e7ce --- /dev/null +++ b/example/condvar/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(condvar condvar.cpp stdafx.cpp) diff --git a/example/condvar/condvar.cpp b/example/condvar/condvar.cpp index ef4fc57..7977402 100644 --- a/example/condvar/condvar.cpp +++ b/example/condvar/condvar.cpp @@ -131,7 +131,7 @@ void CondVar::Leave() } } -struct CondVarTest : rl::test_suite +struct CondVarTest { VAR_T(int) stage; CondVar cv; @@ -141,6 +141,9 @@ struct CondVarTest : rl::test_suite VAR(stage) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -176,6 +179,8 @@ struct CondVarTest : rl::test_suite int main() { - rl::simulate(); + rl::test_params p; + p.static_thread_count = 3; + rl::simulate(p); } diff --git a/example/condvar/msvc8/condvar.sln b/example/condvar/msvc8/condvar.sln deleted file mode 100644 index ba53a32..0000000 --- a/example/condvar/msvc8/condvar.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "condvar", "condvar.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/condvar/msvc8/condvar.vcproj b/example/condvar/msvc8/condvar.vcproj deleted file mode 100644 index 9236236..0000000 --- a/example/condvar/msvc8/condvar.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/condvar/msvc9/condvar.sln b/example/condvar/msvc9/condvar.sln deleted file mode 100644 index bba6a6e..0000000 --- a/example/condvar/msvc9/condvar.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "condvar", "condvar.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/condvar/msvc9/condvar.vcproj b/example/condvar/msvc9/condvar.vcproj deleted file mode 100644 index 330a11f..0000000 --- a/example/condvar/msvc9/condvar.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/eao_blocking/eao_blocking.cpp b/example/eao_blocking/eao_blocking.cpp index 17ed526..394e50f 100644 --- a/example/eao_blocking/eao_blocking.cpp +++ b/example/eao_blocking/eao_blocking.cpp @@ -152,7 +152,7 @@ class business_logic */ /* -struct business_logic_test : rl::test_suite +struct business_logic_test // thread count = 2 { business_logic bl; @@ -167,6 +167,9 @@ struct business_logic_test : rl::test_suite } } + void after() { } + void invariant() { } + void thread(unsigned) { business_logic::account_id_t acc1 = rl::rand(account_count); diff --git a/example/eventcount/eventcount.cpp b/example/eventcount/eventcount.cpp index fa53d87..09688a7 100644 --- a/example/eventcount/eventcount.cpp +++ b/example/eventcount/eventcount.cpp @@ -687,8 +687,11 @@ class condition_variable }; -struct eventcount_test : rl::test_suite +struct eventcount_test { + void before() { } + void after() { } + void invariant() { } void thread(unsigned index) { delete ec_thread::current(); @@ -701,6 +704,7 @@ struct eventcount_test : rl::test_suite int main() { rl::test_params p; + p.static_thread_count = 2; //p.iteration_count = 1000000; rl::simulate(p); } diff --git a/example/examples/amp_condvar.hpp b/example/examples/amp_condvar.hpp index 5e89ef5..daf9146 100644 --- a/example/examples/amp_condvar.hpp +++ b/example/examples/amp_condvar.hpp @@ -211,7 +211,7 @@ int amp_raw_condition_variable_wait(amp_raw_condition_variable_t cond, } -struct amp_condvar_test : rl::test_suite +struct amp_condvar_test // thread count = 2 { VAR_T(int) data; amp_raw_mutex_s mtx; @@ -230,6 +230,8 @@ struct amp_condvar_test : rl::test_suite amp_raw_condition_variable_finalize(&cv); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -254,7 +256,7 @@ struct amp_condvar_test : rl::test_suite -struct amp_condvar_test2 : rl::test_suite +struct amp_condvar_test2 // thread count = 4 { VAR_T(int) stage; amp_raw_mutex_s mtx; @@ -273,6 +275,8 @@ struct amp_condvar_test2 : rl::test_suite amp_raw_condition_variable_finalize(&cv); } + void invariant() { } + void thread(unsigned index) { if (0 == index) diff --git a/example/java_ws_deque/CMakeLists.txt b/example/java_ws_deque/CMakeLists.txt new file mode 100644 index 0000000..7e7e4d4 --- /dev/null +++ b/example/java_ws_deque/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(java_ws_deque java_ws_deque.cpp stdafx.cpp) diff --git a/example/java_ws_deque/java_ws_deque.cpp b/example/java_ws_deque/java_ws_deque.cpp index 7c7070f..7bb6874 100644 --- a/example/java_ws_deque/java_ws_deque.cpp +++ b/example/java_ws_deque/java_ws_deque.cpp @@ -129,7 +129,7 @@ class ws_deque -struct ws_deque_test : rl::test_suite +struct ws_deque_test { ws_deque q; bool state [2]; @@ -146,6 +146,8 @@ struct ws_deque_test : rl::test_suite RL_ASSERT(state[1] == false); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -190,6 +192,8 @@ struct ws_deque_test : rl::test_suite int main() { - rl::simulate(); + rl::test_params p; + p.static_thread_count = 2; + rl::simulate(p); } diff --git a/example/java_ws_deque/msvc8/java_ws_deque.sln b/example/java_ws_deque/msvc8/java_ws_deque.sln deleted file mode 100644 index 7209743..0000000 --- a/example/java_ws_deque/msvc8/java_ws_deque.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "java_ws_deque", "java_ws_deque.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/java_ws_deque/msvc8/java_ws_deque.vcproj b/example/java_ws_deque/msvc8/java_ws_deque.vcproj deleted file mode 100644 index 2d77690..0000000 --- a/example/java_ws_deque/msvc8/java_ws_deque.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/mpmc/mpmc.cpp b/example/mpmc/mpmc.cpp index e3e5e62..39f72e4 100644 --- a/example/mpmc/mpmc.cpp +++ b/example/mpmc/mpmc.cpp @@ -193,10 +193,14 @@ class mpmcq }; -struct test_mpmc : rl::test_suite +struct test_mpmc // thread count = 6 { mpmcq q; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned idx) { if (idx < thread_count / 2) @@ -439,7 +443,7 @@ struct eventcount -struct test_ec : rl::test_suite +struct test_ec { std::atomic x [2]; eventcount ec; @@ -450,6 +454,9 @@ struct test_ec : rl::test_suite x[1]($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned idx) { if (idx < 4) @@ -506,6 +513,7 @@ int main() rl::test_params p; p.iteration_count = 20000000; p.initial_state = "10000000"; + p.static_thread_count = 8; rl::simulate(p); } diff --git a/example/mutex_business_logic/CMakeLists.txt b/example/mutex_business_logic/CMakeLists.txt new file mode 100644 index 0000000..7ecb807 --- /dev/null +++ b/example/mutex_business_logic/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(mutex_business_logic mutex_business_logic.cpp stdafx.cpp) diff --git a/example/mutex_business_logic/msvc8/mutex_business_logic.sln b/example/mutex_business_logic/msvc8/mutex_business_logic.sln deleted file mode 100644 index 05577c5..0000000 --- a/example/mutex_business_logic/msvc8/mutex_business_logic.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mutex_business_logic", "mutex_business_logic.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/mutex_business_logic/msvc8/mutex_business_logic.vcproj b/example/mutex_business_logic/msvc8/mutex_business_logic.vcproj deleted file mode 100644 index 9c06a85..0000000 --- a/example/mutex_business_logic/msvc8/mutex_business_logic.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/mutex_business_logic/mutex_business_logic.cpp b/example/mutex_business_logic/mutex_business_logic.cpp index 51e5a65..c89b0d4 100644 --- a/example/mutex_business_logic/mutex_business_logic.cpp +++ b/example/mutex_business_logic/mutex_business_logic.cpp @@ -97,7 +97,7 @@ class business_logic -struct business_logic_test : rl::test_suite +struct business_logic_test { business_logic bl; @@ -112,6 +112,9 @@ struct business_logic_test : rl::test_suite } } + void after() { } + void invariant() { } + void thread(unsigned /*index*/) { business_logic::account_id_t acc1 = rl::rand(account_count); @@ -126,6 +129,8 @@ struct business_logic_test : rl::test_suite int main() { - rl::simulate(); + rl::test_params p; + p.static_thread_count = 2; + rl::simulate(p); } diff --git a/example/old_api/CMakeLists.txt b/example/old_api/CMakeLists.txt new file mode 100644 index 0000000..e44d50a --- /dev/null +++ b/example/old_api/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(old_api old_api.cpp stdafx.cpp) diff --git a/example/old_api/old_api.cpp b/example/old_api/old_api.cpp new file mode 100644 index 0000000..8efdef3 --- /dev/null +++ b/example/old_api/old_api.cpp @@ -0,0 +1,102 @@ +#include "stdafx.h" + +#include "../../relacy/relacy_std.hpp" + + +// TEST FAILS WITH "ACCESS TO FREED MEMORY" + +class stack +{ +public: + stack() + : head_(0) + { + } + + void push(int data) + { + rl::var n = new node (); + n($)->data_($) = data; + node* next = head_.load(rl::memory_order_relaxed); + for (;;) + { + n($)->next_.store(next, rl::memory_order_relaxed); + if (head_.compare_exchange_weak(next, n($), rl::memory_order_release)) + break; + } + } + + int pop() + { + node* n = head_.load(rl::memory_order_relaxed); + for (;;) + { + if (0 == n) + break; + node* next = n->next_.load(rl::memory_order_relaxed); + if (head_.compare_exchange_weak(n, next, rl::memory_order_acquire)) + break; + } + if (n) + { + int data = n->data_($); + delete n; + return data; + } + else + { + return 0; + } + } + +private: + struct node + { + std::atomic next_; + rl::var data_; + }; + + std::atomic head_; + + stack(stack const&); + stack& operator = (stack const&); +}; + +int count_threads = 0; + +struct stack_test : rl::test_suite +{ + stack s_; + + int produced_count_; + int consumed_count_; + + void before() + { + produced_count_ = 0; + consumed_count_ = 0; + } + + void after() + { + RL_ASSERT(count_threads == produced_count_); + RL_ASSERT(count_threads == consumed_count_); + } + + void invariant() { } + + void thread(unsigned /*index*/) + { + s_.push(rand() + 1); + produced_count_ += 1; + int data = s_.pop(); + RL_ASSERT(data); + consumed_count_ += 1; + } +}; + +int main() +{ + rl::simulate(); +} + diff --git a/example/old_api/stdafx.cpp b/example/old_api/stdafx.cpp new file mode 100644 index 0000000..716dda6 --- /dev/null +++ b/example/old_api/stdafx.cpp @@ -0,0 +1,2 @@ +#include "stdafx.h" + diff --git a/example/old_api/stdafx.h b/example/old_api/stdafx.h new file mode 100644 index 0000000..5be6df7 --- /dev/null +++ b/example/old_api/stdafx.h @@ -0,0 +1,8 @@ +#pragma once + +#ifdef NDEBUG +# define _SECURE_SCL 0 +#endif + +#include "../../relacy/pch.hpp" + diff --git a/example/peterson/CMakeLists.txt b/example/peterson/CMakeLists.txt new file mode 100644 index 0000000..e71b019 --- /dev/null +++ b/example/peterson/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(peterson peterson.cpp stdafx.cpp) diff --git a/example/peterson/msvc8/peterson.sln b/example/peterson/msvc8/peterson.sln deleted file mode 100644 index 53641b8..0000000 --- a/example/peterson/msvc8/peterson.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "peterson", "peterson.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/peterson/msvc8/peterson.vcproj b/example/peterson/msvc8/peterson.vcproj deleted file mode 100644 index 97db3d8..0000000 --- a/example/peterson/msvc8/peterson.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/peterson/msvc9/peterson.sln b/example/peterson/msvc9/peterson.sln deleted file mode 100644 index fcc88dd..0000000 --- a/example/peterson/msvc9/peterson.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "peterson", "peterson.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/peterson/msvc9/peterson.vcproj b/example/peterson/msvc9/peterson.vcproj deleted file mode 100644 index d78365f..0000000 --- a/example/peterson/msvc9/peterson.vcproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/peterson/peterson.cpp b/example/peterson/peterson.cpp index ff220b7..2636722 100644 --- a/example/peterson/peterson.cpp +++ b/example/peterson/peterson.cpp @@ -3,7 +3,7 @@ #include "../../relacy/windows.h" -struct peterson_mutex_test : rl::test_suite +struct peterson_mutex_test { std::atomic flag0; std::atomic flag1; @@ -18,6 +18,9 @@ struct peterson_mutex_test : rl::test_suite turn($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -50,7 +53,7 @@ struct peterson_mutex_test : rl::test_suite -struct peterson_mutex_test2 : rl::test_suite +struct peterson_mutex_test2 { std::atomic flag0; std::atomic flag1; @@ -65,6 +68,9 @@ struct peterson_mutex_test2 : rl::test_suite turn($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -99,7 +105,7 @@ struct peterson_mutex_test2 : rl::test_suite -struct peterson_mutex_test3 : rl::test_suite +struct peterson_mutex_test3 { std::atomic flag0; std::atomic flag1; @@ -114,6 +120,9 @@ struct peterson_mutex_test3 : rl::test_suite turn($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -150,7 +159,7 @@ struct peterson_mutex_test3 : rl::test_suite // FAILS WITH DATA RACE -struct peterson_mutex_test4 : rl::test_suite +struct peterson_mutex_test4 { std::atomic flag0; std::atomic flag1; @@ -165,6 +174,9 @@ struct peterson_mutex_test4 : rl::test_suite turn($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -311,7 +323,7 @@ class eventcount_blocking -struct signaling_test : rl::test_suite +struct signaling_test // thread count = 6 { //rl::HANDLE var_wait_for_items; //rl::CRITICAL_SECTION mtx_items_avail; @@ -349,6 +361,8 @@ struct signaling_test : rl::test_suite //rl::DeleteCriticalSection(&mtx_items_avail, $); } + void invariant() { } + struct enqueue_desc { int pos; @@ -432,7 +446,7 @@ struct signaling_test : rl::test_suite void thread(unsigned index) { - if (index < rl::test_suite::params::thread_count/2+1) + if (index < 6 / 2 + 1) { enqueue(); } @@ -450,16 +464,23 @@ int main() { rl::test_params p; //p.search_type = rl::fair_context_bound_scheduler_type; - p.search_type = rl::sched_bound; + p.static_thread_count = 2; //p.context_bound = 1; //p.execution_depth_limit = 100; //p.iteration_count = 5000; //p.initial_state = "280572"; //rl::simulate(p); - rl::simulate(); + p.search_type = rl::random_scheduler_type; + rl::simulate(p); + + p.search_type = rl::sched_bound; rl::simulate(p); - rl::simulate(); + + p.search_type = rl::random_scheduler_type; + rl::simulate(p); + + p.search_type = rl::sched_bound; rl::simulate(p); } diff --git a/example/proxy_collector/CMakeLists.txt b/example/proxy_collector/CMakeLists.txt new file mode 100644 index 0000000..c965840 --- /dev/null +++ b/example/proxy_collector/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(proxy_collector proxy_collector.cpp stdafx.cpp) diff --git a/example/proxy_collector/msvc8/proxy_collector.sln b/example/proxy_collector/msvc8/proxy_collector.sln deleted file mode 100644 index 7185b0a..0000000 --- a/example/proxy_collector/msvc8/proxy_collector.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy_collector", "proxy_collector.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B29}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/proxy_collector/msvc8/proxy_collector.vcproj b/example/proxy_collector/msvc8/proxy_collector.vcproj deleted file mode 100644 index d23272f..0000000 --- a/example/proxy_collector/msvc8/proxy_collector.vcproj +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/proxy_collector/msvc9/proxy_collector.sln b/example/proxy_collector/msvc9/proxy_collector.sln deleted file mode 100644 index 7729b54..0000000 --- a/example/proxy_collector/msvc9/proxy_collector.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy_collector", "proxy_collector.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B29}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/proxy_collector/msvc9/proxy_collector.vcproj b/example/proxy_collector/msvc9/proxy_collector.vcproj deleted file mode 100644 index d1522d3..0000000 --- a/example/proxy_collector/msvc9/proxy_collector.vcproj +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/proxy_collector/proxy_collector.cpp b/example/proxy_collector/proxy_collector.cpp index 0d942e9..b248699 100644 --- a/example/proxy_collector/proxy_collector.cpp +++ b/example/proxy_collector/proxy_collector.cpp @@ -217,7 +217,7 @@ struct foo_list } }; -struct proxy_collector_test : rl::test_suite +struct proxy_collector_test { foo_list m_list; @@ -232,6 +232,8 @@ struct proxy_collector_test : rl::test_suite m_list.pc.mutate(&node->pcn); } + void invariant() { } + void thread(unsigned index) { if (index < 2) @@ -313,6 +315,7 @@ int main() { rl::test_params params; params.iteration_count = 1000; + params.static_thread_count = 4; rl::simulate(params); } diff --git a/example/ref_counting/CMakeLists.txt b/example/ref_counting/CMakeLists.txt new file mode 100644 index 0000000..84d79e6 --- /dev/null +++ b/example/ref_counting/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(ref_counting ref_counting.cpp stdafx.cpp) diff --git a/example/ref_counting/msvc8/ref_counting.sln b/example/ref_counting/msvc8/ref_counting.sln deleted file mode 100644 index 4cd68cf..0000000 --- a/example/ref_counting/msvc8/ref_counting.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ref_counting", "ref_counting.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B28}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/ref_counting/msvc8/ref_counting.vcproj b/example/ref_counting/msvc8/ref_counting.vcproj deleted file mode 100644 index 84a1152..0000000 --- a/example/ref_counting/msvc8/ref_counting.vcproj +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/ref_counting/msvc9/ref_counting.sln b/example/ref_counting/msvc9/ref_counting.sln deleted file mode 100644 index 5d69f68..0000000 --- a/example/ref_counting/msvc9/ref_counting.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ref_counting", "ref_counting.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B28}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/ref_counting/msvc9/ref_counting.vcproj b/example/ref_counting/msvc9/ref_counting.vcproj deleted file mode 100644 index a942d84..0000000 --- a/example/ref_counting/msvc9/ref_counting.vcproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/ref_counting/ref_counting.cpp b/example/ref_counting/ref_counting.cpp index fbffc47..97643cb 100644 --- a/example/ref_counting/ref_counting.cpp +++ b/example/ref_counting/ref_counting.cpp @@ -54,7 +54,7 @@ rc_object* get_from_channel(rl::atomic& ch) -struct ref_counting_test : rl::test_suite +struct ref_counting_test { std::atomic channel; @@ -63,6 +63,9 @@ struct ref_counting_test : rl::test_suite channel($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -98,7 +101,7 @@ struct ref_counting_test : rl::test_suite -struct ref_counting_test2 : rl::test_suite +struct ref_counting_test2 // thread count = 3 { std::atomic channel01; std::atomic channel02; @@ -113,6 +116,9 @@ struct ref_counting_test2 : rl::test_suite channel21($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -215,7 +221,7 @@ struct ref_counting_test2 : rl::test_suite -struct ref_counting_test3 : rl::test_suite +struct ref_counting_test3 // thread count = 3 { std::atomic channel; @@ -224,6 +230,9 @@ struct ref_counting_test3 : rl::test_suite channel($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -263,6 +272,7 @@ int main() rl::test_params params; params.context_bound = 2; params.iteration_count = 10000; + params.static_thread_count = 2; rl::simulate(params); std::cout << "count: " << params.stop_iteration << std::endl; } diff --git a/example/smr/CMakeLists.txt b/example/smr/CMakeLists.txt new file mode 100644 index 0000000..879fabe --- /dev/null +++ b/example/smr/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(smr smr.cpp stdafx.cpp) diff --git a/example/smr/g++/Makefile b/example/smr/g++/Makefile deleted file mode 100644 index b66e4b4..0000000 --- a/example/smr/g++/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -TARGET=smr -SRC=smr.cpp -HEADERS=stdafx.h - -all: ${TARGET} - -${TARGET}: Makefile ${SRC} ${HEADERS} - g++ ${SRC} -O3 -g -o ${TARGET} - -clean: - rm ${TARGET} diff --git a/example/smr/msvc8/smr.sln b/example/smr/msvc8/smr.sln deleted file mode 100644 index de8f36c..0000000 --- a/example/smr/msvc8/smr.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smr", "smr.vcproj", "{BC168133-5E3D-4691-BA15-8E0FD61DFDB5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.Build.0 = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/smr/msvc8/smr.vcproj b/example/smr/msvc8/smr.vcproj deleted file mode 100644 index d1e29fb..0000000 --- a/example/smr/msvc8/smr.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/smr/msvc9/smr.sln b/example/smr/msvc9/smr.sln deleted file mode 100644 index 7d74c79..0000000 --- a/example/smr/msvc9/smr.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smr", "smr.vcproj", "{BC168133-5E3D-4691-BA15-8E0FD61DFDB5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.Build.0 = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/smr/msvc9/smr.vcproj b/example/smr/msvc9/smr.vcproj deleted file mode 100644 index 16bcc3c..0000000 --- a/example/smr/msvc9/smr.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/smr/smr.cpp b/example/smr/smr.cpp index 3cde442..1b9e05d 100644 --- a/example/smr/smr.cpp +++ b/example/smr/smr.cpp @@ -7,7 +7,7 @@ unsigned const thread_count = 3; unsigned const node_count = 6; -struct smr_test : rl::test_suite +struct smr_test { struct node { @@ -34,8 +34,11 @@ struct smr_test : rl::test_suite } } + void invariant() { } + void push(unsigned index, int data) { + (void)index; node* n = new node (); n->VAR(data_) = data; node* next = head_.load(std::memory_order_relaxed); @@ -183,6 +186,7 @@ int main() //p.output_history = true; //p.initial_state = "991172"; p.iteration_count = 1000; + p.static_thread_count = thread_count; rl::simulate(p); } diff --git a/example/spsc_queue/CMakeLists.txt b/example/spsc_queue/CMakeLists.txt new file mode 100644 index 0000000..babb656 --- /dev/null +++ b/example/spsc_queue/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(spsc_queue spsc_queue.cpp stdafx.cpp) diff --git a/example/spsc_queue/msvc8/spsc_queue.sln b/example/spsc_queue/msvc8/spsc_queue.sln deleted file mode 100644 index 5c442a1..0000000 --- a/example/spsc_queue/msvc8/spsc_queue.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spsc_queue", "spsc_queue.vcproj", "{2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Debug|Win32.ActiveCfg = Debug|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Debug|Win32.Build.0 = Debug|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Release|Win32.ActiveCfg = Release|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/spsc_queue/msvc8/spsc_queue.vcproj b/example/spsc_queue/msvc8/spsc_queue.vcproj deleted file mode 100644 index 7f8642b..0000000 --- a/example/spsc_queue/msvc8/spsc_queue.vcproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/spsc_queue/msvc9/spsc_queue.sln b/example/spsc_queue/msvc9/spsc_queue.sln deleted file mode 100644 index dc5ba93..0000000 --- a/example/spsc_queue/msvc9/spsc_queue.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spsc_queue", "spsc_queue.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/spsc_queue/msvc9/spsc_queue.vcproj b/example/spsc_queue/msvc9/spsc_queue.vcproj deleted file mode 100644 index bd89b8d..0000000 --- a/example/spsc_queue/msvc9/spsc_queue.vcproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/spsc_queue/spsc_queue.cpp b/example/spsc_queue/spsc_queue.cpp index a03a46e..afc99f7 100644 --- a/example/spsc_queue/spsc_queue.cpp +++ b/example/spsc_queue/spsc_queue.cpp @@ -53,10 +53,14 @@ class nonblocking_spsc_queue VAR_T(node*) tail; }; -struct nonblocking_spsc_queue_test : rl::test_suite +struct nonblocking_spsc_queue_test { nonblocking_spsc_queue q; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned thread_index) { if (0 == thread_index) @@ -175,10 +179,14 @@ class spsc_queue : nonblocking_spsc_queue }; -struct spsc_queue_test : rl::test_suite +struct spsc_queue_test { spsc_queue q; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned thread_index) { if (0 == thread_index) @@ -196,7 +204,10 @@ struct spsc_queue_test : rl::test_suite int main() { - rl::simulate(); - rl::simulate(); + rl::test_params p; + p.static_thread_count = 2; + + rl::simulate(p); + rl::simulate(p); } diff --git a/example/stack/CMakeLists.txt b/example/stack/CMakeLists.txt new file mode 100644 index 0000000..cd923e9 --- /dev/null +++ b/example/stack/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(stack stack.cpp stdafx.cpp) diff --git a/example/stack/msvc8/stack.sln b/example/stack/msvc8/stack.sln deleted file mode 100644 index 809c2b6..0000000 --- a/example/stack/msvc8/stack.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stack", "stack.vcproj", "{4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.ActiveCfg = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.Build.0 = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/stack/msvc8/stack.vcproj b/example/stack/msvc8/stack.vcproj deleted file mode 100644 index 8031ba8..0000000 --- a/example/stack/msvc8/stack.vcproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/stack/msvc9/stack.sln b/example/stack/msvc9/stack.sln deleted file mode 100644 index a9e84b6..0000000 --- a/example/stack/msvc9/stack.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stack", "stack.vcproj", "{4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.ActiveCfg = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.Build.0 = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/stack/msvc9/stack.vcproj b/example/stack/msvc9/stack.vcproj deleted file mode 100644 index 7573fad..0000000 --- a/example/stack/msvc9/stack.vcproj +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/stack/stack.cpp b/example/stack/stack.cpp index e30428c..e422fa2 100644 --- a/example/stack/stack.cpp +++ b/example/stack/stack.cpp @@ -62,10 +62,9 @@ class stack stack& operator = (stack const&); }; +int count_threads = 0; - - -struct stack_test : rl::test_suite +struct stack_test { stack s_; @@ -80,11 +79,12 @@ struct stack_test : rl::test_suite void after() { - typedef rl::test_suite base_t; - RL_ASSERT(base_t::params::thread_count == produced_count_); - RL_ASSERT(base_t::params::thread_count == consumed_count_); + RL_ASSERT(count_threads == produced_count_); + RL_ASSERT(count_threads == consumed_count_); } + void invariant() { } + void thread(unsigned /*index*/) { s_.push(rand() + 1); @@ -98,8 +98,34 @@ struct stack_test : rl::test_suite -int main() +int main(int argc, char **argv) { - rl::simulate(); + if (argc != 2) + { + std::cerr << "Wrong number of arguments" << std::endl; + return EINVAL; + } + + try + { + count_threads = std::atoi(argv[1]); + if (count_threads <= 0) + { + std::cerr << "The number of threads must be a positive number" << std::endl; + return EINVAL; + } + + rl::test_params p; + p.static_thread_count = count_threads; + rl::simulate(p); + } + catch(std::exception const & e) + { + (void)e; + std::cerr << "Wrong argument. The number of threads must be a number" << std::endl; + return EINVAL; + } + + return 0; } diff --git a/example/tbb_eventcount/eventcount.cpp b/example/tbb_eventcount/eventcount.cpp index d70deff..1c0400b 100644 --- a/example/tbb_eventcount/eventcount.cpp +++ b/example/tbb_eventcount/eventcount.cpp @@ -765,11 +765,15 @@ class condition_variable }; -struct queue_test : rl::test_suite +struct queue_test { ec_thread threads_ [6]; queue q_; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index < 2) @@ -787,7 +791,7 @@ struct queue_test : rl::test_suite } }; -struct condvar_test : rl::test_suite +struct condvar_test // thread count = 3 { rl::var stage; condition_variable cv; @@ -799,6 +803,9 @@ struct condvar_test : rl::test_suite stage($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -836,6 +843,7 @@ int main() p.iteration_count = 100000000; //p.initial_state = "30000000"; //p.search_type = rl::fair_context_bound_scheduler_type; + p.static_thread_count = 4; rl::simulate(p); //rl::simulate(p); } diff --git a/example/ws_deque/CMakeLists.txt b/example/ws_deque/CMakeLists.txt new file mode 100644 index 0000000..065687d --- /dev/null +++ b/example/ws_deque/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(ws_deque ws_deque.cpp stdafx.cpp) diff --git a/example/ws_deque/msvc8/ws_deque.sln b/example/ws_deque/msvc8/ws_deque.sln deleted file mode 100644 index b4e2c73..0000000 --- a/example/ws_deque/msvc8/ws_deque.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ws_deque", "ws_deque.vcproj", "{0B597F19-DEBB-4832-B520-9A93A286D595}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.ActiveCfg = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.Build.0 = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/ws_deque/msvc8/ws_deque.vcproj b/example/ws_deque/msvc8/ws_deque.vcproj deleted file mode 100644 index c20421c..0000000 --- a/example/ws_deque/msvc8/ws_deque.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/ws_deque/msvc9/ws_deque.sln b/example/ws_deque/msvc9/ws_deque.sln deleted file mode 100644 index 3cd4dde..0000000 --- a/example/ws_deque/msvc9/ws_deque.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ws_deque", "ws_deque.vcproj", "{0B597F19-DEBB-4832-B520-9A93A286D595}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.ActiveCfg = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.Build.0 = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/example/ws_deque/msvc9/ws_deque.vcproj b/example/ws_deque/msvc9/ws_deque.vcproj deleted file mode 100644 index 801a7c4..0000000 --- a/example/ws_deque/msvc9/ws_deque.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/example/ws_deque/ws_deque.cpp b/example/ws_deque/ws_deque.cpp index 15dee73..77a040d 100644 --- a/example/ws_deque/ws_deque.cpp +++ b/example/ws_deque/ws_deque.cpp @@ -139,7 +139,7 @@ class ws_deque -struct ws_deque_test0 : rl::test_suite +struct ws_deque_test0 { ws_deque q; @@ -151,6 +151,8 @@ struct ws_deque_test0 : rl::test_suite { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -220,7 +222,7 @@ struct ws_deque_test0 : rl::test_suite -struct ws_deque_test : rl::test_suite +struct ws_deque_test { ws_deque q; bool state [2]; @@ -237,6 +239,8 @@ struct ws_deque_test : rl::test_suite RL_ASSERT(state[1] == false); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -281,7 +285,10 @@ struct ws_deque_test : rl::test_suite int main() { - rl::simulate(); - rl::simulate(); + rl::test_params p; + p.static_thread_count = 4; + rl::simulate(p); + p.static_thread_count = 2; + rl::simulate(p); } diff --git a/example/ws_deque2/ws_deque.cpp b/example/ws_deque2/ws_deque.cpp index 238c0d3..92b9f72 100644 --- a/example/ws_deque2/ws_deque.cpp +++ b/example/ws_deque2/ws_deque.cpp @@ -604,7 +604,7 @@ class ws_deque int x = 0; -struct ws_deque_test : rl::test_suite +struct ws_deque_test { ws_deque q; pdr p; @@ -619,6 +619,8 @@ struct ws_deque_test : rl::test_suite p.fini(); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -684,6 +686,7 @@ struct ws_deque_test : rl::test_suite int main() { rl::test_params p; + p.static_thread_count = 4; p.iteration_count = 1000000; rl::simulate(p); } diff --git a/relacy/atomic.hpp b/relacy/atomic.hpp index 6385a01..d31f2fe 100644 --- a/relacy/atomic.hpp +++ b/relacy/atomic.hpp @@ -660,33 +660,55 @@ typedef atomic atomic_ptrdiff_t; //typedef atomic atomic_intmax_t; //typedef atomic atomic_uintmax_t; - - - -template +template struct atomic_data_impl : atomic_data { - typedef thread_info thread_info_t; + typedef thread_info thread_info_t; struct history_record { - timestamp_t acq_rel_order_ [thread_count]; - timestamp_t last_seen_order_ [thread_count]; + timestamp_t* acq_rel_order_; + timestamp_t* last_seen_order_; bool busy_; bool seq_cst_; thread_id_t thread_id_; timestamp_t acq_rel_timestamp_; + + history_record(thread_id_t thread_count) + : acq_rel_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , last_seen_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) + { + } + + ~history_record() + { + //free(acq_rel_order_); + //free(last_seen_order_); + } + + private: + history_record(const history_record&); + history_record& operator=(const history_record&); + }; static size_t const history_size = atomic_history_size; - aligned history_ [history_size]; + history_record* history_; unsigned current_index_; - waitset futex_ws_; - sync_var futex_sync_; + waitset<> futex_ws_; + sync_var futex_sync_; - atomic_data_impl() + atomic_data_impl(thread_id_t thread_count) + : history_(static_cast(calloc(history_size, sizeof(history_record)))) + , futex_ws_(thread_count) + , futex_sync_(thread_count) { + for (int i = 0; i != history_size; i++) + { + new (history_ + i) history_record (thread_count); + } + current_index_ = 0; history_record& rec = history_[0]; history_[atomic_history_size - 1].busy_ = false; @@ -696,8 +718,16 @@ struct atomic_data_impl : atomic_data rec.thread_id_ = (thread_id_t)-1; } - atomic_data_impl(thread_info_t& th) + atomic_data_impl(thread_id_t thread_count, thread_info_t& th) + : history_(static_cast(calloc(history_size, sizeof(history_record)))) + , futex_ws_(thread_count) + , futex_sync_(thread_count) { + for (int i = 0; i != history_size; i++) + { + new (history_ + i) history_record(thread_count); + } + current_index_ = 0; history_[atomic_history_size - 1].busy_ = false; @@ -709,12 +739,24 @@ struct atomic_data_impl : atomic_data th.own_acq_rel_order_ += 1; rec.acq_rel_timestamp_ = th.own_acq_rel_order_; - foreach(rec.acq_rel_order_, assign_zero); - foreach(rec.last_seen_order_, assign<(timestamp_t)-1>); + foreach(thread_count, rec.acq_rel_order_, assign_zero); + foreach(thread_count, rec.last_seen_order_, assign<(timestamp_t)-1>); rec.last_seen_order_[th.index_] = th.own_acq_rel_order_; } -}; + ~atomic_data_impl() + { + for (int i = 0; i != history_size; i++) + { + history_[i].~history_record(); + } + //free(history_); + } + +private: + atomic_data_impl(const atomic_data_impl&); + atomic_data_impl& operator = (const atomic_data_impl&); +}; } diff --git a/relacy/cli_var.hpp b/relacy/cli_var.hpp index 40012c8..036ade5 100644 --- a/relacy/cli_var.hpp +++ b/relacy/cli_var.hpp @@ -131,6 +131,7 @@ class nvar : public generic_atomic } nvar(nvar const& r) + : generic_atomic() { T const value = r.load(mo_relaxed, $); this->store(value, mo_relaxed, $); diff --git a/relacy/context.hpp b/relacy/context.hpp index e8b97b2..cf0a791 100644 --- a/relacy/context.hpp +++ b/relacy/context.hpp @@ -24,20 +24,23 @@ #include "test_params.hpp" #include "random.hpp" #include "foreach.hpp" +#include "stdlib/event.hpp" +#include "atomic.hpp" +#include "var.hpp" +#include "stdlib/condition_variable.hpp" +#include "stdlib/mutex.hpp" +#include "test_suite.hpp" -#include "random_scheduler.hpp" -#include "full_search_scheduler.hpp" -#include "context_bound_scheduler.hpp" - - +#include "schedulers/random_scheduler.hpp" +#include "schedulers/full_search_scheduler.hpp" +#include "schedulers/context_bound_scheduler.hpp" namespace rl { -template class generic_mutex_data_impl; -template class condvar_data_impl; -template class sema_data_impl; -template class event_data_impl; +class generic_mutex_data_impl; +class condvar_data_impl; +class sema_data_impl; struct park_event @@ -98,16 +101,11 @@ struct context_persistent }; */ - template -class context_impl - : thread_local_contxt_impl, test_t::params::thread_count> +class context_impl : thread_local_contxt_impl > { private: - typedef thread_local_contxt_impl - , - test_t::params::thread_count> - base_t; + typedef thread_local_contxt_impl > base_t; typedef typename scheduler_t::shared_context_t shared_context_t; using base_t::params_; @@ -118,9 +116,8 @@ class context_impl using base_t::invariant_executing; static thread_id_t const main_thread_id = -1; - static thread_id_t const static_thread_count = test_t::params::static_thread_count; - static thread_id_t const dynamic_thread_count = test_t::params::dynamic_thread_count; - static thread_id_t const thread_count = test_t::params::thread_count; + thread_id_t const static_thread_count; + thread_id_t const thread_count_; iteration_t current_iter_; test_result_e test_result_; @@ -136,44 +133,44 @@ class context_impl test_t* current_test_suite; bool current_test_suite_constructed; bool first_thread_; - timestamp_t seq_cst_fence_order_ [thread_count]; + timestamp_t* seq_cst_fence_order_; - aligned > threads_ [thread_count]; + thread_info<>* threads_; - thread_info& threadi() + thread_info<>& threadi() { - return *static_cast*>(threadx_); + return *static_cast*>(threadx_); } - slab_allocator >* atomic_alloc_; - slab_allocator >* var_alloc_; - slab_allocator >* mutex_alloc_; - slab_allocator >* condvar_alloc_; - slab_allocator >* sema_alloc_; - slab_allocator >* event_alloc_; + slab_allocator >* atomic_alloc_; + slab_allocator* var_alloc_; + slab_allocator* mutex_alloc_; + slab_allocator* condvar_alloc_; + slab_allocator* sema_alloc_; + slab_allocator* event_alloc_; virtual atomic_data* atomic_ctor(void* ctx) { - return new (atomic_alloc_->alloc(ctx)) atomic_data_impl (); + return new (atomic_alloc_->alloc(ctx)) atomic_data_impl<>(thread_count_); } virtual void atomic_dtor(atomic_data* data) { - static_cast*>(data)->~atomic_data_impl(); - atomic_alloc_->free(static_cast*>(data)); + static_cast*>(data)->~atomic_data_impl<>(); + atomic_alloc_->free(static_cast*>(data)); } virtual var_data* var_ctor() { - return new (var_alloc_->alloc()) var_data_impl (); + return new (var_alloc_->alloc()) var_data_impl(thread_count_); } virtual void var_dtor(var_data* data) { - static_cast*>(data)->~var_data_impl(); - var_alloc_->free(static_cast*>(data)); + static_cast(data)->~var_data_impl(); + var_alloc_->free(static_cast(data)); } - + virtual unpark_reason wfmo_park(void** ws, win_waitable_object** wo, size_t count, @@ -181,18 +178,22 @@ class context_impl bool is_timed, debug_info_param info) { - return waitset::park_current(*this, - reinterpret_cast**>(ws), + return waitset<>::park_current(thread_count_, *this, + reinterpret_cast**>(ws), wo, count, wait_all, is_timed, true, info); } public: - context_impl(test_params& params, shared_context_t& sctx) - : base_t(thread_count, params) + context_impl(test_params& params, shared_context_t& sctx, thread_id_t thread_count) + : base_t(thread_count, params, thread_count) + , static_thread_count(params.static_thread_count) + , thread_count_(thread_count) , current_iter_(0) , start_iteration_(1) - , sched_(params, sctx, dynamic_thread_count) + , sched_(params, sctx, params.dynamic_thread_count, thread_count) , sctx_(sctx) + , seq_cst_fence_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , threads_(static_cast*>(calloc(thread_count, sizeof(thread_info<>)))) { this->context::seq_cst_fence_order_ = this->seq_cst_fence_order_; @@ -207,25 +208,25 @@ class context_impl create_main_fiber(main_fiber_); set_low_thread_prio(); - if (0 == val(thread_count)) + if (0 == val(thread_count_)) { throw std::logic_error("no threads created"); } - atomic_alloc_ = new slab_allocator >(); - var_alloc_ = new slab_allocator >(); - mutex_alloc_ = new slab_allocator >(); - condvar_alloc_ = new slab_allocator >(); - sema_alloc_ = new slab_allocator >(); - event_alloc_ = new slab_allocator >(); + atomic_alloc_ = new slab_allocator >(); + var_alloc_ = new slab_allocator(); + mutex_alloc_ = new slab_allocator(); + condvar_alloc_ = new slab_allocator(); + sema_alloc_ = new slab_allocator(); + event_alloc_ = new slab_allocator(); - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { - new (&threads_[i]) thread_info (i); + new (&threads_[i]) thread_info<> (thread_count_, i); threads_[i].ctx_ = this; } - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { //threads_[i].fiber_ = persistent.fibers_[i]; create_fiber(threads_[i].fiber_, &context_impl::fiber_proc, (void*)(intptr_t)i); @@ -238,7 +239,7 @@ class context_impl { disable_alloc_ += 1; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { delete_fiber(threads_[i].fiber_); } @@ -256,6 +257,7 @@ class context_impl delete condvar_alloc_; delete sema_alloc_; delete event_alloc_; + free(seq_cst_fence_order_); } void construct_current_test_suite() @@ -350,7 +352,7 @@ class context_impl (::free)(p); return; } - + disable_alloc_ += 1; debug_info const& info = last_info_; RL_HIST_CTX(memory_free_event) {p, false} RL_HIST_END(); @@ -649,17 +651,19 @@ class context_impl return test_result_success; } - RL_INLINE static void reset_thread(thread_info& ti) + RL_INLINE static void reset_thread(thread_id_t thread_count, thread_info<>& ti) { - foreach( + foreach( + thread_count, ti.acquire_fence_order_, &assign_zero); - foreach( + foreach( + thread_count, ti.release_fence_order_, &assign_zero); #ifdef RL_IMPROVED_SEQ_CST_FENCE - foreach(ti.imp_seq_cst_order_, &assign_zero); + foreach(thread_count, ti.imp_seq_cst_order_, &assign_zero); #endif } @@ -669,17 +673,19 @@ class context_impl disable_preemption_ = 0; sched_count_ = 0; - foreach( - threads_, - &context_impl::reset_thread); + for (thread_id_t i = 0; i != thread_count_; i++) + { + context_impl::reset_thread(thread_count_, threads_[i]); + } - foreach( + foreach( + thread_count_, seq_cst_fence_order_, &assign_zero); base_t::iteration_begin(); - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { threads_[i].iteration_begin(); } @@ -757,15 +763,15 @@ class context_impl void rl_global_fence() { timestamp_t max_acq_rel = 0; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { if (threads_[i].acq_rel_order_[i] > max_acq_rel) max_acq_rel = threads_[i].acq_rel_order_[i]; } - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { - for (thread_id_t j = 0; j != thread_count; ++j) + for (thread_id_t j = 0; j != thread_count_; ++j) { threads_[i].acq_rel_order_[j] = max_acq_rel; } @@ -795,54 +801,54 @@ class context_impl virtual thread_id_t get_thread_count() const { - return thread_count; + return thread_count_; } virtual generic_mutex_data* mutex_ctor(bool is_rw, bool is_exclusive_recursive, bool is_shared_recursive, bool failing_try_lock) { - return new (mutex_alloc_->alloc()) generic_mutex_data_impl(is_rw, is_exclusive_recursive, is_shared_recursive, failing_try_lock); + return new (mutex_alloc_->alloc()) generic_mutex_data_impl(thread_count_, is_rw, is_exclusive_recursive, is_shared_recursive, failing_try_lock); } virtual void mutex_dtor(generic_mutex_data* m) { - generic_mutex_data_impl* mm = static_cast*>(m); - mm->~generic_mutex_data_impl(); + generic_mutex_data_impl* mm = static_cast(m); + mm->~generic_mutex_data_impl(); mutex_alloc_->free(mm); } virtual condvar_data* condvar_ctor(bool allow_spurious_wakeups) { - return new (condvar_alloc_->alloc()) condvar_data_impl(allow_spurious_wakeups); + return new (condvar_alloc_->alloc()) condvar_data_impl(thread_count_, allow_spurious_wakeups); } virtual void condvar_dtor(condvar_data* cv) { - condvar_data_impl* mm = static_cast*>(cv); - mm->~condvar_data_impl(); + condvar_data_impl* mm = static_cast(cv); + mm->~condvar_data_impl(); condvar_alloc_->free(mm); } virtual sema_data* sema_ctor(bool spurious_wakeups, unsigned initial_count, unsigned max_count) { - return new (sema_alloc_->alloc()) sema_data_impl(spurious_wakeups, initial_count, max_count); + return new (sema_alloc_->alloc()) sema_data_impl(thread_count_, spurious_wakeups, initial_count, max_count); } virtual void sema_dtor(sema_data* cv) { - sema_data_impl* mm = static_cast*>(cv); - mm->~sema_data_impl(); + sema_data_impl* mm = static_cast(cv); + mm->~sema_data_impl(); sema_alloc_->free(mm); } virtual event_data* event_ctor(bool manual_reset, bool initial_state) { - return new (event_alloc_->alloc()) event_data_impl(manual_reset, initial_state); + return new (event_alloc_->alloc()) event_data_impl(thread_count_, manual_reset, initial_state); } virtual void event_dtor(event_data* cv) { - event_data_impl* mm = static_cast*>(cv); - mm->~event_data_impl(); + event_data_impl* mm = static_cast(cv); + mm->~event_data_impl(); event_alloc_->free(mm); } @@ -876,7 +882,7 @@ unsigned __stdcall thread_func(void * ctx) */ template -test_result_e run_test(test_params& params, std::ostream& oss, bool second) +test_result_e run_test(test_params& params, std::ostream& oss, bool second, thread_id_t thread_count) { typedef context_impl context_t; typedef typename sched_t::shared_context_t shared_context_t; @@ -901,7 +907,7 @@ test_result_e run_test(test_params& params, std::ostream& oss, bool second) //if (second == false) { istringstream iss (params.initial_state); - res = context_t(params, sctx).simulate(oss, iss, second); + res = context_t(params, sctx, thread_count).simulate(oss, iss, second); } //else //{ @@ -941,10 +947,10 @@ test_result_e run_test(test_params& params, std::ostream& oss, bool second) template -bool simulate(test_params& params) +bool simulate(test_params& params, thread_id_t thread_count) { char const* test_name = typeid(test_t).name(); - while (test_name[0] >= '0' && test_name[0] <= '9') + while (test_name[0] >= '0' && test_name[0] <= '9') test_name += 1; params.test_name = test_name; *params.output_stream << params.test_name << std::endl; @@ -957,11 +963,11 @@ bool simulate(test_params& params) //istringstream iss (params.initial_state); test_result_e res = test_result_success; if (random_scheduler_type == params.search_type) - res = run_test >(params, oss, false); + res = run_test(params, oss, false, thread_count); else if (fair_full_search_scheduler_type == params.search_type) - res = run_test >(params, oss, false); + res = run_test(params, oss, false, thread_count); else if (fair_context_bound_scheduler_type == params.search_type) - res = run_test >(params, oss, false); + res = run_test(params, oss, false, thread_count); else RL_VERIFY(false); @@ -986,11 +992,11 @@ bool simulate(test_params& params) iteration_t const stop_iter = params.stop_iteration; test_result_e res2 = test_result_success; if (random_scheduler_type == params.search_type) - res2 = run_test >(params, oss2, true); + res2 = run_test(params, oss2, true, thread_count); else if (fair_full_search_scheduler_type == params.search_type) - res2 = run_test >(params, oss2, true); + res2 = run_test(params, oss2, true, thread_count); else if (fair_context_bound_scheduler_type == params.search_type) - res2 = run_test >(params, oss2, true); + res2 = run_test(params, oss2, true, thread_count); else RL_VERIFY(false); @@ -1004,36 +1010,84 @@ bool simulate(test_params& params) (void)stop_iter; (void)res2; } - return test_t::params::expected_result == res; + return params.expected_result == res; +} + +template +struct enable_if +{ +}; + +template +struct enable_if +{ + typedef T type; +}; + +template +struct has_params +{ + static const bool value = false; +}; + +template +struct has_params +{ + static const bool value = true; +}; + +template +typename enable_if::value && test_t::params::static_thread_count >= 0 && test_t::params::dynamic_thread_count >= 0 && test_t::params::thread_count >= 1, bool>::type +simulate(test_params& params) +{ + params.static_thread_count = test_t::params::static_thread_count; + params.dynamic_thread_count = test_t::params::dynamic_thread_count; + params.expected_result = test_t::params::expected_result; + return simulate(params, test_t::params::thread_count); +} + +template +typename enable_if::value, bool>::type +simulate(test_params& params) +{ + return simulate(params, params.static_thread_count + params.dynamic_thread_count); } template bool simulate() { test_params params; - return simulate(params); + params.static_thread_count = test_t::params::static_thread_count; + params.dynamic_thread_count = test_t::params::dynamic_thread_count; + params.expected_result = test_t::params::expected_result; + return simulate(params, test_t::params::thread_count); } -template -struct simulate_thunk : test_suite, 1> +template +struct simulate_thunk { - static size_t const dynamic_thread_count = thread_count; void thread(unsigned) { func(); } + + void before() { } + void after() { } + void invariant() { } }; template bool execute(test_params& params) { - return simulate >(params); + params.dynamic_thread_count = thread_count; + params.static_thread_count = 1; + return simulate >(params); } -template -bool execute() +template +bool execute(test_params& params) { - return simulate >(); + return simulate >(params); } typedef bool (*simulate_f)(test_params&); @@ -1215,6 +1269,11 @@ inline void systemwide_fence(debug_info_param info) } // namespace rl +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winline-new-delete" +#endif + #ifndef RL_GC inline void* operator new (size_t size, rl::debug_info_param info) { @@ -1255,7 +1314,7 @@ inline void operator delete (void* p, void(*dtor)(void*), rl::debug_info_param i inline void* operator new (size_t size) RL_THROW_SPEC(std::bad_alloc) { - if (&rl::ctx()) + if (rl::is_ctx()) return rl::ctx().alloc(size); else return (::malloc)(size); @@ -1263,7 +1322,7 @@ inline void* operator new (size_t size) RL_THROW_SPEC(std::bad_alloc) inline void* operator new [] (size_t size) RL_THROW_SPEC(std::bad_alloc) { - if (&rl::ctx()) + if (rl::is_ctx()) return rl::ctx().alloc(size); else return (::malloc)(size); @@ -1271,7 +1330,7 @@ inline void* operator new [] (size_t size) RL_THROW_SPEC(std::bad_alloc) inline void operator delete (void* p) throw() { - if (&rl::ctx()) + if (rl::is_ctx()) rl::ctx().free(p); else (::free)(p); @@ -1279,12 +1338,16 @@ inline void operator delete (void* p) throw() inline void operator delete [] (void* p) throw() { - if (&rl::ctx()) + if (rl::is_ctx()) rl::ctx().free(p); else (::free)(p); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #define RL_NEW_PROXY rl::new_proxy($) % new #define RL_DELETE_PROXY rl::delete_proxy($) , delete diff --git a/relacy/context_addr_hash.hpp b/relacy/context_addr_hash.hpp index cf24b41..0ceaf0b 100644 --- a/relacy/context_addr_hash.hpp +++ b/relacy/context_addr_hash.hpp @@ -15,21 +15,16 @@ #include "base.hpp" - namespace rl { - struct context_addr_hash_iface { virtual size_t get_addr_hash (void const* p) = 0; virtual ~context_addr_hash_iface () {} // to calm down g++ }; - - - -template +template class context_addr_hash_impl : protected base_t { public: @@ -75,7 +70,6 @@ class context_addr_hash_impl : protected base_t } }; - } #endif diff --git a/relacy/context_base.hpp b/relacy/context_base.hpp index 1745399..fce2886 100644 --- a/relacy/context_base.hpp +++ b/relacy/context_base.hpp @@ -102,6 +102,11 @@ class context return *context_holder<>::instance_; } + static bool is_instance() + { + return context_holder<>::instance_; + } + virtual atomic_data* atomic_ctor(void* ctx) = 0; virtual void atomic_dtor(atomic_data* data) = 0; @@ -254,6 +259,11 @@ inline context& ctx() return context::instance(); } +inline bool is_ctx() +{ + return context::is_instance(); +} + inline int get_errno() { diff --git a/relacy/defs.hpp b/relacy/defs.hpp index a620ed0..8bf0787 100644 --- a/relacy/defs.hpp +++ b/relacy/defs.hpp @@ -44,6 +44,7 @@ enum unpark_reason unpark_reason_normal, unpark_reason_timeout, unpark_reason_spurious, + unpark_reason_unknown }; struct debug_info diff --git a/relacy/dyn_thread_ctx.hpp b/relacy/dyn_thread_ctx.hpp index 5e28296..799e905 100644 --- a/relacy/dyn_thread_ctx.hpp +++ b/relacy/dyn_thread_ctx.hpp @@ -23,12 +23,12 @@ namespace rl { - -template class thread_sync_object : public win_waitable_object { public: - thread_sync_object() + thread_sync_object(thread_id_t thread_count) + : ws_(thread_count) + , sync_(thread_count) { } @@ -62,8 +62,8 @@ class thread_sync_object : public win_waitable_object private: bool finished_; - waitset ws_; - sync_var sync_; + waitset<> ws_; + sync_var sync_; virtual void deinit(debug_info_param info) { diff --git a/relacy/foreach.hpp b/relacy/foreach.hpp index d045755..ef0f035 100644 --- a/relacy/foreach.hpp +++ b/relacy/foreach.hpp @@ -18,81 +18,40 @@ namespace rl { - -template -struct foreach_thread_impl -{ - template - RL_INLINE static void exec( - T* v1, - F func) - { - (*func)(v1[i]); - foreach_thread_impl::exec(v1, func); - } - - RL_INLINE static void exec( - T* v1, T* v2, - void (*func)(T& e1, T& e2)) - { - (*func)(v1[i], v2[i]); - foreach_thread_impl::exec(v1, v2, func); - } - - RL_INLINE static void exec( - T* v1, T* v2, T* v3, - void (*func)(T& e1, T& e2, T& e3)) - { - (*func)(v1[i], v2[i], v3[i]); - foreach_thread_impl::exec(v1, v2, v3, func); - } -}; - -template -struct foreach_thread_impl -{ - template - RL_INLINE static void exec( - T*, - F) - { - } - - RL_INLINE static void exec( - T*, T*, - void (*)(T&, T&)) - { - } - - RL_INLINE static void exec( - T*, T*, T*, - void (*)(T&, T&, T&)) - { - } -}; - -template +template RL_INLINE void foreach( + thread_id_t count, T* v1, F func) { - foreach_thread_impl::exec(v1, func); + for (thread_id_t i = 0; i < count; i++) + { + (*func)(v1[i]); + } } -template +template RL_INLINE void foreach( + thread_id_t count, T* v1, T* v2, void (*func)(T& e1, T& e2)) { - foreach_thread_impl::exec(v1, v2, func); + for (thread_id_t i = 0; i < count; i++) + { + (*func)(v1[i], v2[i]); + } } -template +template RL_INLINE void foreach( + thread_id_t count, T* v1, T* v2, T* v3, void (*func)(T& e1, T& e2, T& e3)) { - foreach_thread_impl::exec(v1, v2, v3, func); + for (thread_id_t i = 0; i < count; i++) + { + (*func)(v1[i], v2[i], v3[i]); + } } RL_INLINE void assign_zero(timestamp_t& elem) diff --git a/relacy/java_atomic.hpp b/relacy/java_atomic.hpp index 8785030..ebc2fca 100644 --- a/relacy/java_atomic.hpp +++ b/relacy/java_atomic.hpp @@ -122,6 +122,7 @@ class jatomic : generic_atomic } jatomic(jatomic const& r) + : generic_atomic() { T const value = r.load(mo_seq_cst, $); //??? whether here must be mo_relaxed or mo_release? diff --git a/relacy/java_volatile.hpp b/relacy/java_volatile.hpp index 11be144..9c88dd1 100644 --- a/relacy/java_volatile.hpp +++ b/relacy/java_volatile.hpp @@ -132,6 +132,7 @@ class jvolatile : generic_atomic } jvolatile(jvolatile const& r) + : generic_atomic() { T const value = r.load(mo_seq_cst, $); //??? whether here must be mo_relaxed or mo_release? diff --git a/relacy/platform.hpp b/relacy/platform.hpp index 47dfe4f..6940e70 100644 --- a/relacy/platform.hpp +++ b/relacy/platform.hpp @@ -214,6 +214,7 @@ inline void create_fiber(fiber_t& fib, void(*ufnc)(void*), void* uctx) inline void delete_fiber(fiber_t& fib) { + (void)fib; //(::free)(fib.uc_stack.ss_sp); } diff --git a/relacy/relacy.hpp b/relacy/relacy.hpp index 183d24a..542e371 100644 --- a/relacy/relacy.hpp +++ b/relacy/relacy.hpp @@ -22,7 +22,6 @@ #include "atomic.hpp" #include "var.hpp" #include "thread_local.hpp" -#include "test_suite.hpp" #include "dyn_thread.hpp" #include "stdlib/mutex.hpp" diff --git a/relacy/context_bound_scheduler.hpp b/relacy/schedulers/context_bound_scheduler.hpp similarity index 81% rename from relacy/context_bound_scheduler.hpp rename to relacy/schedulers/context_bound_scheduler.hpp index 440260c..0ec7e17 100644 --- a/relacy/context_bound_scheduler.hpp +++ b/relacy/schedulers/context_bound_scheduler.hpp @@ -13,45 +13,42 @@ # pragma once #endif -#include "base.hpp" +#include "../base.hpp" #include "full_search_scheduler.hpp" -#include "foreach.hpp" - +#include "../foreach.hpp" namespace rl { - -template -struct context_bound_scheduler_thread_info : tree_search_scheduler_thread_info +struct context_bound_scheduler_thread_info : tree_search_scheduler_thread_info { unsigned sched_count_; unsigned forced_context_switch_count_; + context_bound_scheduler_thread_info(thread_id_t thread_count) + : tree_search_scheduler_thread_info(thread_count) + { + + } + void reset(test_params& params) { - tree_search_scheduler_thread_info::reset(params); + tree_search_scheduler_thread_info::reset(params); sched_count_ = 0; forced_context_switch_count_ = 0; } }; - - - -template class context_bound_scheduler - : public tree_search_scheduler - , context_bound_scheduler_thread_info, thread_count> + : public tree_search_scheduler { public: - typedef tree_search_scheduler - , context_bound_scheduler_thread_info, thread_count> base_t; - typedef typename base_t::thread_info_t thread_info_t; - typedef typename base_t::shared_context_t shared_context_t; + typedef tree_search_scheduler base_t; + typedef base_t::thread_info_t thread_info_t; + typedef base_t::shared_context_t shared_context_t; - context_bound_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count) - : base_t(params, ctx, dynamic_thread_count) + context_bound_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count, thread_id_t thread_count) + : base_t(params, ctx, dynamic_thread_count, thread_count) { } diff --git a/relacy/full_search_scheduler.hpp b/relacy/schedulers/full_search_scheduler.hpp similarity index 81% rename from relacy/full_search_scheduler.hpp rename to relacy/schedulers/full_search_scheduler.hpp index 2c256c4..1ae1e67 100644 --- a/relacy/full_search_scheduler.hpp +++ b/relacy/schedulers/full_search_scheduler.hpp @@ -13,42 +13,58 @@ # pragma once #endif -#include "base.hpp" +#include "../base.hpp" #include "scheduler.hpp" -#include "foreach.hpp" - +#include "../foreach.hpp" namespace rl { - -template struct tree_search_scheduler_thread_info : scheduler_thread_info { - unsigned yield_sched_count_ [thread_count]; - unsigned yield_priority_ [thread_count]; + unsigned* yield_sched_count_; + unsigned* yield_priority_; unsigned total_yield_priority_; //unsigned subsequent_timed_waits_; + tree_search_scheduler_thread_info(thread_id_t thread_count) + : scheduler_thread_info(thread_count) + , yield_sched_count_(static_cast(calloc(thread_count, sizeof(unsigned)))) + , yield_priority_(static_cast(calloc(thread_count, sizeof(unsigned)))) + , thread_count_(thread_count) + { + } + + ~tree_search_scheduler_thread_info() + { + free(yield_sched_count_); + free(yield_priority_); + } + void reset(test_params& params) { scheduler_thread_info::reset(params); - foreach(yield_sched_count_, &assign_zero_u); - foreach(yield_priority_, &assign_zero_u); + foreach(thread_count_, yield_sched_count_, &assign_zero_u); + foreach(thread_count_, yield_priority_, &assign_zero_u); total_yield_priority_ = 0; //subsequent_timed_waits_ = 0; } + +private: + tree_search_scheduler_thread_info(const tree_search_scheduler_thread_info&); + tree_search_scheduler_thread_info operator=(const tree_search_scheduler_thread_info&); + thread_id_t const thread_count_; }; -template +template class tree_search_scheduler - : public scheduler + : public scheduler { public: - typedef scheduler base_t; + typedef scheduler base_t; typedef typename base_t::thread_info_t thread_info_t; typedef typename base_t::shared_context_t shared_context_t; @@ -56,11 +72,12 @@ class tree_search_scheduler { }; - tree_search_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count) - : base_t(params, ctx, dynamic_thread_count) + tree_search_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count, thread_id_t thread_count) + : base_t(params, ctx, dynamic_thread_count, thread_count) , stree_depth_() , iteration_count_mean_() , iteration_count_probe_count_() + , thread_count_(thread_count) { stree_.reserve(128); } @@ -99,7 +116,7 @@ class tree_search_scheduler thread_info_t& t = *this->thread_; thread_id_t const& running_thread_count = this->running_threads_count; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { thread_info_t& y = this->threads_[i]; RL_VERIFY(0 == y.yield_priority_[t.index_]); @@ -127,7 +144,7 @@ class tree_search_scheduler #ifdef _DEBUG { unsigned tmp = 0; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) tmp += t.yield_priority_[i]; RL_VERIFY(t.total_yield_priority_ == tmp); } @@ -135,7 +152,7 @@ class tree_search_scheduler if (t.total_yield_priority_) { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { unsigned& prio = t.yield_priority_[i]; if (prio) @@ -246,7 +263,7 @@ class tree_search_scheduler void purge_blocked_threads() { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { on_thread_block(i, false); } @@ -258,7 +275,7 @@ class tree_search_scheduler size_t const size = stree_.size(); if (stree_depth_ == size) { - stree_node n = {limit, 0, t}; + stree_node n = {limit, 0, t, 0}; stree_.push_back(n); } else @@ -331,7 +348,7 @@ class tree_search_scheduler thread_info_t& t = this->threads_[th]; if (t.total_yield_priority_) { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { if (t.yield_priority_[i]) { @@ -363,6 +380,7 @@ class tree_search_scheduler private: double iteration_count_mean_; unsigned iteration_count_probe_count_; + thread_id_t const thread_count_; derived_t& self() { @@ -372,22 +390,16 @@ class tree_search_scheduler RL_NOCOPY(tree_search_scheduler); }; - - - -template class full_search_scheduler - : public tree_search_scheduler - , tree_search_scheduler_thread_info, thread_count> + : public tree_search_scheduler { public: - typedef tree_search_scheduler - , tree_search_scheduler_thread_info, thread_count> base_t; - typedef typename base_t::thread_info_t thread_info_t; - typedef typename base_t::shared_context_t shared_context_t; + typedef tree_search_scheduler base_t; + typedef base_t::thread_info_t thread_info_t; + typedef base_t::shared_context_t shared_context_t; - full_search_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count) - : base_t(params, ctx, dynamic_thread_count) + full_search_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count, thread_id_t thread_count) + : base_t(params, ctx, dynamic_thread_count, thread_count) { } @@ -414,8 +426,6 @@ class full_search_scheduler RL_NOCOPY(full_search_scheduler); }; - } #endif - diff --git a/relacy/random_scheduler.hpp b/relacy/schedulers/random_scheduler.hpp similarity index 84% rename from relacy/random_scheduler.hpp rename to relacy/schedulers/random_scheduler.hpp index 3a91f14..a1f071c 100644 --- a/relacy/random_scheduler.hpp +++ b/relacy/schedulers/random_scheduler.hpp @@ -13,29 +13,26 @@ # pragma once #endif -#include "base.hpp" +#include "../base.hpp" #include "scheduler.hpp" -#include "random.hpp" - +#include "../random.hpp" namespace rl { - -template -class random_scheduler : public scheduler, scheduler_thread_info, thread_count> +class random_scheduler : public scheduler { public: - typedef scheduler, scheduler_thread_info, thread_count> base_t; - typedef typename base_t::thread_info_t thread_info_t; - typedef typename base_t::shared_context_t shared_context_t; + typedef scheduler base_t; + typedef base_t::thread_info_t thread_info_t; + typedef base_t::shared_context_t shared_context_t; struct task_t { }; - random_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count) - : base_t(params, ctx, dynamic_thread_count) + random_scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count, thread_id_t thread_count) + : base_t(params, ctx, dynamic_thread_count, thread_count) { } diff --git a/relacy/scheduler.hpp b/relacy/schedulers/scheduler.hpp similarity index 77% rename from relacy/scheduler.hpp rename to relacy/schedulers/scheduler.hpp index 8e13112..0bcbdb2 100644 --- a/relacy/scheduler.hpp +++ b/relacy/schedulers/scheduler.hpp @@ -13,8 +13,8 @@ # pragma once #endif -#include "base.hpp" -#include "context_base.hpp" +#include "../base.hpp" +#include "../context_base.hpp" namespace rl @@ -35,14 +35,17 @@ enum thread_finish_result thread_finish_result_deadlock, }; - - struct scheduler_thread_info { thread_id_t index_; unsigned block_count_; thread_state_e state_; + scheduler_thread_info(thread_id_t thread_count) + { + (void)thread_count; + } + void reset(test_params& /*params*/) { block_count_ = 0; @@ -50,10 +53,7 @@ struct scheduler_thread_info } }; - - - -template +template class scheduler : nocopy<> { public: @@ -66,14 +66,24 @@ class scheduler : nocopy<> queue queue_; }; - scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count) + scheduler(test_params& params, shared_context_t& ctx, thread_id_t dynamic_thread_count, thread_id_t thread_count) : params_(params) , ctx_(ctx) , total_dynamic_threads_(dynamic_thread_count) , iter_() + , threads_(static_cast(calloc(thread_count, sizeof(thread_info_t)))) , thread_() + , timed_threads_(static_cast(calloc(thread_count, sizeof(thread_info_t*)))) + , spurious_threads_(static_cast(calloc(thread_count, sizeof(thread_info_t*)))) + , dynamic_threads_(static_cast(calloc(thread_count, sizeof(thread_info_t*)))) + , thread_count_(thread_count) { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) + { + new (threads_ + i) thread_info_t (thread_count); + } + + for (thread_id_t i = 0; i != thread_count_; ++i) { threads_[i].index_ = i; } @@ -82,19 +92,19 @@ class scheduler : nocopy<> thread_id_t iteration_begin(iteration_t iter) { iter_ = iter; - running_threads_count = thread_count; + running_threads_count = thread_count_; finished_thread_count_ = 0; timed_thread_count_ = 0; spurious_thread_count_ = 0; dynamic_thread_count_ = 0; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { running_threads.push_back(i); threads_[i].reset(params_); } - for (thread_id_t i = thread_count - total_dynamic_threads_; i != thread_count; ++i) + for (thread_id_t i = thread_count_ - total_dynamic_threads_; i != thread_count_; ++i) { dynamic_threads_[dynamic_thread_count_++] = &threads_[i]; block_thread(i, false); @@ -143,13 +153,13 @@ class scheduler : nocopy<> if (is_timed) { timed_threads_[timed_thread_count_++] = thread_; - RL_VERIFY(timed_thread_count_ <= thread_count); + RL_VERIFY(timed_thread_count_ <= thread_count_); } if (allow_spurious_wakeup) { spurious_threads_[spurious_thread_count_++] = thread_; - RL_VERIFY(spurious_thread_count_ <= thread_count); + RL_VERIFY(spurious_thread_count_ <= thread_count_); } block_thread(thread_->index_, true); @@ -198,7 +208,7 @@ class scheduler : nocopy<> finished_thread_count_ += 1; self().thread_finished_impl(); retry: - if (finished_thread_count_ == thread_count) + if (finished_thread_count_ == thread_count_) { return thread_finish_result_last; } @@ -239,13 +249,26 @@ class scheduler : nocopy<> self().set_state_impl(ss); } + ~scheduler() + { + for (thread_id_t i = 0; i != thread_count_; ++i) + { + threads_[i].~thread_info_t(); + } + + free(threads_); + free(timed_threads_); + free(spurious_threads_); + free(dynamic_threads_); + } + protected: test_params& params_; shared_context_t& ctx_; thread_id_t const total_dynamic_threads_; iteration_t iter_; - aligned threads_ [thread_count]; + thread_info_t* threads_; thread_info_t* thread_; vector::type running_threads; @@ -255,18 +278,19 @@ class scheduler : nocopy<> //!!! doesn't timed/spurious waits must belong to full scheduler? // hyphotesis: random scheduler can ignore timed/spurious waits // (however must detect deadlock with spurious threads) - thread_info_t* timed_threads_ [thread_count]; + thread_info_t** timed_threads_; thread_id_t timed_thread_count_; - thread_info_t* spurious_threads_ [thread_count]; + thread_info_t** spurious_threads_; thread_id_t spurious_thread_count_; - thread_info_t* dynamic_threads_ [thread_count]; + thread_info_t** dynamic_threads_; thread_id_t dynamic_thread_count_; + thread_id_t const thread_count_; void block_thread(thread_id_t th, bool yield) { - RL_VERIFY(th < thread_count); + RL_VERIFY(th < thread_count_); thread_info_t& t = threads_[th]; RL_VERIFY(t.state_ != thread_state_finished); if (t.block_count_++) @@ -288,7 +312,7 @@ class scheduler : nocopy<> bool unblock_thread(thread_id_t th) { - RL_VERIFY(th < thread_count); + RL_VERIFY(th < thread_count_); thread_info_t& t = threads_[th]; RL_VERIFY(t.state_ == thread_state_blocked); if (--t.block_count_) @@ -301,6 +325,9 @@ class scheduler : nocopy<> } private: + scheduler(const scheduler&); + scheduler& operator=(const scheduler&); + derived_t& self() { return *static_cast(this); diff --git a/relacy/stdlib/condition_variable.hpp b/relacy/stdlib/condition_variable.hpp index fbc8716..12147e1 100644 --- a/relacy/stdlib/condition_variable.hpp +++ b/relacy/stdlib/condition_variable.hpp @@ -90,11 +90,11 @@ struct condvar_data virtual ~condvar_data() {} // just to calm down gcc }; -template class condvar_data_impl : public condvar_data { public: - condvar_data_impl(bool allow_spurious_wakeups) + condvar_data_impl(thread_id_t thread_count, bool allow_spurious_wakeups) + : ws_(thread_count) { spurious_wakeup_limit_ = 0; if (allow_spurious_wakeups && ctx().is_random_sched()) @@ -107,7 +107,7 @@ class condvar_data_impl : public condvar_data } private: - waitset ws_; + waitset<> ws_; signature<0xc0ffe3ad> sign_; int spurious_wakeup_limit_; @@ -161,7 +161,7 @@ class condvar_data_impl : public condvar_data //??? do I need this scheduler call? c.sched(); sign_.check(info); - RL_HIST(event_t) {this, event_t::type_notify_one, ws_.size()} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_notify_one, ws_.size(), unpark_reason_unknown} RL_HIST_END(); ws_.unpark_one(c, info); } @@ -171,7 +171,7 @@ class condvar_data_impl : public condvar_data //??? do I need this scheduler call? c.sched(); sign_.check(info); - RL_HIST(event_t) {this, event_t::type_notify_all, ws_.size()} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_notify_all, ws_.size(), unpark_reason_unknown} RL_HIST_END(); ws_.unpark_all(c, info); } @@ -180,7 +180,7 @@ class condvar_data_impl : public condvar_data //!!! detect whether mutex is the same context& c = ctx(); sign_.check(info); - RL_HIST(event_t) {this, event_t::type_wait_enter} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_wait_enter, ws_.size(), unpark_reason_unknown} RL_HIST_END(); lock.unlock(info); sign_.check(info); bool allow_spurious_wakeup = (spurious_wakeup_limit_ > 0); @@ -202,17 +202,17 @@ class condvar_data_impl : public condvar_data { context& c = ctx(); sign_.check(info); - RL_HIST(event_t) {this, event_t::type_wait_pred_enter} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_wait_pred_enter, ws_.size(), unpark_reason_unknown} RL_HIST_END(); while (!pred.exec()) { sema_wakeup_reason reason = wait(lock, is_timed, info); if (reason == sema_wakeup_reason_timeout) { - RL_HIST(event_t) {this, event_t::type_wait_pred_exit} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_wait_pred_exit, ws_.size(), unpark_reason_unknown} RL_HIST_END(); return pred.exec(); } } - RL_HIST(event_t) {this, event_t::type_wait_pred_exit} RL_HIST_END(); + RL_HIST(event_t) {this, event_t::type_wait_pred_exit, ws_.size(), unpark_reason_unknown} RL_HIST_END(); return true; } }; diff --git a/relacy/stdlib/event.hpp b/relacy/stdlib/event.hpp index 5f209e0..fa5e079 100644 --- a/relacy/stdlib/event.hpp +++ b/relacy/stdlib/event.hpp @@ -36,16 +36,14 @@ struct event_data virtual ~event_data() {} // just to calm down gcc }; - - - -template class event_data_impl : public event_data { public: - event_data_impl(bool manual_reset, bool initial_state) + event_data_impl(thread_id_t thread_count, bool manual_reset, bool initial_state) : manual_reset_(manual_reset) , state_(initial_state) + , ws_(thread_count) + , sync_(thread_count) { } @@ -58,8 +56,8 @@ class event_data_impl : public event_data signature<0xdada1234> sign_; bool const manual_reset_; bool state_; - waitset ws_; - sync_var sync_; + waitset<> ws_; + sync_var sync_; struct state_event { diff --git a/relacy/stdlib/mutex.hpp b/relacy/stdlib/mutex.hpp index e522bdc..116f94b 100644 --- a/relacy/stdlib/mutex.hpp +++ b/relacy/stdlib/mutex.hpp @@ -43,8 +43,6 @@ struct generic_mutex_data : nocopy<> virtual ~generic_mutex_data() {} // just to calm down gcc }; - -template class generic_mutex_data_impl : public generic_mutex_data { public: @@ -94,20 +92,24 @@ class generic_mutex_data_impl : public generic_mutex_data } }; - generic_mutex_data_impl(bool is_rw, bool is_exclusive_recursive, bool is_shared_recursive, bool failing_try_lock) + generic_mutex_data_impl(thread_id_t thread_count, bool is_rw, bool is_exclusive_recursive, bool is_shared_recursive, bool failing_try_lock) : is_rw_(is_rw) , is_exclusive_recursive_(is_exclusive_recursive) , is_shared_recursive_(is_shared_recursive) , failing_try_lock_(failing_try_lock) + , sync_(thread_count) , exclusive_owner_(state_free) , exclusive_recursion_count_(0) + , exclusive_waitset_(thread_count) + , shared_waitset_(thread_count) + , shared_owner_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) , shared_lock_count_(0) , try_lock_failed_() { context& c = ctx(); (void)c; RL_VERIFY(false == c.invariant_executing); - foreach(shared_owner_, &assign_zero); + foreach(thread_count, shared_owner_, &assign_zero); } ~generic_mutex_data_impl() @@ -122,6 +124,7 @@ class generic_mutex_data_impl : public generic_mutex_data RL_HIST(event_t) {this, event_t::type_destroying_owned_mutex} RL_HIST_END(); RL_ASSERT_IMPL(false, test_result_destroying_owned_mutex, "", $); } + free(shared_owner_); } virtual bool lock_exclusive(bool is_timed, debug_info_param info) @@ -472,12 +475,12 @@ class generic_mutex_data_impl : public generic_mutex_data bool is_exclusive_recursive_; bool is_shared_recursive_; bool failing_try_lock_; - sync_var sync_; + sync_var sync_; thread_id_t exclusive_owner_; unsigned exclusive_recursion_count_; - waitset exclusive_waitset_; - waitset shared_waitset_; - timestamp_t shared_owner_ [thread_count]; + waitset<> exclusive_waitset_; + waitset<> shared_waitset_; + timestamp_t* shared_owner_; unsigned shared_lock_count_; bool try_lock_failed_; diff --git a/relacy/stdlib/semaphore.hpp b/relacy/stdlib/semaphore.hpp index 223a867..070d73a 100644 --- a/relacy/stdlib/semaphore.hpp +++ b/relacy/stdlib/semaphore.hpp @@ -47,9 +47,6 @@ struct win_waitable_object : win_object virtual void* prepare_wait(debug_info_param info) = 0; }; - - - struct sema_data { virtual sema_wakeup_reason wait(bool try_wait, bool is_timed, debug_info_param info) = 0; @@ -61,17 +58,15 @@ struct sema_data virtual ~sema_data() {} // just to calm down gcc }; - - - -template class sema_data_impl : public sema_data { public: - sema_data_impl(bool spurious_wakeups, unsigned initial_count, unsigned max_count) + sema_data_impl(thread_id_t thread_count, bool spurious_wakeups, unsigned initial_count, unsigned max_count) : spurious_wakeups_(spurious_wakeups) , count_(initial_count) , max_count_(max_count) + , ws_(thread_count) + , sync_(thread_count) { RL_VERIFY(max_count <= INT_MAX); } @@ -251,8 +246,8 @@ class sema_data_impl : public sema_data bool const spurious_wakeups_; unsigned count_; unsigned const max_count_; - waitset ws_; - sync_var sync_; + waitset<> ws_; + sync_var sync_; virtual bool is_signaled(debug_info_param info) { diff --git a/relacy/sync_var.hpp b/relacy/sync_var.hpp index c69302a..ea9579b 100644 --- a/relacy/sync_var.hpp +++ b/relacy/sync_var.hpp @@ -20,31 +20,36 @@ namespace rl { - -template class sync_var : nocopy<> { public: - sync_var() + sync_var(thread_id_t thread_count) + : thread_count_(thread_count) + , order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) { iteration_begin(); } + ~sync_var() + { + free(order_); + } + void iteration_begin() { - foreach(order_, &assign_zero); + foreach(thread_count_, order_, &assign_zero); } void acquire(thread_info_base* th) { th->own_acq_rel_order_ += 1; - foreach(th->acq_rel_order_, order_, &assign_max); + foreach(thread_count_, th->acq_rel_order_, order_, &assign_max); } void release(thread_info_base* th) { th->own_acq_rel_order_ += 1; - foreach(order_, th->acq_rel_order_, &assign_max); + foreach(thread_count_, order_, th->acq_rel_order_, &assign_max); } void acq_rel(thread_info_base* th) @@ -52,12 +57,16 @@ class sync_var : nocopy<> th->own_acq_rel_order_ += 1; timestamp_t* acq_rel_order = th->acq_rel_order_; timestamp_t* order = order_; - foreach(acq_rel_order, order, &assign_max); - foreach(order, acq_rel_order, &assign_max); + foreach(thread_count_, acq_rel_order, order, &assign_max); + foreach(thread_count_, order, acq_rel_order, &assign_max); } private: - timestamp_t order_ [thread_count]; + sync_var(const sync_var&); + sync_var& operator=(const sync_var&); + + thread_id_t thread_count_; + timestamp_t* order_; }; diff --git a/relacy/test_params.hpp b/relacy/test_params.hpp index 9b2ee04..0c215d0 100644 --- a/relacy/test_params.hpp +++ b/relacy/test_params.hpp @@ -60,6 +60,7 @@ struct test_params unsigned context_bound; unsigned execution_depth_limit; string initial_state; + test_result_e expected_result; // output params test_result_e test_result; @@ -67,6 +68,10 @@ struct test_params string test_name; string final_state; + // threads + thread_id_t dynamic_thread_count; + thread_id_t static_thread_count; + test_params() { iteration_count = 1000; @@ -78,9 +83,12 @@ struct test_params search_type = random_scheduler_type; context_bound = 1; execution_depth_limit = 2000; + expected_result = test_result_success; test_result = test_result_success; stop_iteration = 0; + dynamic_thread_count = 0; + static_thread_count = 0; } }; diff --git a/relacy/test_suite.hpp b/relacy/test_suite.hpp index 86c44ea..795e70f 100644 --- a/relacy/test_suite.hpp +++ b/relacy/test_suite.hpp @@ -1,48 +1,48 @@ -/* Relacy Race Detector - * Copyright (c) 2008-2013, Dmitry S. Vyukov - * All rights reserved. - * This software is provided AS-IS with no warranty, either express or implied. - * This software is distributed under a license and may not be copied, - * modified or distributed except as expressly authorized under the - * terms of the license contained in the file LICENSE in this distribution. - */ - -#ifndef RL_TEST_SUITE_HPP -#define RL_TEST_SUITE_HPP -#ifdef _MSC_VER -# pragma once -#endif - -#include "base.hpp" -#include "test_result.hpp" - - -namespace rl -{ - - -template< - typename derived_t, - thread_id_t static_thread_count_param, - test_result_e result = test_result_success> -struct test_suite : nocopy<> -{ - static thread_id_t const dynamic_thread_count = 0; - - struct params - { - static thread_id_t const static_thread_count = static_thread_count_param; - static thread_id_t const dynamic_thread_count = derived_t::dynamic_thread_count; - static thread_id_t const thread_count = static_thread_count + dynamic_thread_count; - static test_result_e const expected_result = result; - }; - - void invariant() {} - void before() {} - void after() {} -}; - - -} - -#endif +/* Relacy Race Detector + * Copyright (c) 2008-2013, Dmitry S. Vyukov + * All rights reserved. + * This software is provided AS-IS with no warranty, either express or implied. + * This software is distributed under a license and may not be copied, + * modified or distributed except as expressly authorized under the + * terms of the license contained in the file LICENSE in this distribution. + */ + +#ifndef RL_TEST_SUITE_HPP +#define RL_TEST_SUITE_HPP +#ifdef _MSC_VER +# pragma once +#endif + +#include "base.hpp" +#include "test_result.hpp" + + +namespace rl +{ + + +template< + typename derived_t, + thread_id_t static_thread_count_param, + test_result_e result = test_result_success> +struct test_suite : nocopy<> +{ + static thread_id_t const dynamic_thread_count = 0; + + struct params + { + static thread_id_t const static_thread_count = static_thread_count_param; + static thread_id_t const dynamic_thread_count = derived_t::dynamic_thread_count; + static thread_id_t const thread_count = static_thread_count + dynamic_thread_count; + static test_result_e const expected_result = result; + }; + + void invariant() {} + void before() {} + void after() {} +}; + + +} + +#endif diff --git a/relacy/thread.hpp b/relacy/thread.hpp index 2b16096..f2d0b13 100644 --- a/relacy/thread.hpp +++ b/relacy/thread.hpp @@ -17,7 +17,6 @@ #include "context_base.hpp" #include "dyn_thread_ctx.hpp" #include "thread_base.hpp" -#include "test_suite.hpp" #include "memory_order.hpp" #include "foreach.hpp" @@ -29,15 +28,23 @@ namespace rl struct atomic_data; struct var_data; -template struct atomic_data_impl; -template struct var_data_impl; +template struct atomic_data_impl; +struct var_data_impl; - -template +template struct thread_info : thread_info_base { - thread_info(thread_id_t index = 0) - : thread_info_base(index, acq_rel_order_) + thread_info(thread_id_t thread_count, thread_id_t index = 0) + : thread_info_base(index, static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , sync_object_(thread_count) + , thread_count_(thread_count) + , acq_rel_order_(thread_info_base::acq_rel_order_) + , acquire_fence_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , release_fence_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) +#ifdef RL_IMPROVED_SEQ_CST_FENCE + , imp_seq_cst_order_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) +#endif + { } @@ -47,7 +54,7 @@ struct thread_info : thread_info_base last_yield_ = 0; dynamic_thread_func_ = 0; dynamic_thread_param_ = 0; - for (thread_id_t j = 0; j != thread_count; ++j) + for (thread_id_t j = 0; j != thread_count_; ++j) { acq_rel_order_[j] = 0; } @@ -56,14 +63,16 @@ struct thread_info : thread_info_base saved_disable_preemption_ = -1; } - thread_sync_object sync_object_; + thread_sync_object sync_object_; - timestamp_t acq_rel_order_ [thread_count]; - timestamp_t acquire_fence_order_ [thread_count]; - timestamp_t release_fence_order_ [thread_count]; + thread_id_t const thread_count_; + + timestamp_t* acq_rel_order_; + timestamp_t* acquire_fence_order_; + timestamp_t* release_fence_order_; #ifdef RL_IMPROVED_SEQ_CST_FENCE - timestamp_t imp_seq_cst_order_ [thread_count]; + timestamp_t* imp_seq_cst_order_; #endif virtual void on_start() @@ -82,7 +91,8 @@ struct thread_info : thread_info_base void atomic_thread_fence_acquire() { - foreach( + foreach( + thread_count_, acq_rel_order_, acquire_fence_order_, &assign_max); @@ -90,7 +100,8 @@ struct thread_info : thread_info_base void atomic_thread_fence_release() { - foreach( + foreach( + thread_count_, release_fence_order_, acq_rel_order_, &assign); @@ -105,17 +116,19 @@ struct thread_info : thread_info_base void atomic_thread_fence_seq_cst(timestamp_t* seq_cst_fence_order) { #ifdef RL_IMPROVED_SEQ_CST_FENCE - foreach(acq_rel_order_, imp_seq_cst_order_, assign_max); + foreach(thread_count_, acq_rel_order_, imp_seq_cst_order_, assign_max); #endif atomic_thread_fence_acquire(); - foreach( + foreach( + thread_count_, acq_rel_order_, seq_cst_fence_order, &assign_max); - foreach( + foreach( + thread_count_, seq_cst_fence_order, acq_rel_order_, &assign); @@ -123,7 +136,16 @@ struct thread_info : thread_info_base atomic_thread_fence_release(); } - virtual ~thread_info() {} // just to calm down gcc + virtual ~thread_info() + { + free(acq_rel_order_); + free(acquire_fence_order_); + free(release_fence_order_); + + #ifdef RL_IMPROVED_SEQ_CST_FENCE + free(imp_seq_cst_order_); + #endif + } private: thread_info(thread_info const&); @@ -200,9 +222,9 @@ struct thread_info : thread_info_base } template - unsigned get_load_index(atomic_data_impl& var) + unsigned get_load_index(atomic_data_impl& var) { - typedef typename atomic_data_impl::history_record history_t; + typedef typename atomic_data_impl::history_record history_t; unsigned index = var.current_index_; context& c = ctx(); @@ -230,7 +252,7 @@ struct thread_info : thread_info_base break; bool stop = false; - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { timestamp_t acq_rel_order2 = acq_rel_order_[i]; if (acq_rel_order2 >= rec.last_seen_order_[i]) @@ -259,10 +281,10 @@ struct thread_info : thread_info_base RL_VERIFY(mo_release != mo || rmw); RL_VERIFY(mo_acq_rel != mo || rmw); - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); - typedef typename atomic_data_impl::history_record history_t; + typedef typename atomic_data_impl::history_record history_t; unsigned index = get_load_index(var); if ((unsigned)-1 == index) @@ -282,17 +304,17 @@ struct thread_info : thread_info_base timestamp_t* acq_rel_order = (synch ? acq_rel_order_ : acquire_fence_order_); - foreach(acq_rel_order, rec.acq_rel_order_, assign_max); + foreach(thread_count_, acq_rel_order, rec.acq_rel_order_, assign_max); return index; } virtual unsigned atomic_init(atomic_data* RL_RESTRICT data) { - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); - typedef typename atomic_data_impl::history_record history_t; + typedef typename atomic_data_impl::history_record history_t; unsigned const idx = ++var.current_index_ % atomic_history_size; history_t& rec = var.history_[idx]; @@ -302,7 +324,7 @@ struct thread_info : thread_info_base rec.seq_cst_ = false; rec.acq_rel_timestamp_ = 0; - foreach(rec.acq_rel_order_, assign_zero); + foreach(thread_count_, rec.acq_rel_order_, assign_zero); return idx; } @@ -314,10 +336,10 @@ struct thread_info : thread_info_base RL_VERIFY(mo_acquire != mo || rmw); RL_VERIFY(mo_acq_rel != mo || rmw); - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); - typedef typename atomic_data_impl::history_record history_t; + typedef typename atomic_data_impl::history_record history_t; unsigned const idx = ++var.current_index_ % atomic_history_size; history_t& rec = var.history_[idx]; @@ -329,7 +351,7 @@ struct thread_info : thread_info_base own_acq_rel_order_ += 1; rec.acq_rel_timestamp_ = own_acq_rel_order_; - foreach(rec.last_seen_order_, assign<(timestamp_t)-1>); + foreach(thread_count_, rec.last_seen_order_, assign<(timestamp_t)-1>); rec.last_seen_order_[index_] = own_acq_rel_order_; @@ -338,7 +360,7 @@ struct thread_info : thread_info_base #ifdef RL_IMPROVED_SEQ_CST_FENCE if (val(mo) == mo_release && val(rmw) == false) - foreach(imp_seq_cst_order_, prev.acq_rel_order_, assign_max); + foreach(thread_count_, imp_seq_cst_order_, prev.acq_rel_order_, assign_max); #endif bool const synch = @@ -353,12 +375,12 @@ struct thread_info : thread_info_base if (preserve) { - foreach(rec.acq_rel_order_, prev.acq_rel_order_, assign); - foreach(rec.acq_rel_order_, acq_rel_order, assign_max); + foreach(thread_count_, rec.acq_rel_order_, prev.acq_rel_order_, assign); + foreach(thread_count_, rec.acq_rel_order_, acq_rel_order, assign_max); } else { - foreach(rec.acq_rel_order_, acq_rel_order, assign); + foreach(thread_count_, rec.acq_rel_order_, acq_rel_order, assign); } return idx; @@ -367,8 +389,8 @@ struct thread_info : thread_info_base template unsigned atomic_rmw(atomic_data* RL_RESTRICT data, bool& aba) { - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); timestamp_t const last_seen = var.history_[var.current_index_ % atomic_history_size].last_seen_order_[index_]; aba = (last_seen > own_acq_rel_order_); atomic_load(data); @@ -384,8 +406,8 @@ struct thread_info : thread_info_base virtual unpark_reason atomic_wait(atomic_data* RL_RESTRICT data, bool is_timed, bool allow_spurious_wakeup, debug_info_param info) { context& c = ctx(); - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); unpark_reason const res = var.futex_ws_.park_current(c, is_timed, allow_spurious_wakeup, false, info); if (res == unpark_reason_normal) var.futex_sync_.acquire(this); @@ -395,8 +417,8 @@ struct thread_info : thread_info_base virtual thread_id_t atomic_wake(atomic_data* RL_RESTRICT data, thread_id_t count, debug_info_param info) { context& c = ctx(); - atomic_data_impl& var = - *static_cast*>(data); + atomic_data_impl& var = + *static_cast*>(data); thread_id_t unblocked = 0; for (; count != 0; count -= 1, unblocked += 1) { diff --git a/relacy/thread_base.hpp b/relacy/thread_base.hpp index 14dd46d..a219ff8 100644 --- a/relacy/thread_base.hpp +++ b/relacy/thread_base.hpp @@ -15,7 +15,6 @@ #include "base.hpp" #include "context_base.hpp" -//#include "test_suite.hpp" //#include "memory_order.hpp" //#include "foreach.hpp" @@ -27,8 +26,8 @@ namespace rl struct atomic_data; struct var_data; -template struct atomic_data_impl; -template struct var_data_impl; +template struct atomic_data_impl; +struct var_data_impl; class thread_info_base diff --git a/relacy/thread_local_ctx.hpp b/relacy/thread_local_ctx.hpp index c8e6cfd..8f84efa 100644 --- a/relacy/thread_local_ctx.hpp +++ b/relacy/thread_local_ctx.hpp @@ -33,12 +33,13 @@ struct thread_local_context_iface -template +template class thread_local_contxt_impl : protected base_t { public: - thread_local_contxt_impl(thread_id_t thread_count_param, test_params& params) + thread_local_contxt_impl(thread_id_t thread_count_param, test_params& params, thread_id_t thread_count) : base_t(thread_count_param, params) + , thread_count_(thread_count) { } @@ -48,7 +49,7 @@ class thread_local_contxt_impl : protected base_t for (size_t ent = 0; ent != entries_.size(); ent += 1) { - for (size_t th = 0; th != thread_count; th += 1) + for (size_t th = 0; th != thread_count_; th += 1) { entries_[ent].value_[th] = 0; } @@ -59,21 +60,51 @@ class thread_local_contxt_impl : protected base_t struct entry { bool alive_; - intptr_t value_ [thread_count]; + intptr_t* value_; void (*dtor_) (intptr_t); + size_t const thread_count_; + + entry(size_t thread_count) + : value_(static_cast(calloc(thread_count, sizeof(intptr_t)))) + , thread_count_(thread_count) + { + } + + entry(const entry& other) + : value_(static_cast(calloc(other.thread_count_, sizeof(intptr_t)))) + , thread_count_(other.thread_count_) + { + alive_ = other.alive_; + dtor_ = other.dtor_; + std::copy(other.value_, other.value_ + thread_count_, value_); + } + + entry& operator=(entry other) + { + std::swap(alive_, other.alive_); + std::swap(value_, other.value_); + std::swap(dtor_, other.dtor_); + return *this; + } + + ~entry() + { + free(value_); + } }; typename vector::type entries_; using base_t::current_thread; + size_t const thread_count_; virtual int thread_local_alloc (void (*dtor)(intptr_t)) { int index = (int)entries_.size(); - entries_.resize(index + 1); + entries_.push_back(entry(thread_count_)); entry& ent = entries_[index]; ent.alive_ = true; ent.dtor_ = dtor; - for (size_t i = 0; i != thread_count; ++i) + for (size_t i = 0; i != thread_count_; ++i) { ent.value_[i] = 0; } @@ -88,7 +119,7 @@ class thread_local_contxt_impl : protected base_t ent.alive_ = false; if (ent.dtor_) { - for (size_t i = 0; i != thread_count; ++i) + for (size_t i = 0; i != thread_count_; ++i) { if (ent.value_[i]) { diff --git a/relacy/var.hpp b/relacy/var.hpp index b41a27c..b71cf56 100644 --- a/relacy/var.hpp +++ b/relacy/var.hpp @@ -25,8 +25,6 @@ namespace rl template class var; - - template class var_proxy_const { @@ -60,9 +58,6 @@ class var_proxy_const var_proxy_const& operator = (var_proxy_const const&); }; - - - template class var_proxy : public var_proxy_const { @@ -177,9 +172,6 @@ class var_proxy : public var_proxy_const } }; - - - template struct var_event { @@ -207,9 +199,6 @@ struct var_event } }; - - - template class var { @@ -325,21 +314,18 @@ class var var& operator = (var const& r); }; - - - -template struct var_data_impl : var_data { - typedef thread_info thread_info_t; - - timestamp_t load_acq_rel_timestamp_ [thread_count]; - timestamp_t store_acq_rel_timestamp_ [thread_count]; + timestamp_t* load_acq_rel_timestamp_; + timestamp_t* store_acq_rel_timestamp_; - var_data_impl() + var_data_impl(thread_id_t thread_count) + : load_acq_rel_timestamp_(static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , store_acq_rel_timestamp_ (static_cast(calloc(thread_count, sizeof(timestamp_t)))) + , thread_count_(thread_count) { - foreach(load_acq_rel_timestamp_, assign_zero); - foreach(store_acq_rel_timestamp_, assign_zero); + foreach(thread_count, load_acq_rel_timestamp_, assign_zero); + foreach(thread_count, store_acq_rel_timestamp_, assign_zero); } virtual void init(thread_info_base& th) @@ -350,7 +336,7 @@ struct var_data_impl : var_data virtual bool store(thread_info_base& th) { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { if (th.acq_rel_order_[i] < store_acq_rel_timestamp_[i]) return false; @@ -365,7 +351,7 @@ struct var_data_impl : var_data virtual bool load(thread_info_base& th) { - for (thread_id_t i = 0; i != thread_count; ++i) + for (thread_id_t i = 0; i != thread_count_; ++i) { if (th.acq_rel_order_[i] < store_acq_rel_timestamp_[i]) return false; @@ -376,13 +362,16 @@ struct var_data_impl : var_data return true; } - virtual ~var_data_impl() {} // just to calm down gcc -}; - + virtual ~var_data_impl() + { + free(load_acq_rel_timestamp_); + free(store_acq_rel_timestamp_); + } +private: + thread_id_t const thread_count_; +}; } - - #endif diff --git a/relacy/waitset.hpp b/relacy/waitset.hpp index 6453f94..25f474b 100644 --- a/relacy/waitset.hpp +++ b/relacy/waitset.hpp @@ -17,27 +17,42 @@ #include "thread_base.hpp" #include "context_base.hpp" - namespace rl { - -template +template class waitset { + struct thread_desc + { + thread_info_base* th_; + unsigned count_; // 0 - wfso, !0 - wfmo + waitset** ws_; // 0 - wfso, !0 - wfmo + win_waitable_object** wo_; // 0 - wfso, !0 - wfmo + bool wait_all_; + bool do_switch_; + }; + public: - waitset() + waitset(thread_id_t thread_count) + : thread_count_(thread_count) + , set_(static_cast(calloc(thread_count, sizeof(thread_desc)))) { size_ = 0; } + virtual ~waitset() + { + free(set_); + } + unpark_reason park_current(context& c, bool is_timed, bool allow_spurious_wakeup, bool do_switch, debug_info_param info) { - RL_VERIFY(size_ < thread_count); + RL_VERIFY(size_ < thread_count_); thread_info_base* th = c.threadx_; thread_desc desc = {th, 0, 0, 0, false, do_switch}; set_[size_] = desc; @@ -57,7 +72,8 @@ class waitset return reason; } - static unpark_reason park_current(context& c, + static unpark_reason park_current(thread_id_t thread_count, + context& c, waitset** ws, win_waitable_object** wo, size_t count, @@ -66,6 +82,7 @@ class waitset bool do_switch, debug_info_param info) { + (void)thread_count; thread_info_base* th = c.threadx_; thread_desc desc = {th, (unsigned)count, ws, wo, wait_all, do_switch}; for (unsigned wsi = 0; wsi != count; ++wsi) @@ -130,17 +147,11 @@ class waitset } private: - struct thread_desc - { - thread_info_base* th_; - unsigned count_; // 0 - wfso, !0 - wfmo - waitset** ws_; // 0 - wfso, !0 - wfmo - win_waitable_object** wo_; // 0 - wfso, !0 - wfmo - bool wait_all_; - bool do_switch_; - }; + waitset(const waitset&); + waitset& operator=(const waitset&); - thread_desc set_ [thread_count]; + thread_id_t const thread_count_; + thread_desc* set_; thread_id_t size_; bool try_remove(context& c, thread_id_t const idx, debug_info_param info) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..f7c7e5a --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8.12) + +enable_testing() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_subdirectory(g++) +add_subdirectory(jtest) +add_subdirectory(ntest) + +add_executable(main main.cpp) +add_executable(iriw iriw.cpp) + +add_test(main main) +add_test(iriw iriw) diff --git a/test/addr_hash.hpp b/test/addr_hash.hpp index b8332bf..d8c4016 100644 --- a/test/addr_hash.hpp +++ b/test/addr_hash.hpp @@ -4,7 +4,7 @@ -struct test_addr_hash : rl::test_suite +struct test_addr_hash { void* p1; void* p2; @@ -25,6 +25,8 @@ struct test_addr_hash : rl::test_suite free(p2); } + void invariant() { } + void thread(unsigned index) { assert(h1 == rl::hash_ptr(p1, table_size)); @@ -36,7 +38,7 @@ struct test_addr_hash : rl::test_suite }; -struct test_addr_hash2 : rl::test_suite +struct test_addr_hash2 { static size_t const table_size = 4; std::atomic table [table_size]; @@ -47,6 +49,9 @@ struct test_addr_hash2 : rl::test_suite -struct cas_spurious_fail_test : rl::test_suite, 1, rl::test_result_until_condition_hit> +struct cas_spurious_fail_test { std::atomic x; std::atomic y; @@ -16,6 +16,9 @@ struct cas_spurious_fail_test : rl::test_suite, 1, rl: y.store(0, std::memory_order_relaxed); } + void after() { } + void invariant() { } + void thread(unsigned /*index*/) { int cmp = 0; diff --git a/test/condvar.hpp b/test/condvar.hpp index 138ff95..b1e66ad 100644 --- a/test/condvar.hpp +++ b/test/condvar.hpp @@ -4,7 +4,7 @@ -struct test_condvar : rl::test_suite +struct test_condvar { std::mutex mtx; std::condition_variable cv; @@ -15,6 +15,9 @@ struct test_condvar : rl::test_suite data($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -39,7 +42,7 @@ struct test_condvar : rl::test_suite -struct test_condvar2 : rl::test_suite +struct test_condvar2 { rl::var stage; std::mutex mtx; @@ -50,6 +53,9 @@ struct test_condvar2 : rl::test_suite stage($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) diff --git a/test/data_race.hpp b/test/data_race.hpp index 7093e9f..ef7ca7b 100644 --- a/test/data_race.hpp +++ b/test/data_race.hpp @@ -5,7 +5,7 @@ -struct race_ld_ld_test : rl::test_suite +struct race_ld_ld_test { rl::var x; @@ -14,6 +14,9 @@ struct race_ld_ld_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -26,7 +29,7 @@ struct race_ld_ld_test : rl::test_suite -struct race_ld_st_test : rl::test_suite +struct race_ld_st_test { rl::var x; @@ -35,6 +38,9 @@ struct race_ld_st_test : rl::test_suite +struct race_st_st_test { rl::var x; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -63,7 +73,7 @@ struct race_st_st_test : rl::test_suite +struct race_seq_ld_ld_test { std::atomic a; rl::var x; @@ -74,6 +84,9 @@ struct race_seq_ld_ld_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -94,7 +107,7 @@ struct race_seq_ld_ld_test : rl::test_suite -struct race_seq_ld_st_test : rl::test_suite +struct race_seq_ld_st_test { std::atomic a; rl::var x; @@ -105,6 +118,9 @@ struct race_seq_ld_st_test : rl::test_suite +struct race_seq_st_ld_test { std::atomic a; rl::var x; @@ -135,6 +151,9 @@ struct race_seq_st_ld_test : rl::test_suite +struct race_seq_st_st_test { std::atomic a; rl::var x; @@ -165,6 +184,9 @@ struct race_seq_st_st_test : rl::test_suite +struct race_uninit_test { std::atomic a; std::atomic x; @@ -195,6 +217,9 @@ struct race_uninit_test : rl::test_suite +struct race_indirect_test { std::atomic a; rl::var x; @@ -226,6 +251,9 @@ struct race_indirect_test : rl::test_suite +struct dyn_thread_basic_test { - static unsigned const dynamic_thread_count = 4; - rl::var data1; rl::var data2; rl::atomic data3; @@ -18,6 +16,9 @@ struct dyn_thread_basic_test : rl::test_suite data3($) = 0; } + void after() { } + void invariant() { } + static void* thread1(void* p) { dyn_thread_basic_test& self = *(dyn_thread_basic_test*)p; @@ -70,10 +71,8 @@ struct dyn_thread_basic_test : rl::test_suite -struct dyn_thread_win32_test : rl::test_suite +struct dyn_thread_win32_test { - static unsigned const dynamic_thread_count = 4; - rl::var data1; rl::var data2; rl::atomic data3; @@ -83,6 +82,9 @@ struct dyn_thread_win32_test : rl::test_suite data3($) = 0; } + void after() { } + void invariant() { } + static unsigned long RL_STDCALL thread1(void* p) { dyn_thread_win32_test& self = *(dyn_thread_win32_test*)p; @@ -130,12 +132,14 @@ struct dyn_thread_win32_test : rl::test_suite }; -struct dyn_thread_visibility_test : rl::test_suite +struct dyn_thread_visibility_test { - static unsigned const dynamic_thread_count = 1; - rl::var data; + void before() { } + void after() { } + void invariant() { } + static unsigned long RL_STDCALL thread(void* p) { dyn_thread_visibility_test& self = *(dyn_thread_visibility_test*)p; diff --git a/test/event.hpp b/test/event.hpp index 3513eff..563245f 100644 --- a/test/event.hpp +++ b/test/event.hpp @@ -4,7 +4,7 @@ -struct test_event_auto : rl::test_suite +struct test_event_auto { HANDLE ev; VAR_T(int) data; @@ -20,6 +20,8 @@ struct test_event_auto : rl::test_suite CloseHandle(ev); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -41,7 +43,7 @@ struct test_event_auto : rl::test_suite -struct test_event_atomic : rl::test_suite +struct test_event_atomic { HANDLE ev1; HANDLE ev2; @@ -57,6 +59,8 @@ struct test_event_atomic : rl::test_suite CloseHandle(ev1); CloseHandle(ev2); } + + void invariant() { } void thread(unsigned index) { @@ -81,7 +85,7 @@ struct test_event_atomic : rl::test_suite -struct test_event_manual : rl::test_suite +struct test_event_manual { HANDLE ev; VAR_T(int) data; @@ -96,6 +100,8 @@ struct test_event_manual : rl::test_suite { CloseHandle(ev); } + + void invariant() { } void thread(unsigned index) { diff --git a/test/fence.hpp b/test/fence.hpp index 83483fd..1038145 100644 --- a/test/fence.hpp +++ b/test/fence.hpp @@ -4,7 +4,7 @@ template -struct fence_synch_test : rl::test_suite, 2> +struct fence_synch_test { std::atomic x; rl::var data; @@ -14,6 +14,9 @@ struct fence_synch_test : rl::test_suite, 2> x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned th) { if (0 == th) @@ -63,7 +66,7 @@ struct fence_synch_test : rl::test_suite, 2> -struct two_fence_synch_test : rl::test_suite +struct two_fence_synch_test { std::atomic x0; std::atomic x1; @@ -76,6 +79,9 @@ struct two_fence_synch_test : rl::test_suite x1($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -110,9 +116,7 @@ struct two_fence_synch_test : rl::test_suite template -struct seq_cst_fence_test : rl::test_suite, 2, - (rl::test_result_e)((0 == index) * rl::test_result_success - + (1 == index) * rl::test_result_until_condition_hit)> +struct seq_cst_fence_test { std::atomic x0; std::atomic x1; @@ -125,6 +129,8 @@ struct seq_cst_fence_test : rl::test_suite, 2, x1($) = 0; } + void invariant() { } + void thread(unsigned th) { if (0 == th) diff --git a/test/futex.hpp b/test/futex.hpp index 642b651..0529a78 100644 --- a/test/futex.hpp +++ b/test/futex.hpp @@ -4,7 +4,7 @@ -struct test_futex : rl::test_suite +struct test_futex { rl::atomic state; int wakeres; @@ -23,6 +23,8 @@ struct test_futex : rl::test_suite || (waitres == EWOULDBLOCK && wakeres == 0) || (waitres == EINTR && wakeres == 0)); } + + void invariant() { } void thread(unsigned index) { @@ -45,12 +47,17 @@ struct test_futex : rl::test_suite -struct test_futex_deadlock : rl::test_suite +struct test_futex_deadlock { rl::atomic state; + + void before() { } + void after() { } + void invariant() { } void thread(unsigned index) { + (void)index; state.store(0, rl::memory_order_relaxed); int rv = futex(&state, FUTEX_WAIT, 0, 0, 0, 0); assert(rv == EINTR); @@ -60,7 +67,7 @@ struct test_futex_deadlock : rl::test_suite +struct test_futex_sync1 { rl::atomic state; VAR_T(int) data; @@ -70,6 +77,9 @@ struct test_futex_sync1 : rl::test_suite +struct test_futex_sync2 { rl::atomic state; VAR_T(int) data; @@ -106,6 +116,9 @@ struct test_futex_sync2 : rl::test_suite +struct test_futex_intr { rl::atomic state; VAR_T(int) data; @@ -142,6 +155,9 @@ struct test_futex_intr : rl::test_suite(p); + p.static_thread_count = 1; + p.dynamic_thread_count = 4; + rl::execute(p); } diff --git a/test/iriw.cpp b/test/iriw.cpp index 55b7d91..b618088 100644 --- a/test/iriw.cpp +++ b/test/iriw.cpp @@ -1,18 +1,24 @@ #include "../relacy/relacy_std.hpp" -struct test : rl::test_suite { +struct test +{ std::atomic x_; std::atomic y_; int r2x, r2y, r3x, r3y; - void before() { + void before() + { x_.store(0, std::memory_order_relaxed); y_.store(0, std::memory_order_relaxed); r2x = r2y = r3x = r3y = 0; } - void thread(unsigned thread_index) { - switch (thread_index) { + void invariant() { } + + void thread(unsigned thread_index) + { + switch (thread_index) + { case 0:; x_.store(1, std::memory_order_relaxed); break; @@ -32,15 +38,18 @@ struct test : rl::test_suite { } } - void after() { + void after() + { // This assert should fire according to C++ memory model, // however it does not in the current relacy implementation. RL_ASSERT(!(r2x == 1 && r3y == 1 && r2y == 0 && r3x == 0)); } }; -int main() { +int main() +{ rl::test_params p; + p.static_thread_count = 4; p.iteration_count = 1000000; rl::simulate(p); } diff --git a/test/jtest/CMakeLists.txt b/test/jtest/CMakeLists.txt new file mode 100644 index 0000000..88b11d0 --- /dev/null +++ b/test/jtest/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FALGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(jtest jtest.cpp) + +add_test(jtest jtest) diff --git a/test/jtest/jtest.cpp b/test/jtest/jtest.cpp index dadc068..b2206f5 100644 --- a/test/jtest/jtest.cpp +++ b/test/jtest/jtest.cpp @@ -65,7 +65,7 @@ class stack -struct stack_test : rl::test_suite +struct stack_test { stack s_; @@ -80,11 +80,12 @@ struct stack_test : rl::test_suite void after() { - typedef rl::test_suite base_t; - RL_ASSERT(base_t::params::thread_count == produced_count_); - RL_ASSERT(base_t::params::thread_count == consumed_count_); + RL_ASSERT(4 == produced_count_); + RL_ASSERT(4 == consumed_count_); } + void invariant() { } + void thread(unsigned /*index*/) { s_.push(rand() + 1); @@ -96,8 +97,12 @@ struct stack_test : rl::test_suite }; -struct test_api : rl::test_suite +struct test_api { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned) { rl::jvolatile jv1; @@ -125,7 +130,7 @@ struct test_api : rl::test_suite } }; -struct test_seq_cst_volatiles : rl::test_suite +struct test_seq_cst_volatiles { rl::jvolatile flag0; rl::jvolatile flag1; @@ -133,6 +138,10 @@ struct test_seq_cst_volatiles : rl::test_suite rl::var data; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -156,7 +165,7 @@ struct test_seq_cst_volatiles : rl::test_suite } }; -struct test_seq_cst_volatiles2 : rl::test_suite +struct test_seq_cst_volatiles2 { rl::jvolatile x; rl::jvolatile y; @@ -168,6 +177,8 @@ struct test_seq_cst_volatiles2 : rl::test_suite r1 = r2 = r3 = r4 = 0; } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -197,10 +208,14 @@ struct test_seq_cst_volatiles2 : rl::test_suite }; template -struct test_unitialized_var : rl::test_suite, 2, rl::test_result_until_condition_hit> +struct test_unitialized_var { rl::jvar*> www; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -217,17 +232,24 @@ struct test_unitialized_var : rl::test_suite, 2, } }; +struct test_info_t +{ + rl::simulate_f f; + rl::thread_id_t static_thread_count; + rl::thread_id_t dynamic_thread_count; + rl::test_result_e expected_result; +}; int main() { - rl::simulate_f tests[] = + test_info_t tests[] = { //!!! broken &rl::simulate >, - &rl::simulate >, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate >, 2, 0, rl::test_result_until_condition_hit }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 4, 0, rl::test_result_success }, + { &rl::simulate, 1, 0, rl::test_result_success }, + { &rl::simulate, 4, 0, rl::test_result_success } }; for (size_t i = 0; i != sizeof(tests)/sizeof(*tests); ++i) @@ -239,8 +261,11 @@ int main() params.progress_stream = &stream; params.context_bound = 2; params.execution_depth_limit = 500; + params.static_thread_count = tests[i].static_thread_count; + params.dynamic_thread_count = tests[i].dynamic_thread_count; + params.expected_result = tests[i].expected_result; - if (false == tests[i](params)) + if (false == tests[i].f(params)) { std::cout << std::endl; std::cout << "FAILED" << std::endl; diff --git a/test/jtest/msvc8/jtest.sln b/test/jtest/msvc8/jtest.sln deleted file mode 100644 index 149ea0d..0000000 --- a/test/jtest/msvc8/jtest.sln +++ /dev/null @@ -1,43 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jtest", "jtest.vcproj", "{1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "..\..\test\msvc8\rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug64|Win32 = Debug64|Win32 - Debug64|x64 = Debug64|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|x64.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|x64.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|x64.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.ActiveCfg = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.Build.0 = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.ActiveCfg = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.Build.0 = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.ActiveCfg = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.Build.0 = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.ActiveCfg = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/jtest/msvc8/jtest.vcproj b/test/jtest/msvc8/jtest.vcproj deleted file mode 100644 index 3049214..0000000 --- a/test/jtest/msvc8/jtest.vcproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/jtest/msvc9/jtest.sln b/test/jtest/msvc9/jtest.sln deleted file mode 100644 index a360a8d..0000000 --- a/test/jtest/msvc9/jtest.sln +++ /dev/null @@ -1,43 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jtest", "jtest.vcproj", "{1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "..\..\test\msvc9\rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug64|Win32 = Debug64|Win32 - Debug64|x64 = Debug64|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|x64.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug64|x64.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|x64.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.ActiveCfg = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.Build.0 = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.ActiveCfg = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.Build.0 = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.ActiveCfg = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.Build.0 = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.ActiveCfg = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/jtest/msvc9/jtest.vcproj b/test/jtest/msvc9/jtest.vcproj deleted file mode 100644 index a46a545..0000000 --- a/test/jtest/msvc9/jtest.vcproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/main.cpp b/test/main.cpp index daab549..9fefde5 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -291,11 +291,14 @@ class recursive_timed_mutex -struct recursive_timed_mutex_test : rl::test_suite +struct recursive_timed_mutex_test // thread count = 3 { recursive_timed_mutex mtx; VAR_T(int) data; + void before() { } + void invariant() { } + void thread(unsigned idx) { if (idx) @@ -322,6 +325,13 @@ struct recursive_timed_mutex_test : rl::test_suite(); //if (rand() <= RAND_MAX) return 0; - rl::simulate_f tests[] = + test_info_t tests[] = { #if 1 - &rl::simulate, - - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit } , //!!! fails &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, // memory model - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 1, 2, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate, - &rl::simulate, - - &rl::simulate >, - &rl::simulate >, - - &rl::simulate, - &rl::simulate, - - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + + { &rl::simulate >, 4, 0, rl::test_result_until_condition_hit }, + { &rl::simulate >, 4, 0, rl::test_result_success }, + + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_until_condition_hit }, + + { &rl::simulate, 1, 2, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_until_condition_hit }, // fences - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, - &rl::simulate, - &rl::simulate >, - &rl::simulate >, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_success }, + { &rl::simulate >, 2, 0, rl::test_result_until_condition_hit }, // data races - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_unitialized_access }, + { &rl::simulate, 2, 0, rl::test_result_data_race }, // compare_exchange - &rl::simulate >, - &rl::simulate >, - &rl::simulate >, + { &rl::simulate >, 1, 0, rl::test_result_until_condition_hit }, + { &rl::simulate >, 1, 0, rl::test_result_until_condition_hit }, + { &rl::simulate >, 1, 0, rl::test_result_until_condition_hit }, // mutex - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_deadlock }, + { &rl::simulate, 2, 0, rl::test_result_deadlock }, + { &rl::simulate, 1, 0, rl::test_result_destroying_owned_mutex }, + { &rl::simulate, 2, 0, rl::test_result_destroying_owned_mutex }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 1, 0, rl::test_result_recursion_on_nonrecursive_mutex }, + { &rl::simulate, 1, 0, rl::test_result_unlocking_mutex_wo_ownership }, + { &rl::simulate, 1, 0, rl::test_result_resource_leak }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, // futex - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 1, 0, rl::test_result_deadlock }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, // condition variable - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, // semaphore - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, // event - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, //wfmo - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 4, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_success }, + { &rl::simulate, 2, 0, rl::test_result_until_condition_hit }, // thread local storage - &rl::simulate, - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 3, 0, rl::test_result_success }, + { &rl::simulate, 3, 0, rl::test_result_user_assert_failed }, + { &rl::simulate, 3, 0, rl::test_result_user_assert_failed }, + { &rl::simulate, 3, 0, rl::test_result_success }, // dynamic thread - &rl::simulate, - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 4, rl::test_result_success }, + { &rl::simulate, 2, 4, rl::test_result_success }, + { &rl::simulate, 1, 1, rl::test_result_success }, #endif }; @@ -512,8 +521,9 @@ int main() { //!!! make it work under sched_full if (sched == rl::sched_full - && (tests[i] == (rl::simulate_f)&rl::simulate - || tests[i] == (rl::simulate_f)&rl::simulate)) + && (tests[i].f == (rl::simulate_f)&rl::simulate + || tests[i].f == (rl::simulate_f)&rl::simulate + || tests[i].f == (rl::simulate_f)&rl::simulate)) continue; rl::ostringstream stream; @@ -525,8 +535,11 @@ int main() params.progress_stream = &stream; params.context_bound = 2; params.execution_depth_limit = 500; + params.dynamic_thread_count = tests[i].dynamic_thread_count; + params.static_thread_count = tests[i].static_thread_count; + params.expected_result = tests[i].expected_result; - if (false == tests[i](params)) + if (false == tests[i].f(params)) { std::cout << std::endl; std::cout << "FAILED" << std::endl; @@ -539,13 +552,14 @@ int main() std::cout << params.test_name << "...OK" << std::endl; } } + std::cout << std::endl; } - rl::simulate_f scheduler_tests[] = + test_info_t scheduler_tests[] = { - &rl::simulate, - &rl::simulate, + { &rl::simulate, 2, 0, rl::test_result_livelock }, + { &rl::simulate, 2, 0, rl::test_result_livelock } }; std::cout << "full search scheduler tests:" << std::endl; @@ -558,8 +572,11 @@ int main() params.progress_stream = &stream; params.context_bound = 2; params.execution_depth_limit = 500; + params.dynamic_thread_count = tests[i].dynamic_thread_count; + params.static_thread_count = tests[i].static_thread_count; + params.expected_result = scheduler_tests[i].expected_result; - if (false == scheduler_tests[i](params)) + if (false == scheduler_tests[i].f(params)) { std::cout << std::endl; std::cout << "FAILED" << std::endl; diff --git a/test/memory.hpp b/test/memory.hpp index 6ba50aa..662df78 100644 --- a/test/memory.hpp +++ b/test/memory.hpp @@ -3,8 +3,12 @@ #include "../relacy/relacy_std.hpp" -struct test_memory_allocation : rl::test_suite +struct test_memory_allocation { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned /*index*/) { VAR_T(int)* p1 = new VAR_T(int) (5), i1 = 5, * p11 = new VAR_T(int) (6); diff --git a/test/memory_order.hpp b/test/memory_order.hpp index cdeb24d..910a2d6 100644 --- a/test/memory_order.hpp +++ b/test/memory_order.hpp @@ -5,7 +5,7 @@ template -struct order_relaxed_test : rl::test_suite, 2> +struct order_relaxed_test { std::atomic x1; std::atomic x2; @@ -16,6 +16,9 @@ struct order_relaxed_test : rl::test_suite, 2> x2($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned th) { if (th) @@ -50,7 +53,7 @@ struct order_relaxed_test : rl::test_suite, 2> -struct reorder_single_var_test : rl::test_suite +struct reorder_single_var_test { std::atomic x; @@ -59,6 +62,9 @@ struct reorder_single_var_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -77,7 +83,7 @@ struct reorder_single_var_test : rl::test_suite -struct acq_rel_test : rl::test_suite +struct acq_rel_test { std::atomic x; rl::var y; @@ -87,6 +93,9 @@ struct acq_rel_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -110,8 +119,7 @@ struct acq_rel_test : rl::test_suite template -struct seq_cst_test : rl::test_suite, 4, - (rl::test_result_e)((1 - index) * rl::test_result_until_condition_hit)> +struct seq_cst_test { std::atomic x1; std::atomic x2; @@ -125,6 +133,8 @@ struct seq_cst_test : rl::test_suite, 4, res = 0; } + void invariant() { } + void thread(unsigned th) { if (0 == th) @@ -172,7 +182,7 @@ struct seq_cst_test : rl::test_suite, 4, } }; -struct modification_order_test : rl::test_suite +struct modification_order_test { std::atomic a; rl::var x; @@ -183,6 +193,9 @@ struct modification_order_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index) @@ -199,7 +212,7 @@ struct modification_order_test : rl::test_suite } }; -struct reordering_test : rl::test_suite +struct reordering_test { std::atomic x; std::atomic y; @@ -212,6 +225,9 @@ struct reordering_test : rl::test_suite r($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -237,7 +253,7 @@ struct reordering_test : rl::test_suite } }; -struct reordering_test2 : rl::test_suite +struct reordering_test2 { std::atomic x1; std::atomic x2; @@ -256,6 +272,9 @@ struct reordering_test2 : rl::test_suite +struct transitive_test { std::atomic x; rl::var y; @@ -292,6 +311,9 @@ struct transitive_test : rl::test_suite x($) = 0; } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -316,7 +338,7 @@ struct transitive_test : rl::test_suite }; -struct cc_transitive_test : rl::test_suite +struct cc_transitive_test { std::atomic x; std::atomic y; @@ -327,6 +349,9 @@ struct cc_transitive_test : rl::test_suite y.store(0, std::memory_order_relaxed); } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -347,7 +372,7 @@ struct cc_transitive_test : rl::test_suite }; -struct occasional_test : rl::test_suite +struct occasional_test { std::atomic x, y, z; @@ -358,6 +383,9 @@ struct occasional_test : rl::test_suite - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/msvc8/rrd.sln b/test/msvc8/rrd.sln deleted file mode 100644 index 23cb40a..0000000 --- a/test/msvc8/rrd.sln +++ /dev/null @@ -1,194 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{99882C71-3316-411F-A8AE-EC1E40702040}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "peterson", "..\..\example\peterson\msvc8\peterson.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy_collector", "..\..\example\proxy_collector\msvc8\proxy_collector.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B29}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ref_counting", "..\..\example\ref_counting\msvc8\ref_counting.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B28}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stack", "..\..\example\stack\msvc8\stack.vcproj", "{4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spsc_queue", "..\..\example\spsc_queue\msvc8\spsc_queue.vcproj", "{2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "condvar", "..\..\example\condvar\msvc8\condvar.vcproj", "{6CC59CF8-408B-441B-8F65-15651210CB82}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smr", "..\..\example\smr\msvc8\smr.vcproj", "{BC168133-5E3D-4691-BA15-8E0FD61DFDB5}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mutex_business_logic", "..\..\example\mutex_business_logic\msvc8\mutex_business_logic.vcproj", "{B03A7216-E196-44C6-8861-C77D90055512}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ws_deque", "..\..\example\ws_deque\msvc8\ws_deque.vcproj", "{0B597F19-DEBB-4832-B520-9A93A286D595}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jtest", "..\..\jtest\msvc8\jtest.vcproj", "{1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntest", "..\..\ntest\msvc8\ntest.vcproj", "{D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cli_ws_deque", "..\..\example\cli_ws_deque\msvc8\cli_ws_deque.vcproj", "{967F376B-BDBF-4AC8-9325-371CC8ABD8FD}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "java_ws_deque", "..\..\example\java_ws_deque\msvc8\java_ws_deque.vcproj", "{9E88433F-779E-4461-9963-35E3338873AC}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Profile|Win32 = Profile|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.ActiveCfg = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.Build.0 = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.ActiveCfg = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.ActiveCfg = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Profile|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Profile|Win32.Build.0 = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Profile|Win32.ActiveCfg = Profile|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Profile|Win32.Build.0 = Profile|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Profile|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Profile|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.Build.0 = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.ActiveCfg = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.Build.0 = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Profile|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Profile|Win32.Build.0 = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.Build.0 = Release|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Debug|Win32.ActiveCfg = Debug|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Debug|Win32.Build.0 = Debug|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Profile|Win32.ActiveCfg = Release|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Profile|Win32.Build.0 = Release|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Release|Win32.ActiveCfg = Release|Win32 - {2F0B1A3B-27CA-47D4-A9D1-5EC66BB0A85B}.Release|Win32.Build.0 = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Debug|Win32.ActiveCfg = Debug|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Debug|Win32.Build.0 = Debug|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Profile|Win32.ActiveCfg = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Profile|Win32.Build.0 = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Release|Win32.ActiveCfg = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Release|Win32.Build.0 = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.Build.0 = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Profile|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Profile|Win32.Build.0 = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.Build.0 = Release|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Debug|Win32.ActiveCfg = Debug|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Debug|Win32.Build.0 = Debug|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Profile|Win32.ActiveCfg = Release|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Profile|Win32.Build.0 = Release|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Release|Win32.ActiveCfg = Release|Win32 - {B03A7216-E196-44C6-8861-C77D90055512}.Release|Win32.Build.0 = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.ActiveCfg = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.Build.0 = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Profile|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Profile|Win32.Build.0 = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Profile|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Profile|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.Build.0 = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.ActiveCfg = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.Build.0 = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Profile|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Profile|Win32.Build.0 = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.Build.0 = Release|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Debug|Win32.ActiveCfg = Debug|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Debug|Win32.Build.0 = Debug|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Profile|Win32.ActiveCfg = Release|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Profile|Win32.Build.0 = Release|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Release|Win32.ActiveCfg = Release|Win32 - {967F376B-BDBF-4AC8-9325-371CC8ABD8FD}.Release|Win32.Build.0 = Release|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Debug|Win32.ActiveCfg = Debug|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Debug|Win32.Build.0 = Debug|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Profile|Win32.ActiveCfg = Release|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Profile|Win32.Build.0 = Release|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Release|Win32.ActiveCfg = Release|Win32 - {9E88433F-779E-4461-9963-35E3338873AC}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/msvc8/rrd.vcproj b/test/msvc8/rrd.vcproj deleted file mode 100644 index bc390d2..0000000 --- a/test/msvc8/rrd.vcproj +++ /dev/null @@ -1,615 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/msvc8/test.sln b/test/msvc8/test.sln deleted file mode 100644 index a805b41..0000000 --- a/test/msvc8/test.sln +++ /dev/null @@ -1,56 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{99882C71-3316-411F-A8AE-EC1E40702040}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Debug64|Win32 = Debug64|Win32 - Debug64|x64 = Debug64|x64 - Profile|Win32 = Profile|Win32 - Profile|x64 = Profile|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.ActiveCfg = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.Build.0 = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|x64.ActiveCfg = Debug|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|x64.Build.0 = Debug|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug64|Win32.ActiveCfg = Debug64|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug64|Win32.Build.0 = Debug64|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug64|x64.ActiveCfg = Debug64|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug64|x64.Build.0 = Debug64|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.ActiveCfg = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.Build.0 = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|x64.ActiveCfg = Profile|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|x64.Build.0 = Profile|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.ActiveCfg = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.Build.0 = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|x64.ActiveCfg = Release|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|x64.Build.0 = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.ActiveCfg = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.Build.0 = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.ActiveCfg = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|Win32.Build.0 = Debug64|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.ActiveCfg = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug64|x64.Build.0 = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|x64.ActiveCfg = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|x64.Build.0 = Debug64|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.ActiveCfg = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/msvc8/test.vcproj b/test/msvc8/test.vcproj deleted file mode 100644 index 76feb91..0000000 --- a/test/msvc8/test.vcproj +++ /dev/null @@ -1,796 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/msvc9/rrd.sln b/test/msvc9/rrd.sln deleted file mode 100644 index addf85e..0000000 --- a/test/msvc9/rrd.sln +++ /dev/null @@ -1,118 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{99882C71-3316-411F-A8AE-EC1E40702040}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ref_counting", "..\..\example\ref_counting\msvc9\ref_counting.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B28}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "peterson", "..\..\example\peterson\msvc9\peterson.vcproj", "{D4756EE9-3953-4E17-B1B5-E89F853303C1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stack", "..\..\example\stack\msvc9\stack.vcproj", "{4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "proxy_collector", "..\..\example\proxy_collector\msvc9\proxy_collector.vcproj", "{31994C0C-3BAD-4F25-8BC8-3206FF349B29}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntest", "..\..\ntest\msvc9\ntest.vcproj", "{D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jtest", "..\..\jtest\msvc9\jtest.vcproj", "{1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smr", "..\..\example\smr\msvc9\smr.vcproj", "{BC168133-5E3D-4691-BA15-8E0FD61DFDB5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spsc_queue", "..\..\example\spsc_queue\msvc9\spsc_queue.vcproj", "{3F32C4FA-E451-42BC-9E65-74129120B6E4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "condvar", "..\..\example\condvar\msvc9\condvar.vcproj", "{6CC59CF8-408B-441B-8F65-15651210CB82}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ws_deque", "..\..\example\ws_deque\msvc9\ws_deque.vcproj", "{0B597F19-DEBB-4832-B520-9A93A286D595}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples", "..\..\example\examples\msvc9\examples.vcproj", "{1EB73A6F-7F94-4ED4-8EB3-C245E773207A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Profile|Win32 = Profile|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.ActiveCfg = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.Build.0 = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.ActiveCfg = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.ActiveCfg = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Profile|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Profile|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B28}.Release|Win32.Build.0 = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Debug|Win32.Build.0 = Debug|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Profile|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Profile|Win32.Build.0 = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.ActiveCfg = Release|Win32 - {D4756EE9-3953-4E17-B1B5-E89F853303C1}.Release|Win32.Build.0 = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.ActiveCfg = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Debug|Win32.Build.0 = Debug|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Profile|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Profile|Win32.Build.0 = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.ActiveCfg = Release|Win32 - {4D6D7FC3-66D1-4F80-B434-2FDCBBFBC9F5}.Release|Win32.Build.0 = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.ActiveCfg = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Debug|Win32.Build.0 = Debug|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Profile|Win32.ActiveCfg = Profile|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Profile|Win32.Build.0 = Profile|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.ActiveCfg = Release|Win32 - {31994C0C-3BAD-4F25-8BC8-3206FF349B29}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.ActiveCfg = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.Build.0 = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Profile|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Profile|Win32.Build.0 = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.ActiveCfg = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Debug|Win32.Build.0 = Debug|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Profile|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Profile|Win32.Build.0 = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.ActiveCfg = Release|Win32 - {1889E8F4-47F7-48B6-9FC7-61FD7CD000C8}.Release|Win32.Build.0 = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Debug|Win32.Build.0 = Debug|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Profile|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Profile|Win32.Build.0 = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.ActiveCfg = Release|Win32 - {BC168133-5E3D-4691-BA15-8E0FD61DFDB5}.Release|Win32.Build.0 = Release|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Debug|Win32.ActiveCfg = Debug|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Debug|Win32.Build.0 = Debug|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Profile|Win32.ActiveCfg = Release|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Profile|Win32.Build.0 = Release|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Release|Win32.ActiveCfg = Release|Win32 - {3F32C4FA-E451-42BC-9E65-74129120B6E4}.Release|Win32.Build.0 = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Debug|Win32.ActiveCfg = Debug|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Debug|Win32.Build.0 = Debug|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Profile|Win32.ActiveCfg = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Profile|Win32.Build.0 = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Release|Win32.ActiveCfg = Release|Win32 - {6CC59CF8-408B-441B-8F65-15651210CB82}.Release|Win32.Build.0 = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.ActiveCfg = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Debug|Win32.Build.0 = Debug|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Profile|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Profile|Win32.Build.0 = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.ActiveCfg = Release|Win32 - {0B597F19-DEBB-4832-B520-9A93A286D595}.Release|Win32.Build.0 = Release|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Debug|Win32.ActiveCfg = Debug|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Debug|Win32.Build.0 = Debug|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Profile|Win32.ActiveCfg = Release|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Profile|Win32.Build.0 = Release|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Release|Win32.ActiveCfg = Release|Win32 - {1EB73A6F-7F94-4ED4-8EB3-C245E773207A}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/msvc9/rrd.vcproj b/test/msvc9/rrd.vcproj deleted file mode 100644 index 871f759..0000000 --- a/test/msvc9/rrd.vcproj +++ /dev/null @@ -1,523 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/msvc9/test.sln b/test/msvc9/test.sln deleted file mode 100644 index d13c674..0000000 --- a/test/msvc9/test.sln +++ /dev/null @@ -1,46 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{99882C71-3316-411F-A8AE-EC1E40702040}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Profile|Win32 = Profile|Win32 - Profile|x64 = Profile|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.ActiveCfg = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|Win32.Build.0 = Debug|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|x64.ActiveCfg = Debug|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Debug|x64.Build.0 = Debug|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.ActiveCfg = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|Win32.Build.0 = Profile|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|x64.ActiveCfg = Profile|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Profile|x64.Build.0 = Profile|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.ActiveCfg = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|Win32.Build.0 = Release|Win32 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|x64.ActiveCfg = Release|x64 - {99882C71-3316-411F-A8AE-EC1E40702040}.Release|x64.Build.0 = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.ActiveCfg = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|x64.Build.0 = Debug|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|x64.ActiveCfg = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Profile|x64.Build.0 = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.ActiveCfg = Release|x64 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/msvc9/test.vcproj b/test/msvc9/test.vcproj deleted file mode 100644 index a00263f..0000000 --- a/test/msvc9/test.vcproj +++ /dev/null @@ -1,639 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/mutex.hpp b/test/mutex.hpp index aec7ea3..3e1053b 100644 --- a/test/mutex.hpp +++ b/test/mutex.hpp @@ -4,7 +4,7 @@ -struct test_mutex : rl::test_suite +struct test_mutex { rl::mutex mtx; rl::var data; @@ -19,6 +19,8 @@ struct test_mutex : rl::test_suite RL_ASSERT(data($) == 3); } + void invariant() { } + void thread(unsigned /*index*/) { mtx.lock($); @@ -30,11 +32,15 @@ struct test_mutex : rl::test_suite -struct test_deadlock : rl::test_suite +struct test_deadlock { rl::mutex mtx1; rl::mutex mtx2; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -56,7 +62,7 @@ struct test_deadlock : rl::test_suite +struct test_deadlock2 { std::mutex m; std::atomic f; @@ -66,6 +72,9 @@ struct test_deadlock2 : rl::test_suite +struct test_mutex_destuction { + void before() { } + void after() { } + void invariant() { } void thread(unsigned) { std::mutex* m = new std::mutex; @@ -97,7 +109,7 @@ struct test_mutex_destuction : rl::test_suite +struct test_mutex_destuction2 { std::mutex* m; std::atomic f; @@ -108,6 +120,9 @@ struct test_mutex_destuction2 : rl::test_suite +struct test_mutex_recursion { std::recursive_mutex mtx; rl::var data; @@ -144,6 +159,8 @@ struct test_mutex_recursion : rl::test_suite RL_ASSERT(data($) == 2); } + void invariant() { } + void thread(unsigned /*index*/) { mtx.lock($); @@ -156,7 +173,7 @@ struct test_mutex_recursion : rl::test_suite -struct test_mutex_try_lock : rl::test_suite +struct test_mutex_try_lock { std::recursive_mutex mtx; rl::var data; @@ -171,6 +188,8 @@ struct test_mutex_try_lock : rl::test_suite RL_ASSERT(data($) == 2); } + void invariant() { } + void thread(unsigned /*index*/) { while (false == mtx.try_lock($)) @@ -184,8 +203,12 @@ struct test_mutex_try_lock : rl::test_suite -struct test_mutex_recursion_error : rl::test_suite +struct test_mutex_recursion_error { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned) { std::mutex m; @@ -196,8 +219,12 @@ struct test_mutex_recursion_error : rl::test_suite +struct test_mutex_unlock_error { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned) { std::mutex m; @@ -208,8 +235,12 @@ struct test_mutex_unlock_error : rl::test_suite +struct test_mutex_leak { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned) { char* p = new char [sizeof(std::mutex)]; diff --git a/test/ntest/CMakeLists.txt b/test/ntest/CMakeLists.txt new file mode 100644 index 0000000..1c0cb21 --- /dev/null +++ b/test/ntest/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) + +set(CMAKE_CXX_FALGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra") + +add_executable(ntest ntest.cpp) + +add_test(ntest ntest) diff --git a/test/ntest/msvc8/ntest.sln b/test/ntest/msvc8/ntest.sln deleted file mode 100644 index c37989b..0000000 --- a/test/ntest/msvc8/ntest.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntest", "ntest.vcproj", "{D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "..\..\test\msvc8\rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.ActiveCfg = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.Build.0 = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/ntest/msvc8/ntest.vcproj b/test/ntest/msvc8/ntest.vcproj deleted file mode 100644 index c268101..0000000 --- a/test/ntest/msvc8/ntest.vcproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/ntest/msvc9/ntest.sln b/test/ntest/msvc9/ntest.sln deleted file mode 100644 index 10334ba..0000000 --- a/test/ntest/msvc9/ntest.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntest", "ntest.vcproj", "{D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rrd", "..\..\test\msvc9\rrd.vcproj", "{D4F501D0-382D-4CBC-86F4-56181F383444}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.ActiveCfg = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Debug|Win32.Build.0 = Debug|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.ActiveCfg = Release|Win32 - {D8A75C0E-3C9A-42E5-97EC-75AEBE64C372}.Release|Win32.Build.0 = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Debug|Win32.Build.0 = Debug|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.ActiveCfg = Release|Win32 - {D4F501D0-382D-4CBC-86F4-56181F383444}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/test/ntest/msvc9/ntest.vcproj b/test/ntest/msvc9/ntest.vcproj deleted file mode 100644 index 587042c..0000000 --- a/test/ntest/msvc9/ntest.vcproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/ntest/ntest.cpp b/test/ntest/ntest.cpp index 3f51f59..1162689 100644 --- a/test/ntest/ntest.cpp +++ b/test/ntest/ntest.cpp @@ -132,7 +132,7 @@ class ws_deque mutex m_foreignLock; }; -struct ws_deque_test : rl::test_suite +struct ws_deque_test { ws_deque q; bool state [2]; @@ -149,6 +149,8 @@ struct ws_deque_test : rl::test_suite RL_ASSERT(state[1] == false); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -190,8 +192,12 @@ struct ws_deque_test : rl::test_suite -struct test_api : rl::test_suite +struct test_api { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned) { rl::nvar cv1, cv2(3), cv3(cv1($)), cv4(cv1); @@ -224,7 +230,7 @@ struct test_api : rl::test_suite -struct ws_deque_test0 : rl::test_suite +struct ws_deque_test0 { ws_deque q; @@ -236,6 +242,8 @@ struct ws_deque_test0 : rl::test_suite { } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -309,7 +317,10 @@ int main() { rl::test_params p; p.iteration_count = 1000; + p.static_thread_count = 4; rl::simulate(p); + p.static_thread_count = 2; rl::simulate(p); - rl::simulate(); + p.static_thread_count = 1; + rl::simulate(p); } diff --git a/test/pthread.hpp b/test/pthread.hpp index 3ce5a16..94e5ee8 100644 --- a/test/pthread.hpp +++ b/test/pthread.hpp @@ -4,12 +4,14 @@ -struct test_pthread_thread : rl::test_suite +struct test_pthread_thread { - static size_t const dynamic_thread_count = 2; - VAR_T(int) data; + void before() { } + void after() { } + void invariant() { } + static void* func(void* param) { static_cast(param)->VAR(data) += 1; @@ -39,7 +41,7 @@ struct test_pthread_thread : rl::test_suite -struct test_pthread_mutex : rl::test_suite +struct test_pthread_mutex { pthread_mutex_t mtx; VAR_T(int) data; @@ -59,6 +61,8 @@ struct test_pthread_mutex : rl::test_suite pthread_mutex_destroy(&mtx); } + void invariant() { } + void thread(unsigned /*index*/) { pthread_mutex_lock(&mtx); @@ -78,7 +82,7 @@ struct test_pthread_mutex : rl::test_suite -struct test_pthread_condvar : rl::test_suite +struct test_pthread_condvar { pthread_cond_t cv; pthread_mutex_t mtx; @@ -98,6 +102,8 @@ struct test_pthread_condvar : rl::test_suite pthread_mutex_destroy(&mtx); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -135,7 +141,7 @@ struct test_pthread_condvar : rl::test_suite -struct test_pthread_condvar2 : rl::test_suite +struct test_pthread_condvar2 { pthread_cond_t cv1, cv2; pthread_mutex_t mtx1, mtx2; @@ -158,6 +164,8 @@ struct test_pthread_condvar2 : rl::test_suite pthread_mutex_destroy(&mtx2); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -180,7 +188,7 @@ struct test_pthread_condvar2 : rl::test_suite -struct test_pthread_rwlock : rl::test_suite +struct test_pthread_rwlock { pthread_rwlock_t mtx; VAR_T(int) data; @@ -200,6 +208,8 @@ struct test_pthread_rwlock : rl::test_suite pthread_rwlock_destroy(&mtx); } + void invariant() { } + void thread(unsigned /*index*/) { pthread_rwlock_wrlock(&mtx); @@ -227,7 +237,7 @@ struct test_pthread_rwlock : rl::test_suite -struct test_pthread_sem : rl::test_suite +struct test_pthread_sem { sem_t sem1, sem2; VAR_T(int) data; @@ -245,6 +255,8 @@ struct test_pthread_sem : rl::test_suite sem_destroy(&sem2); } + void invariant() { } + void thread(unsigned index) { if (index) diff --git a/test/scheduler.hpp b/test/scheduler.hpp index 9c6684e..53532f4 100644 --- a/test/scheduler.hpp +++ b/test/scheduler.hpp @@ -4,7 +4,7 @@ -struct livelock_test : rl::test_suite +struct livelock_test { std::atomic x; @@ -13,6 +13,9 @@ struct livelock_test : rl::test_suite +struct yield_livelock_test { std::atomic x, y; @@ -44,6 +47,9 @@ struct yield_livelock_test : rl::test_suite +struct sched_load_test { std::recursive_mutex mtx1, mtx2; std::condition_variable_any cv1, cv2; @@ -108,6 +114,9 @@ struct sched_load_test : rl::test_suite { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (index % 2) diff --git a/test/semaphore.hpp b/test/semaphore.hpp index e0213b0..2599316 100644 --- a/test/semaphore.hpp +++ b/test/semaphore.hpp @@ -4,7 +4,7 @@ -struct test_semaphore : rl::test_suite +struct test_semaphore { HANDLE sema; VAR_T(int) data; @@ -20,6 +20,8 @@ struct test_semaphore : rl::test_suite CloseHandle(sema); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -41,7 +43,7 @@ struct test_semaphore : rl::test_suite -struct test_semaphore_atomic : rl::test_suite +struct test_semaphore_atomic { HANDLE sem [2]; @@ -56,6 +58,8 @@ struct test_semaphore_atomic : rl::test_suite CloseHandle(sem[0]); CloseHandle(sem[1]); } + + void invariant() { } void thread(unsigned index) { diff --git a/test/thread_local.hpp b/test/thread_local.hpp index fec11a7..e2c9bdd 100644 --- a/test/thread_local.hpp +++ b/test/thread_local.hpp @@ -4,10 +4,14 @@ -struct tls_basic_test : rl::test_suite +struct tls_basic_test { rl::thread_local_var x; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { RL_ASSERT(x.get($) == 0); @@ -17,10 +21,14 @@ struct tls_basic_test : rl::test_suite }; -struct tls_basic_test2 : rl::test_suite +struct tls_basic_test2 { TLS_T(unsigned) x; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { RL_ASSERT(VAR(x) == 0); @@ -30,10 +38,14 @@ struct tls_basic_test2 : rl::test_suite }; -struct tls_reset_test : rl::test_suite +struct tls_reset_test { rl::thread_local_var x; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { RL_ASSERT(x.get($) == 0); @@ -45,8 +57,12 @@ struct tls_reset_test : rl::test_suite tls_global_test_x; -struct tls_global_test : rl::test_suite +struct tls_global_test { + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { RL_ASSERT(tls_global_test_x.get($) == 0); @@ -57,7 +73,7 @@ struct tls_global_test : rl::test_suite +struct tls_win32_test { unsigned long slot; @@ -71,6 +87,8 @@ struct tls_win32_test : rl::test_suite TlsFree(slot); } + void invariant() { } + void thread(unsigned index) { RL_ASSERT(TlsGetValue(slot) == 0); diff --git a/test/trash/rtl.hpp b/test/trash/rtl.hpp index b93a50c..5ea216d 100644 --- a/test/trash/rtl.hpp +++ b/test/trash/rtl.hpp @@ -292,13 +292,17 @@ class dlist_trx -struct dlist_trx_test : rl::test_suite +struct dlist_trx_test // thread count = 4 { dlist_trx list; static int const count = 4; dlist_trx_node nodes[2][count]; + void before() { } + void after() { } + void invariant() { } + void thread(unsigned index) { if (0 == index || 1 == index) diff --git a/test/wfmo.hpp b/test/wfmo.hpp index c1c022e..e7ec896 100644 --- a/test/wfmo.hpp +++ b/test/wfmo.hpp @@ -4,7 +4,7 @@ -struct test_wfmo_all : rl::test_suite +struct test_wfmo_all { HANDLE sema1; HANDLE sema2; @@ -23,6 +23,8 @@ struct test_wfmo_all : rl::test_suite CloseHandle(sema2); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -44,7 +46,7 @@ struct test_wfmo_all : rl::test_suite -struct test_wfmo_single : rl::test_suite +struct test_wfmo_single { HANDLE sema1; HANDLE sema2; @@ -63,6 +65,8 @@ struct test_wfmo_single : rl::test_suite +struct test_wfmo_timeout { HANDLE sema1; HANDLE sema2; @@ -105,6 +109,8 @@ struct test_wfmo_timeout : rl::test_suite +struct test_wfmo_try { HANDLE sema1; HANDLE sema2; @@ -150,6 +156,8 @@ struct test_wfmo_try : rl::test_suite CloseHandle(sema2); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -172,7 +180,7 @@ struct test_wfmo_try : rl::test_suite -struct test_wfmo_mixed : rl::test_suite +struct test_wfmo_mixed { HANDLE sem [2]; @@ -187,6 +195,8 @@ struct test_wfmo_mixed : rl::test_suite CloseHandle(sem[0]); CloseHandle(sem[1]); } + + void invariant() { } void thread(unsigned index) { @@ -212,7 +222,7 @@ struct test_wfmo_mixed : rl::test_suite -struct test_wfmo_mixed2 : rl::test_suite +struct test_wfmo_mixed2 { HANDLE sem [2]; @@ -227,6 +237,8 @@ struct test_wfmo_mixed2 : rl::test_suite CloseHandle(sem[0]); CloseHandle(sem[1]); } + + void invariant() { } void thread(unsigned index) { @@ -252,7 +264,7 @@ struct test_wfmo_mixed2 : rl::test_suite -struct test_wfmo_event_all : rl::test_suite +struct test_wfmo_event_all { HANDLE ev [2]; rl::atomic state; @@ -269,6 +281,8 @@ struct test_wfmo_event_all : rl::test_suite CloseHandle(ev[0]); CloseHandle(ev[1]); } + + void invariant() { } void thread(unsigned index) { @@ -290,7 +304,7 @@ struct test_wfmo_event_all : rl::test_suite -struct test_wfmo_event_any : rl::test_suite +struct test_wfmo_event_any { HANDLE ev [2]; rl::atomic state; @@ -307,6 +321,8 @@ struct test_wfmo_event_any : rl::test_suite CloseHandle(ev[0]); CloseHandle(ev[1]); } + + void invariant() { } void thread(unsigned index) { @@ -328,7 +344,7 @@ struct test_wfmo_event_any : rl::test_suite -struct test_wfmo_atomic : rl::test_suite +struct test_wfmo_atomic { HANDLE ev [2]; rl::atomic state; @@ -344,6 +360,8 @@ struct test_wfmo_atomic : rl::test_suite +struct test_win_thread { - static size_t const dynamic_thread_count = 2; - VAR_T(int) data; + void before() { } + void after() { } + void invariant() { } + static unsigned long RL_STDCALL win_func(void* param) { static_cast(param)->VAR(data) += 1; @@ -38,7 +40,7 @@ struct test_win_thread : rl::test_suite -struct test_win_mutex : rl::test_suite +struct test_win_mutex { HANDLE mtx; VAR_T(int) data; @@ -54,6 +56,8 @@ struct test_win_mutex : rl::test_suite CloseHandle(mtx); } + void invariant() { } + void thread(unsigned) { WaitForSingleObject(mtx, INFINITE); @@ -73,7 +77,7 @@ struct test_win_mutex : rl::test_suite -struct test_win_cs : rl::test_suite +struct test_win_cs { CRITICAL_SECTION mtx; VAR_T(int) data; @@ -89,6 +93,8 @@ struct test_win_cs : rl::test_suite DeleteCriticalSection(&mtx); } + void invariant() { } + void thread(unsigned) { EnterCriticalSection(&mtx); @@ -104,7 +110,7 @@ struct test_win_cs : rl::test_suite }; -struct test_win_condvar : rl::test_suite +struct test_win_condvar { CONDITION_VARIABLE cv; CRITICAL_SECTION mtx; @@ -123,6 +129,8 @@ struct test_win_condvar : rl::test_suite DeleteConditionVariable(&cv); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -156,7 +164,7 @@ struct test_win_condvar : rl::test_suite -struct test_win_condvar_srw : rl::test_suite +struct test_win_condvar_srw { CONDITION_VARIABLE cv; SRWLOCK mtx; @@ -175,6 +183,8 @@ struct test_win_condvar_srw : rl::test_suite DeleteConditionVariable(&cv); } + void invariant() { } + void thread(unsigned index) { if (0 == index) @@ -208,7 +218,7 @@ struct test_win_condvar_srw : rl::test_suite -struct test_win_sem : rl::test_suite +struct test_win_sem { HANDLE sem1, sem2; VAR_T(int) data; @@ -226,6 +236,8 @@ struct test_win_sem : rl::test_suite CloseHandle(sem2); } + void invariant() { } + void thread(unsigned index) { if (index) @@ -263,7 +275,7 @@ struct test_win_sem : rl::test_suite -struct test_win_event : rl::test_suite +struct test_win_event { HANDLE ev; VAR_T(int) data; @@ -278,6 +290,8 @@ struct test_win_event : rl::test_suite { CloseHandle(ev); } + + void invariant() { } void thread(unsigned index) { @@ -302,7 +316,7 @@ struct test_win_event : rl::test_suite -struct test_FlushProcessWriteBuffers : rl::test_suite +struct test_FlushProcessWriteBuffers { std::atomic x1; std::atomic x2; @@ -321,6 +335,8 @@ struct test_FlushProcessWriteBuffers : rl::test_suite