I have a piece of software that’s doing many manipulations of a vector of 4D data points, using OpenCL to do the heavy lifting. I have a default way of visualizing the data, but in the process of doing the development, I’ve found it helpful to create heatmaps as well. These help me see where the data is clustered and how it evolves over time. Obviously I can’t visualize all four dimensions at once, but just looking two dimensions at a time is helpful.
Unfortunately, I haven’t figured out any decent way to create the heatmap on the GPU; it seems that any two pixels can potentially have data dependencies between each other. Here’s the basics of what I’m trying to do, using C syntax:
typedef struct {
uint_t x, y, z, w;
} vect_t;
/*
* A[] is an array of vectors. Each component of each vector is
* guaranteed to have a value less than VECMAX.
*
* M[][] is the matrix of heatmap data that this generates.
* If M[x][y] has the value N, then there are N vectors where
* v.x == x and v.y == y.
*
* This also calculates the largest value of any cell in the
* heatmap, so the values can be normalized.
*/
int heatmap(const vect_t A[VECSIZE], uint_t M[VECMAX][VECMAX])
{
int max = 0;
for (int y = 0; y < VECMAX; y++) {
for (int x = 0; x < VECMAX; x++) {
M[x][y] = 0;
}
}
for (int p = 0; p < VECSIZE; p++) {
int x = A[p].x;
int y = A[p].y;
assert(x < VECMAX && y < VECMAX);
int nval = ++M[x][y];
max = MAX(max, nval);
}
return (max);
}
The image that this generates looks like it’s made of a mesh of dots, and that’s much better for my purposes than the more “blotchy” heatmaps that I’ve seen more often. The 4D object that I’m visualizing can be extremely complex, and I don’t think that a heatmap which blurred pixels together would be very useful.
Can anyone suggest an approach for doing this that would run well on a GPU?