error calling a function inside __global__kernel

in my code i tried to call a function inside global kernel but an error was became.

double f(…)
{

return smth;
}

global void mykernel(…)
{

double var=f(…); // this part cause an error “identifier not found”

}

i made f(…) functon __ device__ vs. but same problem was occured again.
what can i do?

another question, how can i hold a variable that behave like a static variable. inside global kernel declaration of static variable is not allowed.

thanks…