TransWikia.com

How to use _Complex types in CUDAFunctionLoad?

Mathematica Asked on June 22, 2021

The documentation for CUDAFunctionLoad specifies various base datatypes you can use for your function’s arguments, including _Complex. However, in the abbreviated table showing the corresponding CUDA types only integer (_Integer, "Integer32" and "Integer64") and real (_Real, "Double", "Float") types are mentioned. So what should one use to compile functions having Mathematica complex numbers as arguments? In other words, if I wanted to modify the "addTwo" example in the documentation to take complex-number arguments, what should I change in

code = "
__global__ void addTwo(mint * in, mint * out, mint length) {
    int index = threadIdx.x + blockIdx.x*blockDim.x;
    if (index < length)
        out[index] = in[index] + 2;
}";

cudaFun = CUDAFunctionLoad[code, "addTwo", {{_Integer, _, "Input"}, {_Integer, _, "Output"}, _Integer}, 256]

In practice, I need my function to be able to take some CUDAMemory resulting from a CUDAFourier call and do a simple manipulation with it.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP