[futurebasic] Re: [FB] [ANN] FBtoC - new release available

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2007 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Fri, 19 Oct 2007 11:22:11 +1300
Larry Siebenmann wrote:

> Brian Stevens wrote
>> any PowerPC running on an Intel Mac runs
>> slower because of the translation Rosetta
>> does from PowerPC to Intel machine code.

>  (1) How much slower (real examples please!)?

Here are some timings on my Intel 2.16 GHz Core 2 Duo. The same FB  
source code was tested as FB-compiled, and FBtoC-compiled. The test  
task was a complicated mix (mostly string and text processing, and  
table searches). The Rosetta slow-down in this case was 3 x.

  FB          ----FBtoC----
             native   Rosetta
  5.09 s     0.84 s    2.53 s


>  (2) Is it possible (and easy) to use the output
> of FBtoC to compile Intel-Mac-only binaries?

Try it yourself:
<http://4toc.com/fb4/FBtoC_Preview1a115.zip>
In the Preference settings dialog, see the 'Architecture' pop-up button.


> If so, what is the size ratio:
>
>      Universay binary ::  Intel-Mac-only binary

The executable sizes of a moderately large app (FBtoC itself):
Intel-only 376 KB
PPC-only   392 KB
Universal  772 KB

Support materials in the app package (resources, nib files...) add up  
to another 240 KB approx.


>  (3) If so, is it possible to stuff bits of
> Intel machine code into the "Intel-Mac"
> binary?

Yes, FBtoC allows you to pass chunks of code, including assembler,  
through to gcc. Here's an example.

#if def _PASSTHROUGHFUNCTION
inline float SSE_DotProduct3D( float v1[], float v2[] )
{
     float r;
     __asm
     {
         mov eax, v1
         mov ecx, v2
         movaps xmm0, [eax] // ??? | v1[2] | v1[1] | v1[0]
         movaps xmm1, [ecx] // ??? | v2[2] | v2[1] | v2[0]
         mulps xmm0, xmm1 // ??? | v1[2]*v2[2] | v1[1]*v2[1] |v1[0]*v2 
[0]
         movhlps xmm1, xmm0 // ??? | ??? | ??? | v1[2]*v2[2]
         addss xmm1, xmm0 // ??? | ??? | ??? | v1[0]*v2[0]+v1[2]*v2[2]
         shufps xmm0, xmm0, 1 // ??? | ??? | ??? | v1[1]*v2[1]
         addss xmm0, xmm1 // ??? | ??? | ??? |v1[0]*v2[0]+v1[1]*v2[1] 
+v1[2]*v2[2]
         movss r, xmm0
     }
     return r;
}
#endif


> (4) Is there a (small but useful) sub-species
> of Intel-Mac binary that can run somehow both on
> Intel-Macs and on some Mac Linux systems?

Linux's executable file format is different from that of OS X.  
Recompilation from C source would be required.

Robert P.