Skip to content

Commit 479f025

Browse files
authored
Update binomial_main.cpp
1 parent 3af6e16 commit 479f025

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

Libraries/oneMKL/binomial/src/binomial_main.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <cmath>
88
#include <cstdio>
99
#include <vector>
10+
#include <iostream>
1011

1112
#include "binomial.hpp"
1213

@@ -34,7 +35,8 @@ void BlackScholesRefImpl(double& callResult,
3435
callResult = (S * N_d1 - L * std::exp(-r * t) * N_d2);
3536
}
3637

37-
void Binomial::check() {
38+
template<typename DATA_TYPE>
39+
void Binomial<DATA_TYPE>::check() {
3840
if (VERBOSE) {
3941
std::printf("Creating the reference result...\n");
4042
std::vector<double> h_call_result_host(opt_n);
@@ -64,8 +66,16 @@ void Binomial::check() {
6466
}
6567

6668
int main(int argc, char** argv) {
67-
Binomial test;
68-
test.run();
69-
test.check();
69+
if(is_fp64()){
70+
Binomial<double> test;
71+
test.run();
72+
test.check();
73+
}
74+
else{
75+
std::cout<<"Warning: could not find a device with double precision support. Single precision is used."<<std::endl;
76+
Binomial<float> test;
77+
test.run();
78+
test.check();
79+
}
7080
return 0;
7181
}

0 commit comments

Comments
 (0)