CUDA Снижение тяги с двумя массивами
У меня есть следующий (компилируемый и исполняемый) код с использованием CUDA Thrust для выполнения сокращенияfloat2
массивы. Работает правильно
using namespace std;
// includes, system
#include
#include
#include
#include
#include
#include
#include
// includes CUDA
#include
#include
// includes Thrust
#include
#include
#include
// float2 + struct
struct add_float2 {
__device__ float2 operator()(const float2& a, const float2& b) const {
float2 r;
r.x = a.x + b.x;
r.y = a.y + b.y;
return r;
}
};
// double2 + struct
struct add_double2 {
__device__ double2 operator()(const double2& a, const double2& b) const {
double2 r;
r.x = a.x + b.x;
r.y = a.y + b.y;
return r;
}
};
void main( int argc, char** argv)
{
int N = 20;
// --- Host
float2* ha; ha = (float2*) malloc(N*sizeof(float2));
for (unsigned i=0; i