Topic
  • 7 replies
  • Latest Post - ‏2010-06-17T12:44:00Z by jadamcze
yuzung
yuzung
6 Posts

Pinned topic ppu-gcc,spu-gcc and gcc

‏2010-06-15T17:42:28Z |
hi

I'm newer in cell B.E

I used ppu-gcc,spu-gcc and gcc to compile a single program on CELL B.E. ,respectively.

What's the major difference within these 3 compilers when after accomplishing compile the single program?

I mean that run ppu-gcc's binary just use ppu and run spu-gcc's binary just use a spu ?? And if run gcc'binary use what??

Maybe my concept is wrong please tell me
Updated on 2010-06-17T12:44:00Z at 2010-06-17T12:44:00Z by jadamcze
  • jadamcze
    jadamcze
    219 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-15T23:51:44Z  
    > yuzung wrote:
    > What's the major difference within these 3 compilers when after accomplishing compile the single program?
    >
    > I mean that run ppu-gcc's binary just use ppu and run spu-gcc's binary just use a spu ?? And if run gcc'binary use what??

    gcc will probably be the same compiler as ppu-gcc, and will produce code that runs on the ppu.

    You can see the target that each compiler has by using the -v option.
  • yuzung
    yuzung
    6 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T07:05:31Z  
    • jadamcze
    • ‏2010-06-15T23:51:44Z
    > yuzung wrote:
    > What's the major difference within these 3 compilers when after accomplishing compile the single program?
    >
    > I mean that run ppu-gcc's binary just use ppu and run spu-gcc's binary just use a spu ?? And if run gcc'binary use what??

    gcc will probably be the same compiler as ppu-gcc, and will produce code that runs on the ppu.

    You can see the target that each compiler has by using the -v option.
    I still have a problem
    when I write a C program to computing a function execution time

    #include<stdio.h>
    #include<time.h>
    int main()
    {
    ....
    ....
    start = clock();

    function...

    finish = clock();
    duration = (double)(finish-start)/CLOCKS_PER_SEC;
    printf("%f second\n",duration);
    return 0;
    }

    when I used ppu-gcc to compile this program,I got a binary,successully.
    But I used spu-gcc to compile this program that got a error "undefined reference to 'times' "
    why??
  • jadamcze
    jadamcze
    219 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T07:39:17Z  
    • yuzung
    • ‏2010-06-17T07:05:31Z
    I still have a problem
    when I write a C program to computing a function execution time

    #include<stdio.h>
    #include<time.h>
    int main()
    {
    ....
    ....
    start = clock();

    function...

    finish = clock();
    duration = (double)(finish-start)/CLOCKS_PER_SEC;
    printf("%f second\n",duration);
    return 0;
    }

    when I used ppu-gcc to compile this program,I got a binary,successully.
    But I used spu-gcc to compile this program that got a error "undefined reference to 'times' "
    why??
    I was able to compile a variant of that program for spu with no undefined references. I haven't tried running the generated program.

    I'm using a locally built cross compiler for spu (gcc-4.5.0) and newlib-1.18.0 - so it might be version related. What version of the sdk are you using?
  • kenws
    kenws
    49 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T08:26:25Z  
    • yuzung
    • ‏2010-06-17T07:05:31Z
    I still have a problem
    when I write a C program to computing a function execution time

    #include<stdio.h>
    #include<time.h>
    int main()
    {
    ....
    ....
    start = clock();

    function...

    finish = clock();
    duration = (double)(finish-start)/CLOCKS_PER_SEC;
    printf("%f second\n",duration);
    return 0;
    }

    when I used ppu-gcc to compile this program,I got a binary,successully.
    But I used spu-gcc to compile this program that got a error "undefined reference to 'times' "
    why??
    According to section 8.1.1 of the C/C++ Language Extensions for Cell Broadband Engine Architecture document the time.h header is not supported on the SPU. You may consider using the SPU timer library instead (see the SPU Runtime Library Extension Guide).
    -ken
  • kenws
    kenws
    49 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T08:52:41Z  
    • jadamcze
    • ‏2010-06-17T07:39:17Z
    I was able to compile a variant of that program for spu with no undefined references. I haven't tried running the generated program.

    I'm using a locally built cross compiler for spu (gcc-4.5.0) and newlib-1.18.0 - so it might be version related. What version of the sdk are you using?
    Hi jadamcze,
    Using a recent version of the newlib (e.g. 1.18.0) the clock() function will return -1 and set errno to ENOSYS for the SPU target. So the following snippet:
    /* spu-gcc -Wall clocktest.c -o clocktest */
    
    #include<stdio.h> #include<time.h> 
    
    int main()
    { 
    
    if (clock() == -1) perror(
    "error"); 
    
    return 0; 
    }
    

    gives:
    
    $ spu-gcc -Wall clocktest.c -o clocktest && ./clocktest error: Function not implemented
    

    -ken
  • yuzung
    yuzung
    6 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T08:59:35Z  
    • jadamcze
    • ‏2010-06-17T07:39:17Z
    I was able to compile a variant of that program for spu with no undefined references. I haven't tried running the generated program.

    I'm using a locally built cross compiler for spu (gcc-4.5.0) and newlib-1.18.0 - so it might be version related. What version of the sdk are you using?
    I using sdk3.1 and spu(gcc 4.1.1)
  • jadamcze
    jadamcze
    219 Posts

    Re: ppu-gcc,spu-gcc and gcc

    ‏2010-06-17T12:44:00Z  
    • kenws
    • ‏2010-06-17T08:52:41Z
    Hi jadamcze,
    Using a recent version of the newlib (e.g. 1.18.0) the clock() function will return -1 and set errno to ENOSYS for the SPU target. So the following snippet:
    /* spu-gcc -Wall clocktest.c -o clocktest */
    <pre class="jive-pre"> #include<stdio.h> #include<time.h> int main() { if (clock() == -1) perror( "error"); return 0; } </pre>
    gives:
    <pre class="jive-pre"> $ spu-gcc -Wall clocktest.c -o clocktest && ./clocktest error: Function not implemented </pre>
    -ken
    > kenws wrote:
    > Hi jadamcze,
    > Using a recent version of the newlib (e.g. 1.18.0) the clock() function will return -1 and set errno to ENOSYS for the SPU target. So the following snippet:

    Thanks, good to know :)