Skip to content

Commit

Permalink
Rearrange thrust includes for CUDA 12.5 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoes committed Jul 12, 2024
1 parent 921de63 commit 4674cfa
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 42 deletions.
40 changes: 0 additions & 40 deletions test/test_mgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#define BOOST_TEST_MODULE grid_test
#include <boost/test/unit_test.hpp>
#include <thrust/reduce.h>
#include <thrust/execution_policy.h>

#include "libmolgrid/managed_grid.h"

using namespace libmolgrid;
Expand Down Expand Up @@ -88,43 +85,6 @@ BOOST_AUTO_TEST_CASE( indirect_indexing )

}

BOOST_AUTO_TEST_CASE( grid_conversion )
{
MGrid3f g3(7,13,11);
MGrid1f g1(100);

for(unsigned i = 0; i < 7; i++)
for(unsigned j = 0; j < 13; j++)
for(unsigned k = 0; k < 11; k++) {
g3[i][j][k] = i+j+k;
}

for(unsigned i = 0; i < 100; i++) {
g1(i) = i;
}

Grid3f cpu3(g3);
Grid1f cpu1 = g1.cpu();

float sum3 = thrust::reduce(thrust::host, cpu3.data(), cpu3.data()+cpu3.size());
BOOST_CHECK_EQUAL(sum3,14014);

float sum1 = thrust::reduce(thrust::host, cpu1.data(), cpu1.data()+cpu1.size());
BOOST_CHECK_EQUAL(sum1,4950);

MGrid6d g6(3,4,5,2,1,10);
g6[2][2][2][0][0][5] = 3.14;
Grid6d cpu6 = (Grid6d)g6; //cast conversion
BOOST_CHECK_EQUAL(cpu6.size(),1200);
BOOST_CHECK_EQUAL(cpu6(2,2,2,0,0,5), 3.14);

Grid6dCUDA gpu6 = (Grid6dCUDA)g6;
double *cudaptr = gpu6.address(2,2,2,0,0,5);
double val = 0;
cudaMemcpy(&val, cudaptr, sizeof(double), cudaMemcpyDeviceToHost);
BOOST_CHECK_EQUAL(val, 3.14);

}


BOOST_AUTO_TEST_CASE( blank_mgrid )
Expand Down
38 changes: 38 additions & 0 deletions test/test_mgrid.cu
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,41 @@ BOOST_AUTO_TEST_CASE( grid_conversion )
cudaError_t error = cudaGetLastError();
BOOST_CHECK_EQUAL(error,cudaSuccess);
}

BOOST_AUTO_TEST_CASE( grid_conversion2 )
{
MGrid3f g3(7,13,11);
MGrid1f g1(100);

for(unsigned i = 0; i < 7; i++)
for(unsigned j = 0; j < 13; j++)
for(unsigned k = 0; k < 11; k++) {
g3[i][j][k] = i+j+k;
}

for(unsigned i = 0; i < 100; i++) {
g1(i) = i;
}

Grid3f cpu3(g3);
Grid1f cpu1 = g1.cpu();

float sum3 = thrust::reduce(thrust::host, cpu3.data(), cpu3.data()+cpu3.size());
BOOST_CHECK_EQUAL(sum3,14014);

float sum1 = thrust::reduce(thrust::host, cpu1.data(), cpu1.data()+cpu1.size());
BOOST_CHECK_EQUAL(sum1,4950);

MGrid6d g6(3,4,5,2,1,10);
g6[2][2][2][0][0][5] = 3.14;
Grid6d cpu6 = (Grid6d)g6; //cast conversion
BOOST_CHECK_EQUAL(cpu6.size(),1200);
BOOST_CHECK_EQUAL(cpu6(2,2,2,0,0,5), 3.14);

Grid6dCUDA gpu6 = (Grid6dCUDA)g6;
double *cudaptr = gpu6.address(2,2,2,0,0,5);
double val = 0;
cudaMemcpy(&val, cudaptr, sizeof(double), cudaMemcpyDeviceToHost);
BOOST_CHECK_EQUAL(val, 3.14);

}
2 changes: 0 additions & 2 deletions test/test_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#define BOOST_TEST_MODULE transform_test
#include <boost/test/unit_test.hpp>
#include <boost/test/tools/floating_point_comparison.hpp>
#include <thrust/reduce.h>
#include <thrust/execution_policy.h>

#include "libmolgrid/libmolgrid.h"
#include "libmolgrid/transform.h"
Expand Down

0 comments on commit 4674cfa

Please sign in to comment.