2 Replies Latest reply on Dec 10, 2010 3:16 PM by frankas

    Where to store s-boxes for a cipher?

    michaelhuber

      hello to everybody, it's my first posting here.

      i am currently coding a blockbased implementation of a block-cipher that uses a standard s-box (8x8), so 8 bit input and 8 bit output. in every single round of the block-cipher i have to access to a s-box, which consists of 256 entries and therefore can be adressed with one byte.

      i definitly need indexed access to a "memory" where the s-box lies, fastest access as possible.

      currently i am using a temp-index-array, so i can access an element with x0[240] for example.

      my problem is though that there will be a need of 256 registers which can't be covered by the 128 registers. the compiler seems to swap them out to scratch-registers.

      any ideas, how to access an "indexed array" with fastest access as possible?

       

      thanks in advance

        • Where to store s-boxes for a cipher?
          himanshu.gautam

          michaelhuber,

          I am not familiar with the algorithm. But for accessing an indexed array fast you can use any of these alternatives depending on the access pattern and data properties:

          Use constant cache if the data is known before compile time. You need to provide static indexing in the kernel in order to store data inside constant cache.The data limit is quite low and may vary from gpu to gpu.

          Use LDS, if you need to fetch the same data elements many times or you need to fetch a particular set of data from a particular workgroup.LDS is common to all work items in a compute unit.

          You can have the benifit of texture cache by using images.

          Refer to openCL Programming Guide for details

          • Where to store s-boxes for a cipher?
            frankas

            May I ask which cipher you are implemneting ?

            If the S-box is 8 bits in and 8 bits out, packing it into 64 register, and using indexed registers (IL feature) should give good speed.