62 constexpr int number(
const Defaults rhs)
noexcept {
63 return static_cast<int>(rhs);
67 int array[array_size] = { 0 };
70 void reset(
int v1,
int array_value) {
71 int _sync_value = sync_value;
74 for(
int & i : array) {
80 void putThreadType01(
int _len,
int startValue) {
81 const int len =
std::min(number(array_size), _len);
83 int _sync_value = sync_value;
85 _sync_value = startValue;
86 for(
int i=0; i<len; i++) {
87 array[i] = _sync_value+i;
90 sync_value = _sync_value;
93 void getThreadType01(
const std::string& msg,
int _len,
int startValue) {
94 const int len =
std::min(number(array_size), _len);
97 while( startValue != ( _sync_value = sync_value ) ) ;
98 REQUIRE_MSG(msg+
": %s: value at read value1 (sync)", _sync_value == value1);
99 REQUIRE_MSG(msg+
": %s: value at read value1 (start)", startValue == value1);
101 for(
int i=0; i<len; i++) {
106 sync_value = _sync_value;
109 void putThreadType11(
int indexAndValue) {
110 const int idx =
std::min(number(array_size)-1, indexAndValue);
118 _sync_value = sync_value;
119 }
while( idx != (_sync_value * -1) - 1 );
124 sync_value = _sync_value;
127 void getThreadType11(
const std::string& msg,
int _idx) {
128 const int idx =
std::min(number(array_size)-1, _idx);
136 _sync_value = sync_value;
137 }
while( idx != _sync_value );
142 _sync_value = (idx+1)%array_size;
143 _sync_value = ( _sync_value + 1 ) * -1;
145 value1 = _sync_value;
146 sync_value = _sync_value;
153 : value1(0), sync_value(0) {}
156 INFO_STR(
"\n\ntest01_Read1Write1.a\n");
159 std::thread getThread01(&TestMemModelSCDRF00::getThreadType01,
this,
"test01.get01", array_size, 3);
160 std::thread putThread01(&TestMemModelSCDRF00::putThreadType01,
this, array_size, 3);
166 INFO_STR(
"\n\ntest01_Read2Write1.a\n");
169 std::thread getThread00(&TestMemModelSCDRF00::getThreadType01,
this,
"test01.get00", array_size, 4);
170 std::thread getThread01(&TestMemModelSCDRF00::getThreadType01,
this,
"test01.get01", array_size, 4);
171 std::thread putThread01(&TestMemModelSCDRF00::putThreadType01,
this, array_size, 4);
177 INFO_STR(
"\n\ntest01_Read2Write1.b\n");
180 std::thread putThread01(&TestMemModelSCDRF00::putThreadType01,
this, array_size, 5);
181 std::thread getThread00(&TestMemModelSCDRF00::getThreadType01,
this,
"test01.get00", array_size, 5);
182 std::thread getThread01(&TestMemModelSCDRF00::getThreadType01,
this,
"test01.get01", array_size, 5);
190 INFO_STR(
"\n\ntest02_Read4Write1\n");
193 std::thread getThread01(&TestMemModelSCDRF00::getThreadType01,
this,
"test02.get01", array_size, 6);
194 std::thread getThread02(&TestMemModelSCDRF00::getThreadType01,
this,
"test02.get02", array_size, 6);
195 std::thread putThread01(&TestMemModelSCDRF00::putThreadType01,
this, array_size, 6);
196 std::thread getThread03(&TestMemModelSCDRF00::getThreadType01,
this,
"test02.get03", array_size, 6);
197 std::thread getThread04(&TestMemModelSCDRF00::getThreadType01,
this,
"test02.get04", array_size, 6);
206 INFO_STR(
"\n\ntest11_Read10Write10\n");
209 std::thread reader[array_size];
210 std::thread writer[array_size];
211 for(
int i=0; i<number(array_size); i++) {
212 reader[i] = std::thread(&TestMemModelSCDRF00::getThreadType11,
this,
"test11.get11", i);
214 for(
int i=0; i<number(array_size); i++) {
215 writer[i] = std::thread(&TestMemModelSCDRF00::putThreadType11,
this, i);
217 for(
int i=0; i<number(array_size); i++) {
220 for(
int i=0; i<number(array_size); i++) {
226 INFO_STR(
"\n\ntest12_Read10Write10\n");
229 std::thread reader[array_size];
230 std::thread writer[array_size];
231 for(
int i=0; i<number(array_size); i++) {
232 writer[i] = std::thread(&TestMemModelSCDRF00::putThreadType11,
this, i);
234 for(
int i=0; i<number(array_size); i++) {
235 reader[i] = std::thread(&TestMemModelSCDRF00::getThreadType11,
this,
"test12.get11", i);
237 for(
int i=0; i<number(array_size); i++) {
240 for(
int i=0; i<number(array_size); i++) {
#define REQUIRE_MSG(MSG,...)
test_mm_sc_drf_00: Testing SC-DRF non-atomic global read and write within an atomic acquire/release c...
void test03_Read4Write1()
void test11_Read10Write10()
void test01_Read1Write1()
void test02_Read2Write1()
void test12_Read10Write10()
std::string to_string(const alphabet &v) noexcept
constexpr T min(const T x, const T y) noexcept
Returns the minimum of two integrals (w/ branching) in O(1)
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
METHOD_AS_TEST_CASE(TestMemModelSCDRF00::test_list, "Test TestMemModelSCDRF 00- test_list")