Author Topic: Stupid Graphics Card Question: card memory general purpose?  (Read 1257 times)

0 Members and 1 Guest are viewing this topic.

Offline westfwTopic starter

  • Super Contributor
  • ***
  • Posts: 4298
  • Country: us
Stupid Graphics Card Question: card memory general purpose?
« on: October 22, 2020, 12:26:21 am »
Stupid question:
If your desktop has a graphics card with, say, 4GB of memory, but you're currently not doing anything GPU-intensive, can/will the CPU/OS use that as general purpose memory?  Granted that the PCIe bus isn't as fast as the actual memory bus, it's still much faster than disk-like storage...
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8749
  • Country: fi
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #1 on: October 23, 2020, 08:24:32 am »
No, this is not being done.

It's an interesting idea, though.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11707
  • Country: my
  • reassessing directives...
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #2 on: October 23, 2020, 08:57:30 am »
not directly i guess, you need to go through DirectX/OpenGL API and do some hack from there. but for what? when you can RAM up your MB at not so much price.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4172
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #3 on: October 23, 2020, 09:02:01 am »
If you have so much unused vram you could put swap there.

https://github.com/prsyahmi/GpuRamDrive
 

Online magic

  • Super Contributor
  • ***
  • Posts: 7158
  • Country: pl
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #4 on: October 23, 2020, 09:10:25 am »
Actually, part/all of the VRAM is mapped into the CPU address space and can be accessed like any other physical RAM. Same applies to many other PCI devices.

Throughput and access latency is going to be worse than primary RAM.
The CPU will typically be configured not to cache this memory; it could be changed with some kernel tinkering.

As shown above, there is some way in Linux to employ VRAM as swap space. Such use doesn't suffer from caching and latency problems because swap is accessed in 4KB pages, but of course swapping in a whole page has more latency than the data access which triggers it.

edit
The link above is some weird stuff.
See also here
https://wiki.archlinux.org/index.php/Swap_on_video_RAM
« Last Edit: October 23, 2020, 09:13:08 am by magic »
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4455
  • Country: nz
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #5 on: October 23, 2020, 09:10:53 am »
https://github.com/prsyahmi/GpuRamDrive/

You should be able to use the same cuda calls as this uses to just use it as extra RAM. This Windows source but the guts should be able to be ported to Linux.

It seems in some cases ("GPU_API == GPU_API_HOSTMEM") you can just use standard memcpy() to copy data between CPU and GPU, but in other cases you need to use cuMemcpyHtoD() or clEnqueueWriteBuffer().

I don't know what determines what API is available.

See GPURamDrive::GpuAllocateRam(), GPURamDrive::GpuWrite(), GPURamDrive::GpuRead() in https://github.com/prsyahmi/GpuRamDrive/blob/master/GpuRamDrive/GpuRamDrive.cpp
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4455
  • Country: nz
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #6 on: October 23, 2020, 09:11:50 am »
If you have so much unused vram you could put swap there.

https://github.com/prsyahmi/GpuRamDrive

Gah, you posted while I was reading code and composing my message...
 

Online magic

  • Super Contributor
  • ***
  • Posts: 7158
  • Country: pl
Re: Stupid Graphics Card Question: card memory general purpose?
« Reply #7 on: October 23, 2020, 09:33:15 am »
I'm not up to date with the latest developments in CUDA, but up to some 2013~2014 there was no way to map GPU memory into CPU address space with their APIs. The inverse is possible.

It seems in some cases ("GPU_API == GPU_API_HOSTMEM") you can just use standard memcpy() to copy data between CPU and GPU, but in other cases you need to use cuMemcpyHtoD() or clEnqueueWriteBuffer().

I don't know what determines what API is available.
CUDA and OpenCL availability depends on installed video card and drivers, obviously. As for that other one, everything you need to know is here:
Code: [Select]
void GPURamDrive::GpuAllocateRam()
{
#if GPU_API == GPU_API_HOSTMEM
m_pBuff = new char[m_MemSize];
:-DD
« Last Edit: October 23, 2020, 09:36:38 am by magic »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf