cuda sorting algorithm notes

How to judge nan:

https://blog.csdn.net/jacke121/article/details/123836382

Thrust is a C++ library that comes with cuda. ​​After cuda is installed, this library is also installed by default.

This library basically adopts the interface method similar to STL, so it is very friendly to developers, and developers no longer need to pay attention to the problems related to memory and video memory.

Sorting introductory example

#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <algorithm>
#include <vector>
#include <time.h>

int main(void)
{
    thrust::host_vector<int> h_vec(1024*1024);
    std::generate(h_vec.begin(), h_vec.end(), rand);

    std::vector<int> vec(h_vec.size());
    thrust::copy(h_vec.begin(), h_vec.end(), vec.begin());

    thrust::device_vector<int> d_vec = h_vec;

    clock_t time1,time2

Guess you like

Origin blog.csdn.net/jacke121/article/details/123836020