Skip to content
Snippets Groups Projects
Commit 2b481093 authored by Sandipan Mohanty's avatar Sandipan Mohanty
Browse files

Use thrust counting iterator in mandelbrot1.cc

parent 16ecbafa
No related branches found
No related tags found
No related merge requests found
#include "CountingIterator.hh"
#include <thrust/iterator/counting_iterator.h>
#include <algorithm>
#include <chrono>
#include <complex>
......@@ -8,6 +8,9 @@
#include <string>
#include <vector>
template <class T>
using CountingIterator = thrust::counting_iterator<T>;
void save_pgm(std::string filename, size_t width, size_t height,
std::vector<unsigned char> data)
{
......@@ -29,7 +32,7 @@ auto mandel(size_t width, size_t height) -> std::vector<unsigned char>
double aspect = static_cast<double>(width) / height;
std::vector<unsigned char> ans(width * height, 0);
CountingIterator<size_t> beg { 0 }, end { width * height };
std::transform(std::execution::par, beg, end,
std::transform(std::execution::par_unseq, beg, end,
ans.begin(), [=](size_t index) {
double myrow = index / width;
double mycol = index % width;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment