Skip to content

Commit d40261c

Browse files
committed
updated readme + output format
1 parent 95685d3 commit d40261c

File tree

11 files changed

+61
-58
lines changed

11 files changed

+61
-58
lines changed

Libraries/oneMKL/monte_carlo_pi/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,35 @@ Monte Carlo pi Calculation Simulation
7979
Buffer API
8080
-------------------------------------
8181
Number of points = 120000000
82-
Estimated value of Pi = 3.14139
82+
Estimated value of Pi = 3.14106
8383
Exact value of Pi = 3.14159
84-
Absolute error = 0.000207487
84+
Absolute error = 0.000530387
85+
86+
TEST PASSED
8587
8688
./mc_pi_usm
8789
8890
Monte Carlo pi Calculation Simulation
8991
Unified Shared Memory API
9092
-------------------------------------
9193
Number of points = 120000000
92-
Estimated value of Pi = 3.14139
94+
Estimated value of Pi = 3.14106
9395
Exact value of Pi = 3.14159
94-
Absolute error = 0.000207487
96+
Absolute error = 0.000530387
97+
98+
TEST PASSED
9599
96100
./mc_pi_device_api
97101
98102
Monte Carlo pi Calculation Simulation
99103
Device API
100104
-------------------------------------
101105
Number of points = 120000000
102-
Estimated value of Pi = 3.14139
106+
Estimated value of Pi = 3.14159
103107
Exact value of Pi = 3.14159
104-
Absolute error = 0.000207487
108+
Absolute error = 5.95359e-06
109+
110+
TEST PASSED
105111
```
106112

107113
### Troubleshooting

Libraries/oneMKL/monte_carlo_pi/mc_pi.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,16 @@ int main(int argc, char ** argv) {
127127

128128
// Printing results
129129
double abs_error = std::fabs(pi - estimated_pi);
130-
bool failed = abs_error > 1.0e-3;
131-
if(failed) {
132-
std::cout << "TEST FAILED" << std::endl;
133-
} else {
134-
std::cout << "TEST PASSED" << std::endl;
135-
}
136130
std::cout << "Estimated value of Pi = " << estimated_pi << std::endl;
137131
std::cout << "Exact value of Pi = " << pi << std::endl;
138132
std::cout << "Absolute error = " << abs_error << std::endl;
139133
std::cout << std::endl;
140134

141-
if(failed) {
135+
if(abs_error > 1.0e-3) {
136+
std::cout << "TEST FAILED" << std::endl;
142137
return 1;
143138
}
144139

140+
std::cout << "TEST PASSED" << std::endl;
145141
return 0;
146142
}

Libraries/oneMKL/monte_carlo_pi/mc_pi_device_api.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,16 @@ int main(int argc, char ** argv) {
117117

118118
// Printing results
119119
double abs_error = std::fabs(pi - estimated_pi);
120-
bool failed = abs_error > 1.0e-4;
121-
if(failed) {
122-
std::cout << "TEST FAILED" << std::endl;
123-
} else {
124-
std::cout << "TEST PASSED" << std::endl;
125-
}
126120
std::cout << "Estimated value of Pi = " << estimated_pi << std::endl;
127121
std::cout << "Exact value of Pi = " << pi << std::endl;
128122
std::cout << "Absolute error = " << abs_error << std::endl;
129123
std::cout << std::endl;
130124

131-
if(failed) {
125+
if(abs_error > 1.0e-4) {
126+
std::cout << "TEST FAILED" << std::endl;
132127
return 1;
133128
}
134129

130+
std::cout << "TEST PASSED" << std::endl;
135131
return 0;
136132
}

Libraries/oneMKL/monte_carlo_pi/mc_pi_usm.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,16 @@ int main(int argc, char ** argv) {
130130

131131
// Printing results
132132
double abs_error = std::fabs(pi - estimated_pi);
133-
bool failed = abs_error > 1.0e-3;
134-
if(failed) {
135-
std::cout << "TEST FAILED" << std::endl;
136-
} else {
137-
std::cout << "TEST PASSED" << std::endl;
138-
}
139133
std::cout << "Estimated value of Pi = " << estimated_pi << std::endl;
140134
std::cout << "Exact value of Pi = " << pi << std::endl;
141135
std::cout << "Absolute error = " << abs_error << std::endl;
142136
std::cout << std::endl;
143137

144-
if(failed) {
138+
if(abs_error > 1.0e-3) {
139+
std::cout << "TEST FAILED" << std::endl;
145140
return 1;
146141
}
147142

143+
std::cout << "TEST PASSED" << std::endl;
148144
return 0;
149145
}

Libraries/oneMKL/random_sampling_without_replacement/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ After building, if everything is working correctly, you will see the step-by-ste
8282
./lottery
8383
8484
Multiple Simple Random Sampling without replacement
85-
Unified Shared Memory API
85+
Buffer Api
8686
---------------------------------------------------
8787
M = 6, N = 49, Number of experiments = 11969664
8888
Sample 11969661 of lottery of 11969664: 19, 5, 17, 27, 44, 34,
8989
Sample 11969662 of lottery of 11969664: 31, 39, 6, 19, 48, 15,
9090
Sample 11969663 of lottery of 11969664: 24, 11, 29, 44, 2, 20,
9191
92+
TEST PASSED
93+
9294
./lottery_usm
9395
9496
Multiple Simple Random Sampling without replacement
@@ -100,6 +102,8 @@ Sample 11969661 of lottery of 11969664: 19, 5, 17, 27, 44, 34,
100102
Sample 11969662 of lottery of 11969664: 31, 39, 6, 19, 48, 15,
101103
Sample 11969663 of lottery of 11969664: 24, 11, 29, 44, 2, 20,
102104
105+
TEST PASSED
106+
103107
./lottery_device_api
104108
105109
Multiple Simple Random Sampling without replacement
@@ -109,6 +113,8 @@ M = 6, N = 49, Number of experiments = 11969664
109113
Sample 11969661 of lottery of 11969664: 19, 5, 17, 27, 44, 34,
110114
Sample 11969662 of lottery of 11969664: 31, 39, 6, 19, 48, 15,
111115
Sample 11969663 of lottery of 11969664: 24, 11, 29, 44, 2, 20,
116+
117+
TEST PASSED
112118
```
113119

