Skip to content

Commit

Permalink
Fix style and add fp32 job to workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKalistratov committed Oct 27, 2023
1 parent 7160c2a commit 7e35d0b
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 37 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build_and_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,14 @@ jobs:
&$script_path
echo "OCL_ICD_FILENAMES=$env:CONDA_PREFIX\Library\lib\intelocl64.dll" >> $env:GITHUB_ENV
- name: Run benchmarks
run: dpbench -i ${{env.WORKLOADS}} run -r2 --no-print-results || exit 1
- name: Run benchmarks fp64
run: dpbench -i ${{env.WORKLOADS}} run -r2 --no-print-results --precision=double || exit 1

- name: Generate report
- name: Generate report fp64
run: dpbench -i ${{env.WORKLOADS}} report || exit 1

- name: Run benchmarks fp32
run: dpbench -i ${{env.WORKLOADS}} run -r2 --no-print-results --precision=single || exit 1

- name: Generate report fp32
run: dpbench -i ${{env.WORKLOADS}} report || exit 1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

using namespace sycl;

template <typename FpTy>
class BlackScholesKernel;
template <typename FpTy> class BlackScholesKernel;

template <typename FpTy>
void black_scholes_impl(queue Queue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,20 @@ void black_scholes_sync(size_t /**/,
throw std::runtime_error("Input arrays are not acceptable.");

if (typenum == UAR_FLOAT) {
black_scholes_impl<float>(Queue, nopt, price.get_data<float>(),
strike.get_data<float>(), t.get_data<float>(), rate,
volatility, call.get_data<float>(),
put.get_data<float>());
black_scholes_impl<float>(
Queue, nopt, price.get_data<float>(),
strike.get_data<float>(), t.get_data<float>(), rate,
volatility, call.get_data<float>(),
put.get_data<float>());
} else if (typenum == UAR_DOUBLE) {
black_scholes_impl<double>(Queue, nopt, price.get_data<double>(),
strike.get_data<double>(), t.get_data<double>(), rate,
volatility, call.get_data<double>(),
put.get_data<double>());
black_scholes_impl<double>(
Queue, nopt, price.get_data<double>(),
strike.get_data<double>(), t.get_data<double>(), rate,
volatility, call.get_data<double>(),
put.get_data<double>());
} else {
throw std::runtime_error("Expected a double or single precision FP array.");
throw std::runtime_error(
"Expected a double or single precision FP array.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ void getNeighborhood(size_t n,
}
}

template<typename FpTy>
class DBScanKernel;
template<typename FpTy> class DBScanKernel;

template <typename FpTy>
size_t dbscan_impl(queue q,
Expand Down Expand Up @@ -135,8 +134,7 @@ size_t dbscan_impl(queue q,
size_t i2 = (i1 + 1 == n_samples ? n_samples : i1 + 1);
getNeighborhood<FpTy>(n_samples, n_features, data, i2 - i1,
data + i1 * n_features, eps,
d_indices + i1 * n_samples,
d_sizes + i1);
d_indices + i1 * n_samples, d_sizes + i1);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ size_t dbscan_sync(size_t n_samples,

if (typenum == UAR_FLOAT) {
return dbscan_impl<float>(queue, n_samples, n_features,
data.get_data<float>(), eps, min_pts);
} else if (typenum == UAR_DOUBLE) {
data.get_data<float>(), eps, min_pts);
}
else if (typenum == UAR_DOUBLE) {
return dbscan_impl<double>(queue, n_samples, n_features,
data.get_data<double>(), eps, min_pts);
data.get_data<double>(), eps, min_pts);
}

throw std::runtime_error("Expected a double or single precision FP array.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

using namespace sycl;

template <typename FpTy>
class theKernel;
template <typename FpTy> class theKernel;

template <typename FpTy>
void l2_norm_impl(queue Queue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ void l2_norm_sync(dpctl::tensor::usm_ndarray a, dpctl::tensor::usm_ndarray d)

if (typenum == UAR_FLOAT) {
l2_norm_impl(Queue, npoints, dims, a.get_data<float>(),
d.get_data<float>());
d.get_data<float>());
} else if (typenum == UAR_DOUBLE) {
l2_norm_impl(Queue, npoints, dims, a.get_data<double>(),
d.get_data<double>());
d.get_data<double>());
} else {
throw std::runtime_error("Expected a double or single precision FP array.");
throw std::runtime_error(
"Expected a double or single precision FP array.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ using namespace sycl;
#define SQRT(x) sqrt(x)
#endif

template <typename FpTy> class PairwiseDistanceKernel;

template <typename FpTy>
void pairwise_distance_impl(queue Queue,
size_t npoints,
Expand All @@ -21,7 +23,7 @@ void pairwise_distance_impl(queue Queue,
FpTy *distance_op)
{
Queue.submit([&](handler &h) {
h.parallel_for<class PairwiseDistanceKernel>(
h.parallel_for<PairwiseDistanceKernel<FpTy>>(
range<1>{npoints}, [=](id<1> myID) {
size_t i = myID[0];
for (size_t j = 0; j < npoints; j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ void pairwise_distance_sync(dpctl::tensor::usm_ndarray X1,
auto Queue = X1.get_queue();
auto ndims = 3;
auto npoints = X1.get_size() / ndims;
auto typenum = X1.get_typenum();

if (!ensure_compatibility(X1, X2, D))
throw std::runtime_error("Input arrays are not acceptable.");

if (X1.get_typenum() != UAR_DOUBLE || X2.get_typenum() != UAR_DOUBLE) {
throw std::runtime_error("Expected a double precision FP array.");
if (typenum == UAR_FLOAT) {
pairwise_distance_impl(Queue, npoints, ndims, X1.get_data<float>(),
X2.get_data<float>(), D.get_data<float>());
}
else if (typenum == UAR_DOUBLE) {
pairwise_distance_impl(Queue, npoints, ndims, X1.get_data<double>(),
X2.get_data<double>(), D.get_data<double>());
}
else {
throw std::runtime_error(
"Expected a double precision FP array.");
}

pairwise_distance_impl(Queue, npoints, ndims, X1.get_data<double>(),
X2.get_data<double>(), D.get_data<double>());
}

PYBIND11_MODULE(_pairwise_distance_sycl, m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

using namespace sycl;

template <typename FpTy>
class RamboKernel;
template <typename FpTy> class RamboKernel;

template <typename FpTy>
event rambo_impl(queue Queue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ void rambo_sync(size_t nevts,
F1.get_data<float>(), Q1.get_data<float>(),
output.get_data<float>());
e.wait();
} else if (typenum == UAR_DOUBLE) {
}
else if (typenum == UAR_DOUBLE) {
auto e = rambo_impl(Queue, nevts, nout, C1.get_data<double>(),
F1.get_data<double>(), Q1.get_data<double>(),
output.get_data<double>());
e.wait();
} else {
throw std::runtime_error("Expected a double or single precision FP array.");
}
else {
throw std::runtime_error(
"Expected a double or single precision FP array.");
}
}

Expand Down

0 comments on commit 7e35d0b

Please sign in to comment.