You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
I'm using Thrust 2.1.1 with CUDA 12.2 on Ubuntu 20, deploying to a GPU with compute-capability 7.5.
My goal is to initialise a device array of cuDoubleComplex (provided by cuComplex.h), using Thrust's sequence() which accepts a device_ptr (and offset) and init and step scalars. I must use a cudaMalloc'd raw pointer (rather than a Thrust device_vector), and I must use cuDoubleComplex for the scalar type (as opposed to thrust::complex<double>) due to compatibility constraints.
The correctly initialised device array will have contents:
The output then is correct.
Unfortunately this is not a solution for me, since I am bound to maintaining the device array d_sv with type cuDoubleComplex.
Unable to hybridise cuComplex and thrust::complex
A precursory google suggested Thrust is compatible with cuComplex types (despite my results above), so I attempted to hybridise the two scenarios above: use cuDoubleComplex for the device array, and thrust::complex for the sequence arguments, like so:
Hi there,
The goal
I'm using Thrust 2.1.1 with CUDA 12.2 on Ubuntu 20, deploying to a GPU with compute-capability 7.5.
My goal is to initialise a device array of
cuDoubleComplex
(provided bycuComplex.h
), using Thrust'ssequence()
which accepts adevice_ptr
(and offset) andinit
andstep
scalars. I must use acudaMalloc
'd raw pointer (rather than a Thrustdevice_vector
), and I must usecuDoubleComplex
for the scalar type (as opposed tothrust::complex<double>
) due to compatibility constraints.The correctly initialised device array will have contents:
That is, we start at
.1i
and step by.2+.2i
.The problem
Attempting to do so with
cuComplex
directly...will not compile, since
sequence
needs acuDoubleComplex * size_t
operator:If we define the needed operators...
and compile, this code runs but produces an incorrect (unmodified) all-zero device array. I check the resulting device array via:
This is not an issue with our operator definitions, since replacing their returns with debug tests
yields the same erroneous result.
Works fine with
thrust::complex
, but not allowedI have checked that
sequence
works fine when giventhrust::complex<double>
as its type instead:The output then is correct.
Unfortunately this is not a solution for me, since I am bound to maintaining the device array
d_sv
with typecuDoubleComplex
.Unable to hybridise
cuComplex
andthrust::complex
A precursory google suggested Thrust is compatible with
cuComplex
types (despite my results above), so I attempted to hybridise the two scenarios above: usecuDoubleComplex
for the device array, andthrust::complex
for thesequence
arguments, like so:Alas, this throws compiler error:
Am I making an obvious mistake?
Is there any way to use
sequence
for my purpose without changing the type ofd_sv
away fromcuDoubleComplex
?Kernel is trivial, of course
I am aware just writing an un-optimised custom kernel for this case is trivial, like so:
however I need to perform more advanced operations with Thrust and
cuDoubleComplex
arrays; this is the simplest MWE I could make.Full MWEs
working
thrust::complex
code:failing
cuComplex
code:The text was updated successfully, but these errors were encountered: