Altera_Forum
Honored Contributor
12 years agoSize and persistence of __local memory
Hi,
I was trying to understand the implementation of __local memory better and have two questions. 1. Max size of local memory ------------------------------- If I am not completely wrong, an OpenCL __local variable is placed in BRAM and a Stratix V should have about 7MB of that. So I was trying to allocate a large matrix like so: __kernel __attribute((reqd_work_group_size(1,1,1))) foo(...) { __local char matrix[2048][2048]; //read and write matrix here, otherwise it will be optimized away } (I also tried to declare matrix as __local in the parameter list and add __attribute__((local_mem_size(2048 * 2048))); I also tried to allocate it as a 1-Dimensional array; it all has the same result) If I compile this with aoc -c kernel.cl --report --estimate-throughput I get the two following lines in the report: ..# of RAMs (local mem) / compute unit : 262144 ... more ... ; Memory blocks ; 10257% ; The matrix should take 4MB space and should fit, I think, but it says I'm 10k percent over. Can anybody explain to me what's happening? Am I missing something? Is the report just assuming 16kB as 100% (it seems so) but synthesis would actually succeed? Is there any other limit I am not aware of? 2) Persistence of __local memory ------------------------------------- I was wondering if data stored into __local memory survives kernel invokations? Assume I have a 1-compute-unit, 1-dimension kernel that in the first invokation initializes the above __local matrix. Will the data be still available and valid the next time the kernel runs? I know that I cannot rely on that according to the OpenCL specification and on a GPU that makes a lot of sense because I don't know what other kernels may have run on the given compute unit. But here I know that no other kernel runs and there is only one compute unit that's dedicated to the kernel so I assume that nobody overwrites the BRAM "just for the fun of it". But I was wondering how bad this assumption really is---or if it is even wrong to rely on that (in the current version; it's OK if that may "change in the future")? Thanks in advance, Christoph