How to make a std::vector with structure?

Hello, everyone.
I am trying to make up pointers such as x,y,z and radius structure from text file.
Moreover, there are so many pointers and I though i have to use with std::vector.
making a c coding, i made success without any troubles.

However, I cannot declare std::vector in CUDA. so I tried to find out solutions and there were some ways such as using the thrust::vector. But when I used to declare “device_vector” with structure, I failed to show up members or variables.
following code is sample of my work.

typedef struct inputs {
	int idx;
	int u, v;
	float x, y, z = 0;
	int r, g, b;
}point3d;

This is my structure.

thrust::host_vector<point3d> alpha;

(....reading from text files)

thrust::device_vector<point3d> beta = alpha;

beta[0].      // here is my problem. i need to call member from structure but i can only find a members like 'operator inputs','operator %=','operator &', and etc.

So, this is my question.

  1. How can I use with device_vector with structure to GPU?
  2. if we cannot use structure with device_vector, then what can I find an alternative way?

It seems to work when i re-created your sample using xtream:

#include <xpl.cuh>

typedef struct inputs {
	int idx;
	int u, v;
	float x, y, z = 0;
	int r, g, b;
}point3d;


int main(int argc, char* argv[])
{
	// Nb points:
	const int N = 1024*1024;

	xpl::HostBuffer<point3d> h_points(N);
	// edit values in first element:
	h_points(0).x = 1.0f;
	h_points(0).y = 2.0f;
	h_points(0).z = 3.0f;

	xpl::DeviceBuffer<point3d> d_points(N);
	// transfer to GPU
	d_points = h_points;
	// GPU kernel
	auto gpu_kernel = xpl_iterator(const xpl::Index& ind)
	{

		point3d point  = d_points(ind);
		if(ind == xpl::Index(0,0,0))
		{
			printf("\n Device x y z = (%0.1f, %0.1f, %0.1f)", point.x, point.y,point.z);
			// modify
			point.x = point.x + 1.0f;
			point.y = point.y + 1.0f;
			point.z = point.z + 1.0f;
			// write to buffer
			d_points(ind) = point;
		}

	};
	xpl::device::iterate(d_points.size(), gpu_kernel);
	// sync
	xpl::device::synchronize();
	// Print device value from host code:
	point3d p = d_points(0);
	std::cout << "\n Modified value on host: " << p.x << " " << p.y << " " << p.z << "\n";

	return 0;
}

This outputs the values on both the host/device:

./main 

 Device x y z = (1.0, 2.0, 3.0)
 Modified value on host: 2 3 4

You can build the sample with cmake using:

cmake_minimum_required(VERSION 3.10.2)

project(sandbox VERSION 1.0 LANGUAGES CXX CUDA)

find_package(xtream 1.2.4 REQUIRED)	

add_executable(main main.cu)
target_link_libraries(main xtream)

Hope this is what you were trying to do.

PS:
If you want to try xtream:

git clone git@gitlab.com:jipe4153/xtream-dev.git
cd xtream-dev
./install.sh

Thank you for your advice!
I didn’t know about the xtream until you told me.
Thank you agian!