Memory Management on Jetson TK1

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

Memory Management on Jetson TK1

Postby ing.gabriel » Wed Sep 24, 2014 10:39 am

Hi!

I'm working on an ArrayFire application for Jetson TK1.
Is there a way to take advance of the fact that the memory is physically shared between CPU and GPU? I need to read repeatedly input data and currently my code is structured like:

float* RFpointer = (float*) RF.device<float>();
..
fread(data_host, size , file_id );
cudaMemcpy(ARRAYpointer, data_host ,size, cudaMemcpyHostToDevice)
RF.unlock();

Ideally I want to avoid to define two distinct memory areas and the communication between them.
Is there a way to write input data directly on the array?
Something like:

fread(ARRAYpointer, size , file_id );
RF.unlock();

Thank you, Gabriel
ing.gabriel
 
Posts: 2
Joined: Wed Sep 24, 2014 10:15 am

Re: Memory Management on Jetson TK1

Postby shehzan » Wed Sep 24, 2014 1:54 pm

Hi

Unfortunately there is no such capability put out by NVIDIA through their CUDA Toolkit.
Although the physical memory is the same, the API does not allow direct access through host and device for the same memory.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Re: Memory Management on Jetson TK1

Postby ing.gabriel » Sat Sep 27, 2014 6:00 am

Thank you. I've got an another question then.
Can I overlap the data transfer with the with GPU computation? Cuda provides cudastreams for that purpose but, as I've read in an other post, ArrayFire doesn't support it. Is there an other way? Maybe using multithreaded code by OpenMp directives?

Best regards, Gabriel
ing.gabriel
 
Posts: 2
Joined: Wed Sep 24, 2014 10:15 am

Re: Memory Management on Jetson TK1

Postby shehzan » Sun Sep 28, 2014 12:38 pm

This is possible if you are writing your own CUDA code, ie. writing memory management code and stream management.
However, ArrayFire does not currently support using streams and hence does not support compute overlap. We do not guarantee thread-safety either.
On the other hand, ArrayFire does have JIT which should give a good performance gain.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Re: Memory Management on Jetson TK1

Postby shehzan » Mon Sep 29, 2014 8:24 pm

A quick update on your query.
This is possible if you are using zero copy memory. CUDA allows mapping memory between host and device using the cudaHostAlloc call and the cudaHostAllocMapped flag.
See slide 21 at this link for more: http://on-demand.gputechconf.com/gtc-ex ... zation.pdf
However, you will have to write your own CUDA code for this as ArrayFire does not make use of this feature.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm


Return to [archive-commercial] Programming & Development with ArrayFire

cron