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
125124int main (int argc, char **argv) {
126- std::cout << " \n Student's T-test Simulation\n " ;
127- std::cout << " Buffer Api\n " ;
128- std::cout << " -------------------------------------\n " ;
125+ std::cout << " \n Student'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,13 +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\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
200+ if (res0 != 1 || res1 != 1 ) {
201+ std::cout << " TEST FAILED" << std::endl;
202+ return 1 ;
203+ }
204+
205+ std::cout << " TEST PASSED" << std::endl;
200206 return 0 ;
201207}
0 commit comments