The M20k memory has several modes. For example, a M20k can be configured as 512 in depth, and x32 or x40 in width. But with OpenCL, how can i get different modes.Another question: if I defined a array in OpenCL as short buf. So, what type of memory does it use, M20k or MLAB? If M20k is used, what's the depth and width is for the M20k?
The configuration mode is not directly controllable in OpenCL. The compiler will automatically choose the best one for you. I would assume the configuration width would be the same as your type size; e.g. for short it will be x16. However, if you have unrolled consecutive accesses to the local buffer, then the compiler or eventually the mapper will instead opt to merge the small consecutive accesses into a larger coalesced one. You should be able to see the width and depth of the allocated buffer in the area report. It is also possible that the mapper would map smaller buffers to MLAB. The OpenCL compiler does not explicitly map anything to MLAB (or at least I have never seen any mention of MLAB in the area report".
There are attributes you can use when declaring the local variable (that you want to be instantiated as an M20K) to help control configuration in section 12.2 of the Intel FPGA SDK for Opencl Programming Guide. For example, you can define the number of banks to break your memory into, the width of the banks, etc. You can also see some examples and more discussion in the Intel FPGA SDK for Opencl Best Practices Guide section 7.4.As far as MLABs go, my experience has been that's a decision the compiler makes - I do not know of any sort of attributes to infer them. In my experience they're used for memories with shallow depth.