2

I have a program which works with 10 million variables max because of memory limitations. I need to make it 20 million but with same memory.

So what is the best way to do that in C++?

are there any libraries for it?

and does the calculations with half data types consume less time?

also mention if Cuda Supports the half data types

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Roshan
  • 548
  • 1
  • 3
  • 11
  • 3
    If all your data was in `double`, then the answer would be to simply use `float` (with the caveat that you loose precision and range). However, there's really no "half-float". Also, the loss of precision and range would be considerable. Can you please edit your question to include the value ranges you need to support, as well as the minimum precision needed? – Some programmer dude Sep 14 '15 at 07:54
  • Oh, and since no modern CPU supports "half-floats" natively, it will *increase* the number of operations needed for calculations, as you need to implement all those operations (like addition, division, etc.) yourself in code. It's the usual trade-off between saving space or saving time. – Some programmer dude Sep 14 '15 at 07:57
  • yes I have used double and integer only. I need to increase the speed and the number of variables supported. I use Cuda for parallel programming. So virtual memory is not an option. – Roshan Sep 14 '15 at 07:57
  • I guess you want to make the processing time per "variable" shorter? The problem is that even if you can halve the space used by those "variables" (for example by going from `double` to `float`) you probably won't be able to halve the processing time for each "variable", meaning if you double the number of "variables" you will increase the total processing time as well, you won't be able to keep it the same (or lower). – Some programmer dude Sep 14 '15 at 08:02
  • I want to increase ... 1. total number of supported variables. and 2. Speed while processing with same number of variables(say 10 mil vs 10 mil) :) – Roshan Sep 14 '15 at 08:13
  • 3
    @JoachimPileborg: Please note that is is a CUDA/GPU question, the IEEE 754 standard includes a BINARY16 floating point format, and a number of modern devices, including GPUs and ARM processors *do* support half precision floating point, be it fully IEEE 754 compliant or not – talonmies Sep 14 '15 at 08:51
  • 4
    CUDA 7.5. supports [16-bit Floating Point (FP16) Data](http://devblogs.nvidia.com/parallelforall/new-features-cuda-7-5/) – m.s. Sep 14 '15 at 08:52
  • 1
    @m.s I think that is the most sensible suggestion. CUDA 7.5 has [defined storage and conversion mechanisms](http://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF__MISC.html#group__CUDA__MATH____HALF__MISC) for `float` <-> `half` If you want to provide an answer I would upvote – Robert Crovella Sep 14 '15 at 21:11
  • @RobertCrovella in Cuda 7.5 half variables, it seems like we need to make use of functions for basic arithmetic, have they not use operator overloading for that purposes? – Roshan Sep 23 '15 at 04:23
  • At the current time, for CUDA 7.5, a typical use case would be to use the intrinsics to covert the half data type to an ordinary `float` data type, then use ordinary `float` arithmetic. – Robert Crovella Sep 23 '15 at 12:28

0 Answers0