开发者

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++.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