I have a little problem I don’t understand…
In the exemple below, I have a struct where I set the grid size (10).
When I want to launch my kernel with that value, I have an error “invalid configuration argument” (asif it was equal to 0). But if I launch it with a hardcoded grid size, it works fine.
What am I doing wrong ???
test_kernel.h:
typedef struct
{
int bar;
}foo;
extern "C" void test( foo* foovar );
my .cpp:
#include "test_kernel.h"
// includes, project
#include <cutil.h>
#include <cuda.h>
#include <cuda_runtime.h>
void runTest()
{
// STRUCT HOST
foo* foohost = (foo*)malloc(sizeof(foo));
foohost->bar = 10;
// STRUCT DEVICE
foo* foodevice;
CUDA_SAFE_CALL( cudaMalloc( (void**)&foodevice, sizeof(foo) ) );
CUDA_SAFE_CALL( cudaMemcpy( foodevice, foohost, sizeof(foo), cudaMemcpyHostToDevice ) );
// RUN
test( foodevice );
}
int main(int argc, char** argv)
{
CUT_DEVICE_INIT( argc, argv );
runTest();
CUT_EXIT(argc, argv);
}
my .cu:
...
__global__ void globaltest()
{
huhu();
}
extern "C" void test( foo* foovar )
{
//globaltest<<< 10, 16 >>>(); // OK
globaltest<<< foovar->bar, 16 >>>(); // FAIL
cudaError err = cudaGetLastError();
if( err != cudaSuccess )
{
printf( "duh! %s\n", cudaGetErrorString( err ) );
}
}