Results 1 to 3 of 3

Thread: Memory access pattern

  1. #1

    Memory access pattern

    Hi all,

    I want to store in global memory a 2D grid where each cell grid stores 2 floats. I was wondering which is the best way. Every time a thread needs to read a cell grid position of memory it will always need to read the two floats. I mean, there's no situation where I just need the information of the first float, and the other way around. Additionally many threads can be accessing the same cell grid position simultaneously.

    So, according to this, my question. Is it more efficiently to store my grid a n cl_float2, being n the number of grid cells, or is it better to store it as n*2 cl_float?

    I think the idea is clear.

    Thank you.

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Memory access pattern

    Use float2 for the kernel arguments, for the hardware i've used it is somewhat faster. On the host side it probably wont make much difference.

    It tells the compiler you will only ever access the data aligned to float2's, so it can probably use a single or faster instruction to load it.

    Or ... use float4, and process two at once ...

  3. #3

    Re: Memory access pattern

    Quote Originally Posted by notzed
    It tells the compiler you will only ever access the data aligned to float2's, so it can probably use a single or faster instruction to load it.
    I understand that this is solved in compilation time. I mean, I do not have to do anything special, just declare my array as float2 and the compiler optimizes the access instructions. Correct me if I am wrong.

    Quote Originally Posted by notzed
    Or ... use float4, and process two at once ...
    Thanks, but because of the nature of my problem, I can't.

Similar Threads

  1. Memory Access
    By lcnepo in forum OpenCL
    Replies: 1
    Last Post: 12-09-2010, 04:22 PM
  2. Information concerning memory access
    By benschaff in forum OpenCL
    Replies: 14
    Last Post: 03-04-2010, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •