Reputation: 1
In C , we can easily access file using fprintf()
and fscanf()
as shown below:
fp = fopen(“forces1.txt”, “w”);
for(h=0;h<147;h++)
{
fprintf(fp, “%f %f %f\n”, ForceX[h], ForceY[h], ForceZ[h]);
}
But I am using CUDA and my variables ForceX[h]
etc are of type cuDoubleComplex
. I want to ask two things:
frintf
and fscanf
in CUDA, if not then how to access files.%f
as my variable is not float.Upvotes: 0
Views: 138
Reputation: 152003
From here:
in cuComplex.h
(which is in the CUDA include directory in your CUDA install) we can see the following typedef:
typedef double2 cuDoubleComplex;
and double2
is a struct definition (in vector_types.h
, same directory) that looks like this:
struct double2 {
double x,y;
};
So now your question is a C or C++ question. You can print the elements (.x
, .y
) of that struct easily enough using the %f
format specifier.
Yes, you can use fprintf
and fscanf
in CUDA host code, just like you would in ordinary host code.
Upvotes: 1