Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6523

Data binning with CUDA

From psycho_dad <s.nesseris@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Data binning with CUDA
Date 2011-11-19 11:47 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <ja8506$ig4$1@smc.vnet.net> (permalink)

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

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

csiph-web