Here it was asked how to generalize the procedure of marginalizing a table over given dimensions. The solution given here works very well.
I would like to have a parallelized version of that solution. In particular, I was wondering if it would be possible to use the GPU via OpenCL (I have a AMD Radeon Pro Vega 56).
In order to reduce the problem, perhaps one could initially consider the following simplified task. Let us define a test table tab
:
{n1, n2, n3} = {10, 20, 30};
tab = Table[{i1, i2, i3, i1 + i2 + i3}, {i1, n1}, {i2, n2}, {i3, n3}];
Then, this command marginalizes over the first and second dimensions:
newtab = tab[[1, 1, All, {3, 4}]];
Do[newtab[[i3, 2]] = -2 Log[Total[Exp[-tab[[All, All, i3, 4]]/2],Infinity]];, {i3, n3}];
while the following one marginalizes over the second dimension only:
newtab = tab[[All, 1, All, {1, 3, 4}]];
Do[newtab[[i1, i3, 3]] = -2 Log[
Total[Exp[-tab[[i1, All, i3, 4]]/2], Infinity]];, {i1, n1}, {i3,
n3}];
How to efficiently perform the latter operations with OpenCL?