Question about Thrust Library with Kernel

Hello, everyone!
I am trying to find a way to use the STL library in CUDA and i found that i can use the thrust library as STL in C++ programming. So i am trying to use the ‘vector’ to CUDA but i had a lot of errors with programming. Because i am not well in English, i read a document of Thrust but cannot understand very well. Following code is my code for checking the thrust library but i failed several times. Please help me.

#include <iostream>
#include <cstdlib>
#include <chrono>

#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <device_functions.h>
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>

typedef struct point {
	int x;
	int y;

using namespace std;

#define maxNum 5
#define THREADS 32

void Testing(thrust::device_vector<point2D> *inputs) {
	int idx = threadIdx.x + blockDim.x*blockIdx.x;
	if (idx <inputs->size()) {
		//static_cast<point2D>(inputs[idx]).x *=5;  <<< no working
		//static_cast<point2D>(inputs[idx]).y *=5;  <<< no working

int main() {
	thrust::host_vector<point2D> alpha;
	point2D inputs;
	for (int i = 0; i < maxNum; i++) {
		inputs.x = rand() % maxNum + 1;
		inputs.y = rand() % maxNum + 1;
	for (int i = 0; i < alpha.size(); i++) {
		printf("phase[%d] = xy(%d,%d)\n", i, alpha[i].x, alpha[i].y);

	thrust::device_vector<point2D> beta = alpha;
	dim3 threads(THREADS);
	dim3 block(maxNum / threads.x);

	Testing << < block, threads >> > (beta);

	for(int i=0;i<beta.size();i++){
		printf("phase[%d] = xy(%d,%d)\n", 

	return 0;

You cannot use thrust::device_vector in device code.

If you wish to use the contents of a device vector in device code via a CUDA kernel call, extract a pointer to the data, e.g. thrust::raw_pointer_cast(, and pass that pointer to your CUDA kernel as an ordinary bare pointer.

Thank you for replying my question!
I will do this way as you said!