I created a file called kernels.cu containing the code:
#include <stdio.h>
__global__ void kern()
{
printf("hi!");
}
void k_kern()
{
printf("starting kernel\n");
kern<<<1,1>>>();
}
Then i launched it from my class:
#pragma once
void k_kern();
class MyClass
{
MyClass(){}
~MyClass(){}
void start_kernel()
{
k_kern();
}
};
In the main i do:
#include "MyClass.h"
int main(int argc, char** argv)
{
MyClass m = MyClass();
m.start_kernel();
}
Compiling using:
main:
nvcc -arch=sm_30 -std=c++11 -I /usr/local/cuda-6.5/include -L /usr/local/cuda-6.5/lib64/ -lcuda -lcudart ./main.cpp kernels.o -o prog
kernels:
nvcc -arch=sm_30 -std=c++11 -c ./src/kernels.cu
Permutations of the code were running but now i get a segmentation fault. Does anyone know what is going wrong here? Might i have messed up the device somehow?
Thanks for you attention.