Skip to content
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

Fix the tests build #228

Merged
merged 3 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions tests/test_opencl_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
#define CL_HPP_ENABLE_EXCEPTIONS
#include <CL/opencl.hpp>

#include <cinttypes>
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <random>
#include <thread>
#include <vector>

using uint = std::uint32_t;
Expand Down Expand Up @@ -590,4 +590,4 @@ TEST(opencl_merge, merge_path_v2) {
std::cout << "Time taken for Merge Cpu: " << (result_time_cpu / N_RUNS).count() << " ms\n";
}

SPLA_GTEST_MAIN
SPLA_GTEST_MAIN
30 changes: 16 additions & 14 deletions tests/test_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include <spla.hpp>

#include <algorithm>

TEST(vector, get_set_naive) {
const spla::uint N = 10;
const int X[N] = {1, 2, 3, 4, 5, -3, -3, 5, -8, 1};
Expand Down Expand Up @@ -117,7 +119,7 @@ TEST(vector, reduce_plus) {
auto istart = spla::Scalar::make_int(0);
int isum = 0;

for (int k = 0; k < K; ++k) {
for (spla::uint k = 0; k < K; ++k) {
ivec->set_int(I[k], X[k]);
isum += X[k];
}
Expand All @@ -141,11 +143,11 @@ TEST(vector, reduce_mult) {
auto istart = spla::Scalar::make_int(1);
int isum = 1;

for (int k = 0; k < N; ++k) {
for (spla::uint k = 0; k < N; ++k) {
ivec->set_int(k, 1);
}

for (int k = 0; k < K; ++k) {
for (spla::uint k = 0; k < K; ++k) {
ivec->set_int(I[k], X[k]);
isum *= X[k];
}
Expand Down Expand Up @@ -253,27 +255,27 @@ TEST(vector, eadd_fdb_min) {
auto iv = spla::Vector::make(N, spla::INT);
auto ifdb = spla::Vector::make(N, spla::INT);

for (int k = 0; k < N; ++k) {
for (spla::uint k = 0; k < N; ++k) {
ir->set_int(k, S);
R[k] = S;
F[k] = 0;
}

for (int k = 0; k < K; ++k) {
for (spla::uint k = 0; k < K; ++k) {
iv->set_int(I[k], V[k]);
R[I[k]] = std::min(R[I[k]], V[k]);
if (R[I[k]] != S) F[I[k]] = R[I[k]];
}

spla::exec_v_eadd_fdb(ir, iv, ifdb, spla::MIN_INT);

for (int k = 0; k < N; k++) {
for (spla::uint k = 0; k < N; k++) {
int r;
ir->get_int(k, r);
EXPECT_EQ(R[k], r);
}

for (int k = 0; k < N; k++) {
for (spla::uint k = 0; k < N; k++) {
int r;
ifdb->get_int(k, r);
EXPECT_EQ(F[k], r);
Expand Down Expand Up @@ -323,20 +325,20 @@ TEST(vector, assign_plus) {
auto imask = spla::Vector::make(N, spla::INT);
auto ival = spla::Scalar::make_int(S);

for (int k = 0; k < N; ++k) {
for (spla::uint k = 0; k < N; ++k) {
ivec->set_int(k, 14);
imask->set_int(k, 0);
R[k] = 14;
}

for (int k = 0; k < K; ++k) {
for (spla::uint k = 0; k < K; ++k) {
imask->set_int(I[k], 1);
R[I[k]] = R[I[k]] + S;
}

spla::exec_v_assign_masked(ivec, imask, ival, spla::PLUS_INT, spla::NQZERO_INT);

for (int k = 0; k < N; k++) {
for (spla::uint k = 0; k < N; k++) {
int r;
ivec->get_int(k, r);
EXPECT_EQ(R[k], r);
Expand All @@ -354,20 +356,20 @@ TEST(vector, assign_second) {
auto imask = spla::Vector::make(N, spla::INT);
auto ival = spla::Scalar::make_int(S);

for (int k = 0; k < N; ++k) {
for (spla::uint k = 0; k < N; ++k) {
ivec->set_int(k, 14);
imask->set_int(k, 0);
R[k] = 14;
}

for (int k = 0; k < K; ++k) {
for (spla::uint k = 0; k < K; ++k) {
imask->set_int(I[k], 1);
R[I[k]] = S;
}

spla::exec_v_assign_masked(ivec, imask, ival, spla::SECOND_INT, spla::NQZERO_INT);

for (int k = 0; k < N; k++) {
for (spla::uint k = 0; k < N; k++) {
int r;
ivec->get_int(k, r);
EXPECT_EQ(R[k], r);
Expand Down Expand Up @@ -495,4 +497,4 @@ TEST(vector, map) {
}
}

SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1)
SPLA_GTEST_MAIN_WITH_FINALIZE_PLATFORM(1)