[petsc-dev] Backend independent VecGetArray for GPUs

Lisandro Dalcin dalcinl at gmail.com
Mon Oct 27 07:48:27 CDT 2014


On 27 October 2014 15:06, Matthew Knepley <knepley at gmail.com> wrote:
> On Mon, Oct 27, 2014 at 6:30 AM, Lisandro Dalcin <dalcinl at gmail.com> wrote:
>>
>> On 27 October 2014 13:49, Lisandro Dalcin <dalcinl at gmail.com> wrote:
>> > 1) petsc4py will provide a method Vec.getCUDAAddress() that will
>> > return a plain Python integer (and a corresponding
>> > restoreCUDAAddress()). Any other name to suggest? Using "CUDAArray"
>> > would be a bit misleading in Python land.
>>
>> Perhaps "getCUDAHandle()" is better? Please help me to decide, I'm
>> really bad at naming things.
>
>
> I like handle. That is the traditional name.
>

Thanks! Take a look at branch dalcinl/cuda-handle
https://bitbucket.org/petsc/petsc4py/src/cec7da13bbb407a1b376f8e6b46b1ef31ca6e9b3/?at=dalcinl%2Fcuda-handle

PS: Ashwin, you could use contextmanager
https://docs.python.org/2/library/contextlib.html#contextlib.contextmanager
to handle the get/restore using Python's with statement, eg.

with gpuarray(vec) as array:
    launch_cuda_kernel(array)

-- 
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Numerical Porous Media Center (NumPor)
King Abdullah University of Science and Technology (KAUST)
http://numpor.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 4332
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459



More information about the petsc-dev mailing list