Skip to content

[SYCL][CUDA] Improve function to guess local work size more efficiently. #9787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove the need for computing square in for loop check in isPrime.
  • Loading branch information
mmoadeli committed Jun 13, 2023
commit e39beeeefda287fdcc59f406c55c60fa8ca1b9f8
4 changes: 3 additions & 1 deletion sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cuda.h>
#include <cuda_device_runtime_api.h>
#include <limits>
Expand Down Expand Up @@ -308,13 +309,14 @@ void guessLocalWorkSize(_pi_device *device, size_t *threadsPerBlock,
int minGrid, maxBlockSize, maxBlockDim[3];

static auto isPrime = [](size_t number) -> bool {
auto lastNumToCheck = ceil(sqrt(number));
if (number < 2)
return false;
if (number == 2)
return true;
if (number % 2 == 0)
return false;
for (int i = 3; (i * i) <= number; i += 2) {
for (int i = 3; i <= lastNumToCheck; i += 2) {
if (number % i == 0)
return false;
}
Expand Down