CUDA map interweaving device vectors to OpenGL buffer

I have 2 device vectors that contain some data:

thrust::device_vector<float> A(3); // { 0, 2, 4 }
thrust::device_vector<float> B(3); // { 1, 3, 5 }

Is there a way to map these vectors to a single OpenGL vertex buffer so that the data gets organized like this (without having to launch a kernel every time the data gets updated):

OGL BUFFER [0, 1, 2, 3, 4, 5]

so the layout of the vertex buffer looks something like this:

OGL BUFFER {float a, float b}

Note that I’ve also been having trouble mapping the vectors to OpenGL buffers. I know how to map a float*, but I wasn’t able to map a device_vector so far. My best attempt at making this work was this:

// the sizes of the device_vectors
const int N = 3;

// create the device_vectors
thrust::device_vector<float> A(N);
thrust::device_vector<float> B(N);

// fill the device_vectors with data
A[0] = 0;
A[1] = 2;
A[2] = 4;
B[0] = 1;
B[1] = 3;
B[2] = 5;

// create a buffer to hold the data from the device_vectors
float* buffer = new float[N * 2];

// copy the data from the device_vectors into the buffer
thrust::copy(A.begin(), A.end(), buffer);
thrust::copy(B.begin(), B.end(), buffer + N);

// map the buffer to an OpenGL vertex buffer
GLuint vertex_buffer;
glGenBuffers(1, &vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, N * 2 * sizeof(float), buffer, GL_STATIC_DRAW);

TestKernel << <1, 3 >> > (buffer);

delete[] buffer;

But this produces an unhandled exception. (The TestKernel is a basic kernel that just prints 3 values at indexes 0, 1, and 2)

In the end I just used a single vector of structs that I mapped to OpenGL memory.