malloc a complex<float> in C++ and CUDA
In C++, if I want an array of complex I might do 开发者_JAVA百科something like this:
complex<float> *temp = new complex<float>[size];
Can I change this into a malloc statement?
What about if I want to use cudaMalloc to give me an array on the GPU of complex floats?
thanks
Can I change this into a malloc statement?
No, but you can change it into a malloc statement with Placement-New. Can't see why you'd want to do that though.
What about if I want to use cudaMalloc to give me an array on the GPU of complex floats?
Again, you'll have to use placement new.
For Cuda there is the type cuComplex for complex floa values and cuDoubleComplex for double complex values. You can use both in combination with cudaMalloc or cublasAlloc.
Unless complex
has no constructor, no. You should use new
when allocating arrays in C++.
精彩评论