Skip to content

Commit 7fb3abe

Browse files
authored
Update montecarlo_main.cpp
1 parent c857966 commit 7fb3abe

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

Libraries/oneMKL/monte_carlo_european_opt/src/montecarlo_main.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818

1919
template<typename Type, int>
2020
class k_MonteCarlo; // can be useful for profiling
21+
template<typename Type>
22+
class k_initialize_state; // can be useful for profiling
2123

22-
int main(int argc, char** argv)
24+
template <typename DataType>
25+
void run()
2326
{
2427
try {
2528
std::cout << "MonteCarlo European Option Pricing in " <<
@@ -97,7 +100,7 @@ int main(int argc, char** argv)
97100
auto rng_states_uptr = std::unique_ptr<EngineType, decltype(deleter)>(sycl::malloc_device<EngineType>(n_states, my_queue), deleter);
98101
auto* rng_states = rng_states_uptr.get();
99102

100-
my_queue.parallel_for<class k_initialize_state>(
103+
my_queue.parallel_for<k_initialize_state<DataType>>(
101104
sycl::range<1>(n_states),
102105
std::vector<sycl::event>{rng_event_1, rng_event_2, rng_event_3},
103106
[=](sycl::item<1> idx) {
@@ -179,5 +182,18 @@ int main(int argc, char** argv)
179182
std::cout << e.what();
180183
exit(1);
181184
}
182-
return 0;
185+
}
186+
187+
int main(int argc, char** argv){
188+
bool is_fp64 = true;
189+
{
190+
sycl::queue test_queue;
191+
is_fp64 = test_queue.get_device().has(sycl::aspect::fp64);
192+
}
193+
if (is_fp64) {
194+
run<double>();
195+
} else {
196+
std::cout<<"Warning: could not find a device with double precision support. Single precision is used."<<std::endl;
197+
run<float>();
198+
}
183199
}

0 commit comments

Comments
 (0)