Skip to content

Commit 450b26b

Browse files
authored
Update binomial_sycl.cpp
1 parent 479f025 commit 450b26b

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

Libraries/oneMKL/binomial/src/binomial_sycl.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ constexpr int wg_size = 128;
1414

1515
sycl::queue* binomial_queue;
1616

17-
Binomial::Binomial() {
17+
template<typename DATA_TYPE>
18+
Binomial<DATA_TYPE>::Binomial() {
1819
binomial_queue = new sycl::queue;
1920

2021
h_call_result = sycl::malloc_shared<DATA_TYPE>(opt_n, *binomial_queue);
@@ -45,7 +46,8 @@ Binomial::Binomial() {
4546
sycl::event::wait({event_1, event_2, event_3});
4647
}
4748

48-
Binomial::~Binomial() {
49+
template<typename DATA_TYPE>
50+
Binomial<DATA_TYPE>::~Binomial() {
4951
sycl::free(h_call_result, *binomial_queue);
5052
sycl::free(h_stock_price, *binomial_queue);
5153
sycl::free(h_option_strike, *binomial_queue);
@@ -54,7 +56,8 @@ Binomial::~Binomial() {
5456
delete binomial_queue;
5557
}
5658

57-
void Binomial::body() {
59+
template<typename DATA_TYPE>
60+
void Binomial<DATA_TYPE>::body() {
5861
constexpr int block_size = num_steps / wg_size;
5962
static_assert(block_size * wg_size == num_steps);
6063

@@ -139,7 +142,8 @@ void Binomial::body() {
139142
binomial_queue->wait();
140143
}
141144

142-
void Binomial::run() {
145+
template<typename DATA_TYPE>
146+
void Binomial<DATA_TYPE>::run() {
143147
std::printf(
144148
"%s Precision Binomial Option Pricing version %d.%d running on %s using "
145149
"DPC++, workgroup size %d, sub-group size %d.\n",
@@ -179,3 +183,17 @@ void Binomial::run() {
179183
std::printf("Time Elapsed = %10.5f seconds\n", t.duration());
180184
fflush(stdout);
181185
}
186+
187+
bool is_fp64() {
188+
sycl::queue test_queue;
189+
return test_queue.get_device().has(sycl::aspect::fp64);
190+
}
191+
192+
template DLL_EXPORT Binomial<double>::Binomial();
193+
template DLL_EXPORT Binomial<float>::Binomial();
194+
195+
template DLL_EXPORT Binomial<double>::~Binomial();
196+
template DLL_EXPORT Binomial<float>::~Binomial();
197+
198+
template DLL_EXPORT void Binomial<double>::run();
199+
template DLL_EXPORT void Binomial<float>::run();

0 commit comments

Comments
 (0)