       Data binning with CUDA

• To: mathgroup at smc.vnet.net
• Subject: [mg122971] Data binning with CUDA
• From: psycho_dad <s.nesseris at gmail.com>
• Date: Sat, 19 Nov 2011 06:44:43 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```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[], t1[[2, 2]]}

(* Use BinCounts to get the number of points in each bin *)
t2 = BinCounts[qq, {0, 1, 0.01}] // AbsoluteTiming

(* 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] // AbsoluteTiming
CUDAMap[Sin, 2.0 Range] // 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

```

• Prev by Date: Re: EmpiricalDistribution bug
• Next by Date: Re: How to force integers
• Previous by thread: Re: Numerical Integration of Improper Integral
• Next by thread: Re: Data binning with CUDA