Struct Member Pointer in kernel function the values associated to the pointer are not copied into de

Hi, we have the following struct defined

typedef struct PurchaseOrder { 

char* Value1;

double Value2;  

int Value3Length;

  __device__ int GetValue3Length() {return Value3Length;}

double* Value3;

  __device__ double GetValue3(int i) { return Value3[i];}

  __device__ void SetValue3(int i, double value) { Value3[i] = value;}

};

The PurchaseOrder data (array of structs) are marshalled from C# application into the following C dll function

int RunMonteCarlo(PurchaseOrder *hostPurchaseOrders, int length)

{	

	PurchaseOrder *devPurchaseOrders;	

	// display the results

	for (int i = 0; i < length; i++) 

	{			

		//printf("\n\nAddress: %u",hostPurchaseOrders+i);			

		printf("\n\nIndex: %d", i);			

		printf("\nValue1: %s",(hostPurchaseOrders+i)->Value1);

		printf("\nValue2: %f",(hostPurchaseOrders+i)->Value2);

		

		for(int  j = 0; j < (hostPurchaseOrders+i)->Value3Length; j++)

		{

			printf("\nValue3[%d]: %fl", j, (hostPurchaseOrders+i)->Value3[j]);			

		}

		}	

	// allocate the memory on the GPU

	HANDLE_ERROR( cudaMalloc( (void**)&devPurchaseOrders, length * sizeof(PurchaseOrder) ) );

	

	// copy the array 'PurchaseOrder' to the GPU

	HANDLE_ERROR( cudaMemcpy( devPurchaseOrders, hostPurchaseOrders, length * sizeof(PurchaseOrder), cudaMemcpyHostToDevice ) );	

	// Run the kernel code

	MonteCarloKernel<<<60,32>>>( devPurchaseOrders, length);

	// copy the array 'PurchaseOrders' back from the GPU to the CPU

	HANDLE_ERROR( cudaMemcpy(hostPurchaseOrders, devPurchaseOrders, length * sizeof(PurchaseOrder), cudaMemcpyDeviceToHost ) );	

	

	

	// free the memory allocated on the GPU

		HANDLE_ERROR( cudaFree( devPurchaseOrders ) );	 

	return 0;

}

__global__ void MonteCarloKernel(PurchaseOrder *purchaseorders, long length) 

{

	// calculate the starting index and the offset to the next block that each thread will be processing

	int i = threadIdx.x + blockIdx.x * blockDim.x;

	int stride = blockDim.x * gridDim.x;

	  

	 while (i < length) 

	 {		

		

	purchaseorders[i].SetAAUS(1.11);

		

		for (int j=0; j < purchaseorders[i].GetValue3Length(); j++) 

	{			

			

	   //purchaseorders[i].SetValue3(j,1.0);

	}

		

		i += stride;

	}

}

The data are marshalled correctly as verified by the printf code at the beginning.

However, the Value3 (array of double) seems not copied into the device memory as the line purchaseorders[i].SetValue3(j,1.0) in the kernel crashes the application.

What should I do to solve it out?

When the application crashes, the console windows just closed. What debug technique I could use to get some meaningful messages?

Hi, we have the following struct defined

typedef struct PurchaseOrder { 

char* Value1;

double Value2;  

int Value3Length;

  __device__ int GetValue3Length() {return Value3Length;}

double* Value3;

  __device__ double GetValue3(int i) { return Value3[i];}

  __device__ void SetValue3(int i, double value) { Value3[i] = value;}

};

The PurchaseOrder data (array of structs) are marshalled from C# application into the following C dll function

int RunMonteCarlo(PurchaseOrder *hostPurchaseOrders, int length)

{	

	PurchaseOrder *devPurchaseOrders;	

	// display the results

	for (int i = 0; i < length; i++) 

	{			

		//printf("\n\nAddress: %u",hostPurchaseOrders+i);			

		printf("\n\nIndex: %d", i);			

		printf("\nValue1: %s",(hostPurchaseOrders+i)->Value1);

		printf("\nValue2: %f",(hostPurchaseOrders+i)->Value2);

		

		for(int  j = 0; j < (hostPurchaseOrders+i)->Value3Length; j++)

		{

			printf("\nValue3[%d]: %fl", j, (hostPurchaseOrders+i)->Value3[j]);			

		}

		}	

	// allocate the memory on the GPU

	HANDLE_ERROR( cudaMalloc( (void**)&devPurchaseOrders, length * sizeof(PurchaseOrder) ) );

	

	// copy the array 'PurchaseOrder' to the GPU

	HANDLE_ERROR( cudaMemcpy( devPurchaseOrders, hostPurchaseOrders, length * sizeof(PurchaseOrder), cudaMemcpyHostToDevice ) );	

	// Run the kernel code

	MonteCarloKernel<<<60,32>>>( devPurchaseOrders, length);

	// copy the array 'PurchaseOrders' back from the GPU to the CPU

	HANDLE_ERROR( cudaMemcpy(hostPurchaseOrders, devPurchaseOrders, length * sizeof(PurchaseOrder), cudaMemcpyDeviceToHost ) );	

	

	

	// free the memory allocated on the GPU

		HANDLE_ERROR( cudaFree( devPurchaseOrders ) );	 

	return 0;

}

__global__ void MonteCarloKernel(PurchaseOrder *purchaseorders, long length) 

{

	// calculate the starting index and the offset to the next block that each thread will be processing

	int i = threadIdx.x + blockIdx.x * blockDim.x;

	int stride = blockDim.x * gridDim.x;

	  

	 while (i < length) 

	 {		

		

	purchaseorders[i].SetAAUS(1.11);

		

		for (int j=0; j < purchaseorders[i].GetValue3Length(); j++) 

	{			

			

	   //purchaseorders[i].SetValue3(j,1.0);

	}

		

		i += stride;

	}

}

The data are marshalled correctly as verified by the printf code at the beginning.

However, the Value3 (array of double) seems not copied into the device memory as the line purchaseorders[i].SetValue3(j,1.0) in the kernel crashes the application.

What should I do to solve it out?

When the application crashes, the console windows just closed. What debug technique I could use to get some meaningful messages?