Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6523 > unrolled thread
| Started by | psycho_dad <s.nesseris@gmail.com> |
|---|---|
| First post | 2011-11-19 11:47 +0000 |
| Last post | 2011-11-20 10:40 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Data binning with CUDA psycho_dad <s.nesseris@gmail.com> - 2011-11-19 11:47 +0000
Re: Data binning with CUDA "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-20 10:40 +0000
| From | psycho_dad <s.nesseris@gmail.com> |
|---|---|
| Date | 2011-11-19 11:47 +0000 |
| Subject | Data binning with CUDA |
| Message-ID | <ja8506$ig4$1@smc.vnet.net> |
Hi all,
Is it possible to bin data (actually I am only interested in the number of
points in each bin) by using only the CUDA functions available in Mathematica (CUDAMap etc)? The reason for this is that CUDAFunctionLoad for some reason is not working, so I have to use only what's built-in.
Important note: The data I want to apply this on are on the order of 10^6, they are in the range [0,1] and I want to find the number of points in bins of size 0.01.
So, with the above note in mind, I have done the following (the function I wrote myself is called MyCudaBin):
(* Make some mock data // Small scale test *)
qq = RandomReal[{0, 1}, 50000];
(* Use HistogramList to get the number of points in each bin *)
t1 = HistogramList[qq, {0, 1, 0.01}] // AbsoluteTiming;
{t1[[1]], t1[[2, 2]]}
(* Use BinCounts to get the number of points in each bin *)
t2 = BinCounts[qq, {0, 1, 0.01}] // AbsoluteTiming
(* Load CUDA *)
Needs["CUDALink`"];
(* This is my function *)
MyCudaBin[dat_] := Module[{sort, diffs, dat1},
sort = CUDASort[dat];
diffs =
Table[CUDAArgMinList[Ceiling[(sort - 2 - i)]], {i,
Range[0, 1, .01]}];
dat1 = Table[diffs[[i + 1]] - diffs[[i]], {i, 1, 100}];
dat1[[-1]] = Length[dat] + dat1[[-1]];
dat1
]
(* Test if CUDA is OK *)
CUDAMap[Sin, 1.0 Range[10]] // AbsoluteTiming
CUDAMap[Sin, 2.0 Range[10]] // AbsoluteTiming
(* Use my binning function *)
MyCudaBin[qq] // AbsoluteTiming
So, what I find is that in terms of speed (unsurpisingly) BinCounts is faster that HistogramList which is faster than MyCudaBin.
Obviously, my implementation sucks and that's why I ask for help!
Any help is appreciated!!!
Cheers,
Savvas
[toc] | [next] | [standalone]
| From | "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> |
|---|---|
| Date | 2011-11-20 10:40 +0000 |
| Message-ID | <jaale0$17l$1@smc.vnet.net> |
| In reply to | #6523 |
On Sat, 19 Nov 2011 11:47:18 -0000, psycho_dad <s.nesseris@gmail.com> wrote: > Hi all, > > Is it possible to bin data (actually I am only interested in the number > of > points in each bin) by using only the CUDA functions available in > Mathematica (CUDAMap etc)? The reason for this is that CUDAFunctionLoad > for some reason is not working, so I have to use only what's built-in. > > Important note: The data I want to apply this on are on the order of > 10^6, they are in the range [0,1] and I want to find the number of > points in bins of size 0.01. > > [...] > > So, what I find is that in terms of speed (unsurpisingly) BinCounts is > faster that HistogramList which is faster than MyCudaBin. > > Obviously, my implementation sucks and that's why I ask for help! > > Any help is appreciated!!! > > Cheers, > Savvas > Although I don't have CUDA-capable hardware so I can't suggest an alternative implementation, I would strongly suspect that for only 10^6 points a CPU-based approach will always be faster than a CUDA one no matter how optimised the code might be. The situation will likely be different for 10^7 points or with simultaneous processing of many lists of 10^6 points, but for such small inputs as you suggest above the processing time will be dominated by latency rather than throughput--and copying small arrays to the graphics card and back several times is inherently a fairly high-latency operation.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web