I have to calculate a functional (it’s a set of matrix vector multiplication in double precision, three matrix and six vector) of size n (square matrix nxn and vector of size n). If i have 4800 MBytes of global memory on my gpu (it’s a K20) and i want to transfer all the data on the gpu at one time, how i choose n to fill all the gpu global memory, take into account a double is 8 bytes?

The number of elements in the three matrices and six vector is 3*n*n + 6*n. If each element requires 8 bytes, the total amount of memory required is 8 * (3*n*n + 6*n) bytes. Chose a memory size and solve for n. If the total memory available is 4800 MB, n comes out to roughly 13800.

The number of elements in the three matrices and six vector is 3*n*n + 6*n. If each element requires 8 bytes, the total amount of memory required is 8 * (3*n*n + 6*n) bytes. Chose a memory size and solve for n. If the total memory available is 4800 MB, n comes out to roughly 13800.

The number of elements in the three matrices and six vector is 3*n*n + 6*n. If each element requires 8 bytes, the total amount of memory required is 8 * (3*n*n + 6*n) bytes. Chose a memory size and solve for n. If the total memory available is 4800 MB, n comes out to roughly 13800.

Thanks for the response! have you solved N as a normal second degree equation?

I did not actually solve a second degree equation, which would be necessary for an exact solution. By making note of the fact that the quadratic term dominates for larger N, one can conclude that the other terms to be neglected. So I simply took the square root, and even that I did not compute accurately but approximated by mental arithmetic (looks like that came out slightly on the low side).

I made this argument, please to follow me:

```
global memory = 5033164800 Bytes
# of elements (double) = 5033164800 / 8 = 629145600 elements
take n = 14200 and 3*n*n + 6*n total number of structure
3*14200*14200*3 + 6*14200 = 605005200 approx 629145600
i will choose n approx 14200, it's right?
```

Why 3*14200*14200*3? A square matrix of dimension N has N*N elements. Three such matrices have 3*N*N elements. Six 1-D vector of length N have 6*N elements. Total 3*N*N + 6*N elements.

With N=14200, we have 3*14200*14200 + 6*14200 = 605,005,200 elements. With each element being an 8-byte double precision number, these use a total of 4,840,041,600 bytes of storage, or about 4616 MB.

excuse a misprint, I wanted to write 3*14200*14200 :D

I agree with your argument with n = 14200 i’m using about 4600 Mbytes. In any case my interest is to find a n approximation to estimate the size of my problem (I do not want a n computed exactly). Thank you for your support.