Borrar filtros
Borrar filtros

Column-wise dot-products of two gpuArrays

2 visualizaciones (últimos 30 días)
Ahmed
Ahmed el 5 de Sept. de 2013
Is there a good way to compute column-wise dot-products of two matrices of same size when stored on the GPU? Specifically, say A and B are n (rows) times m (columns) matrices, I seek to find the 1 (row) times m (columns) row-vector of dot-products of the columns of A and B (i.e. the diagonal elements of the dot-product matrix). Following minimum working example demonstrates the computations:
n = 10;
m = 100;
A = randn(n,m);
B = randn(n,m);
C = bsxfun(@dot,A,B);
However, if A and B are gpuArrays, then this is not possible:
C = bsxfun(@dot,gpuArray(A),gpuArray(B));
% Error using gpuArray/bsxfun
% Use of 'dot' is not supported
Similarly, using anonymous function '@(a,b) a'*b' instead of '@dot' does not work. In my application n is roughly 100 and m roughly 500000. Hope that someone has an idea how C can be computed directly on the GPU and without for loops, as this was very slow for the given problem size.
Ahmed --

Respuesta aceptada

Ahmed
Ahmed el 5 de Sept. de 2013
A possible solution (I hope it will be helpful to someone):
C = sum(gpuArray(A).*gpuArray(B));

Más respuestas (0)

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by