2 Replies Latest reply: Nov 17, 2010 2:49 PM by AlphaTrion RSS

    Assembler in C-code for Alchemy

    svolatch123

      Hello all!

       

      I aspire to reach high performance my left unfinished 3D-renderer for Flash-player. Soon enough I have understood that my ActionScript-code is doomed. Then I have started to learn Alchemy. And thanks to the help Bernd Paradies could transfer any data in the C-code and take away the ready image in the form of ByteArray. And it was essential faster. The same calculations occupying 10-15 seconds, now were measured by milliseconds.

       

      Wishing to move ahead further, I want to add still productivity in my code.

       

      I saw some topics about assembler and Alchemy.

      Also I understand what to use "x86-asm-code" in Alchemy it is impossible.

      But I want to ask. I can use "FlashPlayer-llvm-asm-code" in my C-code and in what type?

       

      Especially I am interested in operations of data transfer and floating point operations between registers (without using variables in memory) interest.

        • 1. Re: Assembler in C-code for Alchemy
          Bernd Paradies Adobe Employee

          Hello svolatch123,

           

          in this forum you'll find some posts about optimizations involving inline assembly code, i.e.:

           

               optimizing abc-code

               http://forums.adobe.com/thread/686022

           

               inline functions in C, gcc optimization and floating point arithmetic issues

               http://forums.adobe.com/thread/660099

           

          But in general I would avoid optimizations at the inline assembler level. Instead I would use profile your app and use the results to zoom in on specific areas that your optimizations will benefit from. You may have already done that and identified floating point calculations as one of those areas. If floating point calculations are your problem then you might be able to get better performance by using integer math internally (if that's possible). This technique is used by programs like Donald Knuth's TeX. The idea is that you do your math in integer units of floats (i.e. 1.234cm = 1 unit, 2 * 3 = 6 units = 6 * 1.234cm = 7.404cm).

           

          Another performance hog that will probably show up in your profiling results will probably point you to the fact that crossing the border between AS3 and C world (calling from AS3 code into Alchemy-C code and vice versa) is very expensive. You'll get good performance improvements by reducing calls that cross that boundary.

           

          If there is a piece of code in particular that you need to optimize I would post it here in this forum.

          I am sure you'll find help here.

           

          Best wishes,

           

          - Bernd

          • 2. Re: Assembler in C-code for Alchemy
            AlphaTrion

            If you use floats for your floating point operations take double instead of float. Double performs much more better cause it is the native as3 Number type without some internal roundings