114120
### Troubleshooting

Libraries/oneMKL/random_sampling_without_replacement/lottery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int main(int argc, char ** argv) {
150150
return 1;
151151
}
152152
}
153-
std::cout << "TEST PASSED" << std::endl;
154153

154+
std::cout << "TEST PASSED" << std::endl;
155155
return 0;
156156
}

Libraries/oneMKL/random_sampling_without_replacement/lottery_device_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int main(int argc, char ** argv) {
139139
return 1;
140140
}
141141
}
142-
std::cout << "TEST PASSED" << std::endl;
143142

143+
std::cout << "TEST PASSED" << std::endl;
144144
return 0;
145145
}

Libraries/oneMKL/random_sampling_without_replacement/lottery_usm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int main(int argc, char ** argv) {
151151
return 1;
152152
}
153153
}
154-
std::cout << "TEST PASSED" << std::endl;
155154

155+
std::cout << "TEST PASSED" << std::endl;
156156
return 0;
157157
}

Libraries/oneMKL/student_t_test/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Number of random samples = 1000000 with mean = 0, std_dev = 1
7070
T-test result with expected mean: 1
7171
T-test result with two input arrays: 1
7272
73+
TEST PASSED
74+
7375
./t_test_usm
7476
7577
Student's T-test Simulation
@@ -78,6 +80,8 @@ Unified Shared Memory Api
7880
Number of random samples = 1000000 with mean = 0, std_dev = 1
7981
T-test result with expected mean: 1
8082
T-test result with two input arrays: 1
83+
84+
TEST PASSED
8185
```
8286

8387
### Troubleshooting

Libraries/oneMKL/student_t_test/t_test.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@
1919

2020
#include "oneapi/mkl.hpp"
2121

22-
using fp_type = float;
2322
// Initialization value for random number generator
24-
static const auto seed = 7777;
23+
static const int seed = 7777;
2524
// Quantity of samples to check using Students' T-test
26-
static const auto n_samples = 1000000;
25+
static const int n_samples = 1000000;
2726
// Expected mean value of random samples
28-
static const auto expected_mean = 0.0f;
27+
static const float expected_mean = 0.0f;
2928
// Expected standard deviation of random samples
30-
static const auto expected_std_dev = 1.0f;
29+
static const float expected_std_dev = 1.0f;
3130
// T-test threshold which corresponds to 5% significance level and infinite
3231
// degrees of freedom
33-
static const auto threshold = 1.95996f;
32+
static const float threshold = 1.95996f;
3433

3534
// T-test function with expected mean
3635
// Returns: -1 if something went wrong, 1 - in case of NULL hypothesis should be
@@ -123,10 +122,11 @@ std::int32_t t_test(sycl::queue &q, sycl::buffer<RealType, 1> &r1,
123122
}
124123

125124
int main(int argc, char **argv) {
126-
std::cout << "\nStudent's T-test Simulation\n";
127-
std::cout << "Buffer Api\n";
128-
std::cout << "-------------------------------------\n";
125+
std::cout << "\nStudent's T-test Simulation" << std::endl;
126+
std::cout << "Buffer Api" << std::endl;
127+
std::cout << "-------------------------------------" << std::endl;
129128

129+
using fp_type = float;
130130
size_t n_points = n_samples;
131131
fp_type mean = expected_mean;
132132
fp_type std_dev = expected_std_dev;
@@ -153,7 +153,7 @@ int main(int argc, char **argv) {
153153
}
154154

155155
std::cout << "Number of random samples = " << n_points
156-
<< " with mean = " << mean << ", std_dev = " << std_dev << "\n";
156+
<< " with mean = " << mean << ", std_dev = " << std_dev << std::endl;
157157

158158
// This exception handler with catch async exceptions
159159
auto exception_handler = [](sycl::exception_list exceptions) {
@@ -189,20 +189,19 @@ int main(int argc, char **argv) {
189189
res1 = t_test(q, rng_buf0, n_points, rng_buf1, n_points);
190190
} catch (...) {
191191
// Some other exception detected
192-
std::cout << "Failure\n";
192+
std::cout << "Failure" << std::endl;
193193
std::terminate();
194194
}
195195

196196
// Printing results
197-
std::cout << "T-test result with expected mean: " << res0 << "\n";
198-
std::cout << "T-test result with two input arrays: " << res1 << "\n";
197+
std::cout << "T-test result with expected mean: " << res0 << std::endl;
198+
std::cout << "T-test result with two input arrays: " << res1 << std::endl << std::endl;
199199

200200
if(res0 != 1 || res1 != 1) {
201201
std::cout << "TEST FAILED" << std::endl;
202202
return 1;
203203
}
204204

205205
std::cout << "TEST PASSED" << std::endl;
206-
207206
return 0;
208207
}

0 commit comments

Comments
 (0)