Reputation: 17
I have a function shown below which I pass it to pthread_create. I have read plenty of posts and implemented them on my code, However I still can not return a value.
void *threaded_FFT(void* arg) {
struct arg_struct *data = (struct arg_struct *)arg;
data->base = data->fft->in;
for(i=0;i<N;i++){
data->base[i].re = data->input[i]; data->base[i].im =0.0;
}
usleep(1);
gpu_fft_execute(data->fft);
data->base = data->fft->out;
for(i=0;i<N;i++){
data->output[i]= sqrt(((data->base[i].re)*(data->base[i].re))+((data->base[i].im)*(data->base[i].im)));
}
return (void *)data->output;
}
When I add a printf line to display data->output[0...N], I can clearly see that they've proper values which shows function working properly.
I'm trying this in my main function
void *outData;
...
pthread_join(threads[],&outData);
...
printf("%f\n",(float *)outData);
This always returns me value of 0.000000
Upvotes: 0
Views: 1882
Reputation: 33719
printf("%f\n",(float *)outData);
%f
expects a floating point value, not a pointer. This might work:
printf("%f\n", ((float *)outData)[0]);
You have not posted your type definitions, so it is not clear whether outData
actually points to a float
value.
Upvotes: 2