I’m trying to build a tree on my GEForce GT 525M device (supports version 2.0) using the following logic.
The problem is that it doesn’t seem to “get into” the kernel function itself. A blank screen is displayed at output console.
(In a different n simpler code, I’m able to use printf inside the kernel function.)
What might be the problem? Shouldn’t it atleast execute the simple printf statement?
P.S. : I’m a beginner.
#include<iostream>
#include<stdlib.h>
using namespace std;
struct node
{
int data;
node *left,*right;
};
__global__ void build(node * root)
{
int arr[]={5,3,8,2,6,7,1,9,4};
printf("Control in 1st kernel function!");
root->data = arr[1];
root->left = root->right=NULL;
}
__global__ void print(node * root)
{
printf("%d",root->data);
}
int main()
{
node *n_h,*n_d;
size_t size9 = sizeof(node)*9;
size_t size = sizeof(node);
cudaMalloc((void**)&n_d,size);
build<<<1,1>>>(n_d);
print<<<1,1>>>(n_d);
getchar();
return 0;
}