Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Fix some warnings (#20)
Browse files Browse the repository at this point in the history
* int -> size_t in sort.hpp

* fix warnings in benchmarks/{benchmark.h, sycl_reduce.cpp}

* fix warnings in benchmarks
  • Loading branch information
JoanThibault authored and Ruyk committed Dec 7, 2016
1 parent 847e8b7 commit fe4879f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ struct benchmark {
const unsigned NUM_REPS = REPS; \
const unsigned STEP_SIZE = STEP_SIZE_PARAM; \
const unsigned MAX_ELEMS = STEP_SIZE * (NUM_STEPS); \
for (int nelems = STEP_SIZE; nelems < MAX_ELEMS; nelems *= STEP_SIZE) { \
for (size_t nelems = STEP_SIZE; nelems < MAX_ELEMS; nelems *= STEP_SIZE) { \
const std::string short_name = NAME; \
auto time = FUNCTION(NUM_REPS, nelems, cds); \
benchmark<>::output_data(short_name, nelems, time, ba.requestedOutput); \
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/montecarloPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ benchmark<>::time_units_t benchmark_montecarlo(const unsigned numReps,
std::srand((unsigned int)std::time(0));
// scatter some random points in the unit circle
int count = 0;
for (int i = 0; i < num_elems; i++) {
for (size_t i = 0; i < num_elems; i++) {
float x = ((float)std::rand()) / RAND_MAX;
float y = ((float)std::rand()) / RAND_MAX;
cl::sycl::float2 p(x, y);
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/nbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ benchmark<>::time_units_t benchmark_nbody(const unsigned numReps,
std::vector<Body> bodies(N);

// randomly generating N Particles
for (int i = 0; i < N; i++) {
for (size_t i = 0; i < N; i++) {
auto& b = bodies[i];
b.generateBody();
}
Expand All @@ -156,7 +156,7 @@ benchmark<>::time_units_t benchmark_nbody(const unsigned numReps,
h.parallel_for<class NBodyAlgorithm>(
r, [a_bodies, vectorSize](cl::sycl::nd_item<3> id) {
if (id.get_global(0) < vectorSize) {
for (int i = 0; i < vectorSize; i++) {
for (size_t i = 0; i < vectorSize; i++) {
a_bodies[id.get_global(0)].addForce(a_bodies[i]);
}
}
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/sycl_reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ benchmark<>::time_units_t benchmark_reduce(const unsigned numReps,
const unsigned N,
const cli_device_selector cds) {
std::vector<int> v;
for (int i = 0; i < N; i++) {
for (size_t i = 0; i < N; i++) {
int x = 10 * (((float)std::rand()) / RAND_MAX);
v.push_back(x);
}
Expand All @@ -71,16 +71,16 @@ benchmark<>::time_units_t benchmark_reduce(const unsigned numReps,

h.parallel_for<class ReduceAlgorithmBench>(
r, [aI, scratch, local, length](cl::sycl::nd_item<1> id) {
int globalid = id.get_global(0);
int localid = id.get_local(0);
size_t globalid = id.get_global(0);
size_t localid = id.get_local(0);

if (globalid < length) {
scratch[localid] = aI[globalid];
}
id.barrier(cl::sycl::access::fence_space::local_space);

int min = (length < local) ? length : local;
for (int offset = min >> 1; offset > 0; offset = offset >> 1) {
size_t min = (length < local) ? length : local;
for (size_t offset = min >> 1; offset > 0; offset = offset >> 1) {
if (localid < offset) {
scratch[localid] += scratch[localid + offset];
}
Expand Down
4 changes: 2 additions & 2 deletions include/sycl/algorithm/sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ class sort_kernel_sequential_comp {

// Simple sequential sort
void operator()() {
for (int i = 0; i < vS_; i++) {
for (int j = 1; j < vS_; j++) {
for (size_t i = 0; i < vS_; i++) {
for (size_t j = 1; j < vS_; j++) {
if (comp_(a_[j - 1], a_[j])) {
sort_swap<T>(a_[j - 1], a_[j]);
}
Expand Down

0 comments on commit fe4879f

Please sign in to comment.