9 Replies Latest reply on Dec 2, 2012 1:35 PM by jacksonfurrier

    Tahiti ISA assembler

    jacksonfurrier

      Hi All!
      I have a really simple question:
      Is it really possible tho assemble my ISA code on my 7970?
      I know that CodeXl provides things like dissassembling code and showing me the ISA
      but is it possible to write an assembly program, just like on the x86 architecture processors?
      And if yes, how?

       


      Thanks in advance,
      Adam

        • Re: Tahiti ISA assembler
          realhet

          Hi!

          It's possible to inject any binary code into an opencl .elf image and then execute it using the latest OpenCl api. (There's and easier way to do it using CAL, but it's kinda broken on 7970, only the 11.12_79xx 64bit Catalystworks well for that)

          The ISA disassembler you mentioned is inside the drivers, but AFAIK it exists only for debugging purposes and there is no ISA asm -> ISA binary compiler in the drivers.

          The best you can do is to write your own limited instruction set assembler (or code generator) for your specific tasks. Since July you can check the ISA documentation for the 7970 here -> developer/SDKs/AMD APP SDK/documentation/ AMD_Southern_Islands_Instruction_Set_Architecture_2012_Aug.pdf

          Also there is a good overview on instruction encoding in GCN_2620_final.pdf

          (site is under maintenance, I wasn't able to give exact links)

          • Tahiti ISA assembler
            jacksonfurrier

            Thanks for your answer. I was just wandering, because I am designing 128bit floating point arithmetic on this hardware and I'd like to make it fast and "useable"

              • Re: Tahiti ISA assembler
                realhet

                Hi,

                "because I am designing 128bit floating point arithmetic on this hardware"

                Someone else was also interested in int operations check this thread -> http://devgurus.amd.com/thread/159816 (Integer operations in GCN) here are the instruction you'll need.

                 

                In bignum arithmetic we have to work with carries. On GCN they can be handled elegantly with S registers, and with the v_addc_i32 instruction. At the moment this could be the reason choosing to write code in GCN asm.

                 

                For example here's a bigint multiplier cell:

                  v_mul_u32_u24    Work, MCols[CIdx], MRows[RIdx]             \

                  v_add_i32        MAcc[AccIdx], vcc, MAcc[AccIdx], Work      \

                  v_mul_hi_u32_u24 Work, MCols[CIdx], MRows[RIdx]             \

                  v_addc_u32       Carry, vcc, CIn, Work, vcc

                 

                It calculates a 48bit product from 2 24bit operands (MCols[CIdx]*MRow[RIdx]) and accumulates the result in 2 32bit registers (named MAcc[AccIdx] and Carry). 'Work' is a temporary register. And vcc is a temporary 'special 1bit' register which moves the carry from the first addition into the second addition.

                 

                Now do that in OpenCL within 4 clock cycles!

                 

                (btw that would be soo cool If there was a v_mad_u32_u24 which can generate carry -> this way bigint multiplication could be 33% faster)

                  • Re: Tahiti ISA assembler
                    jacksonfurrier

                    Hi,
                    Thanks it's really helpful but how can I assemble this code?
                    It is clear for me that writing the arithmetic part in GNC asm would be really really fast but
                    I have no idea how to assemble your or any code written with Tahiti ISA.

                      • Re: Tahiti ISA assembler
                        realhet

                        There's no official way to do it.

                        But you can do like compile a skeleton OpenCL kernel (compile it to binary only) and then patch your own binary code into it.

                        You'll have to handle .elf files. (Especially an elf file inside and elf image).

                        Read the GCN ISA manual, so you learn how to encode those instructions you're going to use. Also learn s_branch instructions because you'll have to adjust jump offsets.

                        Also there are GCN specific technical info in the latest OpenCL manual.

                         

                        It's not that easy, but AFAIK that's the only way. Since July there is official ISA documentation out. When the GCN card came out, it was harder, because all we had was a pdf brochure that luckily contained all the different instruction encodings and some tech info, and a disassembler.

                          • Re: Tahiti ISA assembler
                            jacksonfurrier

                            Thanks for all of the infos. So I have to write my code in byte code if I'd like to write a low-assemly-like program.

                             

                            Could you please show me a "project" like just, when e.g.: you write a simple code which doubles a value with all of the dirty work, like patching binary code into opencl kernel, using elf images ....