Skip to content

Instantly share code, notes, and snippets.

@willkill07
Created September 19, 2016 18:09
Show Gist options
  • Save willkill07/b8414947e655e8a014040b6db3f81959 to your computer and use it in GitHub Desktop.
Save willkill07/b8414947e655e8a014040b6db3f81959 to your computer and use it in GitHub Desktop.
Here's a smoketest which compiles correctly with NVCC given all of the same compiler options as RAJA
/*
$ /opt/cuda/bin/nvcc --keep iterDeductionSmokeTest.cpp -m64 -DRAJA_ENABLE_NESTED -O2 -restrict -arch compute_35 -std c++11 --expt-extended-lambda -x cu -ccbin /opt/cuda/bin/g++ -Xcompiler -fopenmp -DNVCC -I/opt/cuda/include -I/opt/cuda/include -I/home/wkillian/RAJA_build/tpl/src/googletest/include -I/home/wkillian/RAJA_build/include/RAJA -I/home/wkillian/RAJA_build/include -I/home/wkillian/RAJA/include -I/home/wkillian/RAJA/test/include
*/
#include <iostream>
#include <iterator>
#include <type_traits>
#include <algorithm>
#include <RAJA/RAJA.hxx>
template <typename IterType>
using OutputIter = std::ostream_iterator <typename std::iterator_traits<IterType>::value_type>;
int main() {
const int N = 1024;
const int LIMIT = 10;
float* a;
cudaMallocManaged (&a, sizeof (float) * N);
std::fill (a, a + N, 1);
std::copy (a, a + LIMIT, OutputIter<decltype(a)> (std::cout, " "));
std::cout << std::endl;
for (int loopCount = 0; loopCount < 3; ++loopCount) {
RAJA::inclusive_scan_inplace <RAJA::seq_exec> (a, a + N);
std::copy (a, a + LIMIT, OutputIter<decltype(a)> (std::cout, " "));
std::cout << std::endl;
RAJA::inclusive_scan_inplace <RAJA::omp_parallel_for_exec> (a, a + N);
std::copy (a, a + LIMIT, OutputIter<decltype(a)> (std::cout, " "));
std::cout << std::endl;
RAJA::inclusive_scan_inplace <RAJA::cuda_exec<128>> (a, a + N);
std::copy (a, a + LIMIT, OutputIter<decltype(a)> (std::cout, " "));
std::cout << std::endl;
}
cudaFree (a);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment