[NetBehaviour] How to display code-based art...
james morris
james at jwm-art.net
Tue Sep 8 01:54:55 CEST 2009
Not unless you are willing to read assembly language, in which case use
objdump:
objdump --disassemble --section=.text ./executable
in elf files (the executable format linux most commonly uses), your
compiled code resides in the TEXT section. the above command only
disassembles that section. look in particular at the main sub-section
(i'm guessing).
you could disassemble your two executables redirecting the output to two
text files (using two invocations of objdump) and then compare the
disassembly using diff -u. i tried with a simple for loop, and
with/without -funroll-loops... no difference.
but a more likely way of producing a difference is to use -O2 (for speed)
as the optimization, or -Os (for size). these enable lots of different
optimizations.
James.
On 7/9/2009, "Pall Thayer" <pallthay at gmail.com> wrote:
>Ah haha... oops.
>
>Even so, after fixing there's no difference. I get the feeling that
>it's doing the same thing to both regardless of the funroll flag. Is
>there any way to see what it actually does?
>
>
>On Mon, Sep 7, 2009 at 9:14 PM, james morris<james at jwm-art.net> wrote:
>>
>> try this just to see what is happening:
>>
>> --------8<------------
>>
>> #include<stdio.h>
>>
>> int main()
>> {
>> int i;
>> for(i=0;i <= 999999999;i++){
>> printf("i1:%d\n",i);
>> for(i=0;i <= 999999999;i++){
>> printf("i2:%d\n",i);
>> for(i=0;i <= 999999999;i++){
>> printf("i3:%d\n",i);
>> for(i=0;i <= 999999999;i++){
>> printf("i3:%d\n",i);
>> for(i=0;i <= 999999999;i++){
>> printf("i3:%d\n",i);
>> for(i=0;i <= 999999999;i++){
>> }
>> }
>> }
>> }
>> }
>> }
>> return 0;
>> }
>>
>> --------8<------------
>>
>> so what you actually wanted was:
>>
>> --------8<------------
>>
>> #include<stdio.h>
>>
>> int main()
>> {
>> int i;
>> for(i=0;i <= 999999999;i++){
>> int i;
>> for(i=0;i <= 999999999;i++){
>> int i;
>> for(i=0;i <= 999999999;i++){
>> int i;
>> for(i=0;i <= 999999999;i++){
>> int i;
>> for(i=0;i <= 999999999;i++){
>> int i;
>> for(i=0;i <= 999999999;i++){
>> printf("Hello World");
>> }
>> }
>> }
>> }
>> }
>> }
>> return 0;
>> }
>>
>> --------8<------------
>>
>> which still does not result in any size difference!
>>
>> james.
>>
>>
>> On 7/9/2009, "Pall Thayer" <pallthay at gmail.com> wrote:
>>
>>>I don't know what I'm doing wrong but I'm not seeing a size difference
>>>in these two compilations:
>>>
>>>gcc -funroll-loops infinite.c -o infinite
>>>gcc infinite.c -o infinite2
>>>
>>>of this code:
>>>
>>>#include<stdio.h>
>>>
>>>main()
>>>{
>>> int i;
>>> for(i=0;i <= 999999999;i++){
>>> for(i=0;i <= 999999999;i++){
>>> for(i=0;i <= 999999999;i++){
>>> for(i=0;i <= 999999999;i++){
>>> for(i=0;i <= 999999999;i++){
>>> for(i=0;i <= 999999999;i++){
>>> printf("Hello World");
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>>}
>>>
>>>
>>>On Mon, Sep 7, 2009 at 6:37 PM, james morris<james at jwm-art.net> wrote:
>>>>
>>>> On 7/9/2009, "Pall Thayer" <pallthay at gmail.com> wrote:
>>>>
>>>>>What exactly happens when you try to unroll an infinite loop?
>>>>
>>>> http://en.wikipedia.org/wiki/Loop_unwinding#A_simple_example
>>>>
>>>> might shed some light on what might happen.
>>>>
>>>> james.
>>>>
>>>>>On Mon, Sep 7, 2009 at 6:14 PM, james morris<james at jwm-art.net> wrote:
>>>>>>
>>>>>> On 6/9/2009, "Rob Myers" <rob at robmyers.org> wrote:
>>>>>>
>>>>>>>On 06/09/09 22:23, james morris wrote:
>>>>>>>>
>>>>>>>>> You could unroll loops in the code manually using templates for
>>>>>>>>> different sections of the code. Or instantiate objects with other templates.
>>>>>>>>
>>>>>>>> Eurgh that's made me feel quite sick.
>>>>>>>
>>>>>>>It's a good job I didn't mention colouring in the letters to represent
>>>>>>>the compiled code then. ;-)
>>>>>>>
>>>>>>
>>>>>> I don't know about that. It was just the image of having something
>>>>>> physical - a large roll of paper - with code stenciled into it, and
>>>>>> applying the GNU C Compiler's -funroll-loops optimization to it, ++
>>>>>> that with C++ Templates, and stencils, templates, loops, and rolls. Spun
>>>>>> my head right round, and it was to me, pure genius of you to think of it
>>>>>> like that. I never thought jokes about programming could be so funny!!!!
>>>>>> Because all that I saw in Pall's stencil was a visual stencil of some
>>>>>> code, which looked quite attractive in a certain way.
>>>>>> _______________________________________________
>>>>>> NetBehaviour mailing list
>>>>>> NetBehaviour at netbehaviour.org
>>>>>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>--
>>>>>*****************************
>>>>>Pall Thayer
>>>>>artist
>>>>>http://www.this.is/pallit
>>>>>*****************************
>>>>>_______________________________________________
>>>>>NetBehaviour mailing list
>>>>>NetBehaviour at netbehaviour.org
>>>>>http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>>>>
>>>> _______________________________________________
>>>> NetBehaviour mailing list
>>>> NetBehaviour at netbehaviour.org
>>>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>>>
>>>
>>>
>>>
>>>--
>>>*****************************
>>>Pall Thayer
>>>artist
>>>http://www.this.is/pallit
>>>*****************************
>>>_______________________________________________
>>>NetBehaviour mailing list
>>>NetBehaviour at netbehaviour.org
>>>http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>>
>> _______________________________________________
>> NetBehaviour mailing list
>> NetBehaviour at netbehaviour.org
>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>
>
>
>
>--
>*****************************
>Pall Thayer
>artist
>http://www.this.is/pallit
>*****************************
>_______________________________________________
>NetBehaviour mailing list
>NetBehaviour at netbehaviour.org
>http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>
More information about the NetBehaviour
mailing list