Thanks a lot for the quick reply!
I was wondering whether I could "count" the number of elements in a
given interval by something such as:
moduleHistrogram = SourceModule("""
__global__ void H(float *pos, int size, float his, float lower_limit,
float upper_limit)
{
unsigned int idx = blockIdx.x*blockDim.x+threadIdx.x;
unsigned int idy = blockIdx.y*blockDim.y+threadIdx.y;
unsigned int id = idy*gridDim.x*blockDim.x+idx;
if (id<size) {
if (pos[id]<upper_limit && pos[id]>lower_limit){
his=his+1.0;
}
}
}
""")
I have tried this but it doesn't work (because the value of the
variable his is not "viewed" by different threads, each of them has
its own local value for the variable his. I also tried with the kernel:
moduleHistrogram = SourceModule("""
__global__ void H(float *pos, int size, float his, float lower_limit,
float upper_limit)
{
unsigned int idx = blockIdx.x*blockDim.x+threadIdx.x;
unsigned int idy = blockIdx.y*blockDim.y+threadIdx.y;
unsigned int id = idy*gridDim.x*blockDim.x+idx;
__shared__ float A;
A=his;
__syncthreads();
if (id<size) {
if (pos[id]<upper_limit && pos[id]>lower_limit){
A=A+1.0;
__syncthreads();
his=A;
}
}
}
""")
but the problem isn't solved.
Probably I'm doing something very stupid and I would like to know what
it is.
Thanks a lot,
Fran.
El 04/04/2012, a las 20:32, Andreas Kloeckner escribió:
<#part sign=pgpmime>
On Wed, 4 Apr 2012 19:47:08 +0200, Francisco Villaescusa Navarro <[email protected]
> wrote:
Hi,
I have been writing some lines for a project regarding management of
pretty large data sets. I have been trying to simplify the problem as
much as possible to understand where the problem is since I got wrong
results.
The simplification of the problem is the following:
I have a pretty long array of data containing numbers in a given
interval (let's suppose between 0.0 and 1.0), for example
total_numbers=10000
np.random.random(total_numbers).astype(np.float32)
I would like make a histogram of those data. I was wondering which
would be the best strategy to achieve this in PyCUDA.
http://lmgtfy.com/?q=cuda+histogram
:) (Nothing special about *Py*CUDA in this instance. In particular,
there's no canned functionality that will do this for you.)
HTH,
Andreas
_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda