device function pointers
Dear Sirs,
I need a device version of the following
host code:

double (**func)(double x);

double func1(double x)
{
return x+1.;
}

double func2(double x)
{
return x+2.;
}

double func3(double x)
{
return x+3.;
}

void test(void)
{
double x;

for(int i=0;i<3;++i){
x=func[i](2.0);
printf("%g\n",x);
}

}

int main(void)
{
func=(double (**)(double))malloc(10*sizeof(double (*)(double)));

test();

return 0;
}


where func1, func2, func3
have to be __device__ functions
and "test"
has to be a (suitably modified) __global__ kernel.

I have a NVIDIA GeForce GTS 450 (compute capability 2.1)
Thank you in advance
Michele
Dear Sirs,

I need a device version of the following

host code:



double (**func)(double x);



double func1(double x)

{

return x+1.;

}



double func2(double x)

{

return x+2.;

}



double func3(double x)

{

return x+3.;

}



void test(void)

{

double x;



for(int i=0;i<3;++i){

x=func[i](2.0);

printf("%g\n",x);

}



}



int main(void)

{

func=(double (**)(double))malloc(10*sizeof(double (*)(double)));



test();



return 0;

}





where func1, func2, func3

have to be __device__ functions

and "test"

has to be a (suitably modified) __global__ kernel.



I have a NVIDIA GeForce GTS 450 (compute capability 2.1)

Thank you in advance

Michele

#1
Posted 01/25/2012 09:58 AM   
Scroll To Top