Strange 64 bit binaries slowdown vs 32 bit binaries on the same 11.464bit system

stamostolias wrote:

> But I said it again when we have #include
> <stdlib.h> you need a System(“pause”) to the end of algorithm.
>

I encourage you again to make yourself familiar with the basics before you
post and esp. before you post completely senseless things.

This is not the first thread where you are doing the following

  1. post things which are completely unrelated
  2. which are completely wrong and misleading and can result in a problem to
    everyone who follows your advise
  3. argument when your post is declared as wrong that you are a computer
    science student with a lot of experience in programming and whatever else

The missing quality and correctness of a variety of your posts not only in
this thread really makes it hard to believe that 3) can be true. This was
the most polite formulation I can find at the moment to describe this.

Your way of spreading incorrect information is no fun, it does do a harm to
the community in my point view and to every thread owner who becomes a
victim of that behaviour and to everyone who tries to help figure out the
real reason of a problem.

I’ll stop here and leave that as it is.
I hope some moderator can review that thread and not only this one to judge
it.
Over and out.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.1 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

printf("Num Primos: %i
",j) about that you are right, because I saw it and study it more carefully(sorry again for my rush), ok about that you are right . About my English you are not. All Greek men have a bit problem with their English.

Second, you can not start C++, you must first learn C and then C++. C is the father of Object Oriented Programming. So if you want to start with Object Oriented Programming, C is the first language who you must learn(Education about programming languages in Greek Universities).
Third about these errors from first algorithm, I mean Post 1, I was right. I saw many errors in it. Many of them I have written in other posts in this thread.
Fourth this link of wiki is the book who I had in the first year of my university and learn C(translated of course in Greek).

My University teacher, teaches me perfect. And I am a very good student in my university. So stop tell that. And i make nothing worse, you make them worse with your arrogance.

On 2011-04-22 17:55, martin_helm wrote:

> Here is a self contained example which shows you that you get the same speed
> with both (-m32 and -m64) if you take care to use the right declarations for
> the integer types:

Ah, yes.

> The benefit of using <stdint.h> and the types declared in it is that you get
> a C99 compliant program, which does not depend on the compiler defaults for
> different architectures.

Things get a bit more complicated typing var types :-p

The results are curious in another way: that the 64 bit code version is not
faster than the 32 code bit version when the integers are 64 bit. The 32
bit code should incur a penalty - so there are more things involved. It
must be that the arithmetic is heavy, as nrickert said.

time ./primos_short32 ; time ./primos_short64 ; echo “----” ;
time ./primos_long32 ; time ./primos_long64
Num Primos: 17984

real 0m6.380s
user 0m6.370s
sys 0m0.000s
Num Primos: 17984

real 0m6.416s
user 0m6.370s
sys 0m0.023s

Num Primos: 17984

real 0m20.778s
user 0m20.717s
sys 0m0.015s
Num Primos: 17984

real 0m21.815s
user 0m21.703s
sys 0m0.020s


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Carlos E. R. wrote:

> The results are curious in another way: that the 64 bit code version is
> not faster than the 32 code bit version when the integers are 64 bit. The
> 32 bit code should incur a penalty - so there are more things involved. It
> must be that the arithmetic is heavy, as nrickert said.
>
I am not an expert in integer arithmetic but I have to say I was also
slightly surprised, I expected some improvement when using -m64. It seems
the memory handling plays nearly no role with that example.
Do you see a difference when increasing the optimization level to -O3?
I cannot test it before tomorrow, I will check if there are some additional
command line switches for gcc which might have an effect besides only -m64
when trying to produce an optimized 64bit binary.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.2 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

Hi,

On Sat, 23 Apr 2011, stamostolias wrote:

>
> robin_listas;2328098 Wrote:
>> On 2011-04-22 17:36, stamostolias wrote:
>>
>>> Look I develop in C++ and study computer science, and know about
>> many
>>> in developing
>>
>> I don’t believe it.
>>
>>> With different names of variables I mean that when you declare a
>>> variable in the beginning of program, you can not change the name of
>>> variable inside program.
>>> For example
>>> int num
>>> …
>>>
>>> …
>>> …
>>> …
>>> …
>>> printf("Num Primos: %i
",j)
>>
>> printf is printing the text “Num Primos”, not a variable called “Num”
>> nor
>> “num”. This is basic C, if you don’t know that it is impossible your
>> are
>> studying computer science with C included.
>>
>> I refuse to consider the rest of what you said. My C skills are rusty
>> and
>> outdated, I know very little of linux programming, but yours are…
>> are
>> unbelievable.
>>
>> :frowning:
>>
>> Or perhaps you study pure C++ with no plain C. Dunno. I try to
>> understand it…
>>
>> Or perhaps you know no English and use an automated translator from
>> Greek
>> that makes such big warfs.
>>
>>
>> Hint: the program was compiled with “-Wall” enabled, and didn’t print
>> the
>> smallest protest. If what you said were true it would print big
>> complains.
>>
>> Hint2: Ask your teacher, before making things worse.
>>
>>
>> –
>> Cheers / Saludos,
>>
>> Carlos E. R.
>> (from 11.2 x86_64 “Emerald” at Telcontar)
>
> printf("Num Primos: %i
",j) about that you are right, because I saw
> it and study it more carefully(sorry again for my rush), ok about that
> you are right . About my English you are not. All Greek men have a bit
> problem with their English.

It’s good you can see that error, and you are able to admit you made a
mistake.

I hope you can do the same for the crazy system call rubbish you not
only recommended, but actually stated was required!!

>
> robin_listas Wrote:
>> Or perhaps you study pure C++ with no plain C. Dunno. I try to
>> understand it…
>>
>
> Second, you can not start C++, you must first learn C and then C++. C
> is the father of Object Oriented Programming. So if you want to start
> with Object Oriented Programming, C is the first language who you must
> learn(Education about programming languages in Greek Universities).
> Third about these errors from first algorithm, I mean Post 1, I was
> right. I saw many errors in it. Many of them I have written in other
> posts in this thread.
> Fourth this link of wiki is the book who I had in the first year of my
> university and learn C(translated of course in Greek).
>

Don’t be ridiculous, you don’t have to learn C to learn C++, I learnt
C++ long before learning C.

Also, C doesn’t really provide anything for object oriented programming.
Whilst you can work around this to some extent, it is not an ideal
language for object oriented programming and wasn’t written with OOP in
mind. Who told you C is ‘the father of object oriented programming’? I
hope it wasn’t an academic at your university…

I can’t see a link to a wikibook, but by the sounds of it you need to
invest in a good book on the C programming language before you comment
again. And another for the C++ programming language.

Also, a tip: when people tell you, you are wrong check before arguing,
they might be correct. We’re all wrong sometimes, even once we have a
Computer Science degree.

>
> –
> ALWAYS FRIENDLY STAMOS!!!:wink:
> Desktop: OpenSUSE 11.4||x86_64||KDE 4.6.2||AMD PHENOM II X3||AMD RADEON
> 6990 2 Cores.
> PROGRAMMING LANGUAGES: C++,FORTRAN.
> AMD: The Future Is Fusion
> ------------------------------------------------------------------------
> stamostolias’s Profile: http://forums.opensuse.org/member.php?userid=52202
> View this thread: http://forums.opensuse.org/showthread.php?t=457094
>


Regards,
Barry D. Nichols

Barry_Nichols@no-mx.forums.opensuse.org wrote:

You spoke to stamastolias but please forgive me that I make two comments:
>
> Don’t be ridiculous, you don’t have to learn C to learn C++, I learnt
> C++ long before learning C.
>
I want to second that from my own experience. I learnt C++ in 1994 without
knowing anything about C (but several years of programming knowledge in
Pascal and FORTRAN 77, not in a job but only at a university level as
student).
It was not before 2 years later that I for the first time in my life had to
do anything with plain C (the need was to understand legacy code) and it was
another two years later when I had to program something myself in C (after
several years of daily programming in C++ as a developer in the healthcare
industry).
>
> Also, a tip: when people tell you, you are wrong check before arguing,
> they might be correct. We’re all wrong sometimes, even once we have a
> Computer Science degree.
>
I want to second that also, we all are wrong sometimes explicitly including
myself and a degree in whatever subject does often not help being not wrong.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.2 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

On 2011-04-24 02:39, martin_helm wrote:
> Carlos E. R. wrote:
>
>> The results are curious in another way: that the 64 bit code version is
>> not faster than the 32 code bit version when the integers are 64 bit. The
>> 32 bit code should incur a penalty - so there are more things involved. It
>> must be that the arithmetic is heavy, as nrickert said.
>>
> I am not an expert in integer arithmetic but I have to say I was also
> slightly surprised, I expected some improvement when using -m64. It seems
> the memory handling plays nearly no role with that example.

The lesson is that we should not assume straight away that a 64 bit
processor and software is necessarily faster. It depends…

In real situations we will have to test the software we need in real
situations.

> Do you see a difference when increasing the optimization level to -O3?
> I cannot test it before tomorrow, I will check if there are some additional
> command line switches for gcc which might have an effect besides only -m64
> when trying to produce an optimized 64bit binary.
>

A bit faster (my previous test was with no optimization), with similar
relations:

cer@Telcontar:~/bin/C>
gcc -Wall -O3 -m32 primos_long.c -o primos_long32 ;
gcc -Wall -O3 -m64 primos_long.c -o primos_long64 ;
gcc -Wall -O3 -m32 primos_short.c -o primos_short32 ;
gcc -Wall -O3 -m64 primos_short.c -o primos_short64 ;

cer@Telcontar:~/bin/C> time ./primos_short32 ; time ./primos_short64 ; echo
“----” ; time ./primos_long32 ; time ./primos_long64
Num Primos: 17984

real 0m6.155s
user 0m6.148s
sys 0m0.000s
Num Primos: 17984

real 0m6.090s
user 0m6.084s
sys 0m0.000s

Num Primos: 17984

real 0m18.590s
user 0m18.486s
sys 0m0.001s
Num Primos: 17984

real 0m19.301s
user 0m19.209s
sys 0m0.046s


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

On 2011-04-24 04:01, martin_helm wrote:
> Barry_Nichols@no-mx.forums.opensuse.org wrote:

Me, I studied C before C++, this one briefly, and never used it
professionally (the plus). So I’m curious about that system(“pause”) thing
I’ve never heard about, so I googled it. (Internet and Google are still new
things for me). First hit tells not to use it. Second one, that it is a
windows visual C thing… Ahhh! >:-P

http://www.gidnetwork.com/b-61.html

Things to Avoid in C/C++ – system(“pause”), Part 4
by: WaltP - Sep 20, 2005

“It’s not portable. This works only on systems that have the PAUSE command
at the system level, like DOS or Windows. But not Linux and most others…”

http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/636a5fe5-06e8-4eaa-b88b-3d16921f161d

“But quite simply it is there for the convenience of not having the console
window automatically close after your program has finished.”

http://stackoverflow.com/questions/1107705/systempause-why-is-it-wrong

Q: “The command, System(“pause”); is taught to new programmers as a way to
pause a program and wait for a keyboard input to continue. However, it
seems to be frowned on by many veteran programmers as something that should
not be done in varying degrees.”
“Some people say it is fine to use. Some say it is only to be used when
you are locked in your room and no one is watching. Some say that they will
personally come to your house and kill you if you use it.”

A: “It’s frowned upon because it’s a platform-specific hack that has
nothing to do with actually learning programming, but instead to get around
a feature of the IDE/OS - the console window launched from Visual Studio
closes when the program has finished execution, and so the new user doesn’t
get to see the output of his new program.”

I understand now.

So, our greek friend has understood that a hack some use on some BAD
IDEs⁽¹⁾ is actually a needed thing for any C program. Good teaching on that
university. Sigh!

We should not, perhaps, blame him, but blame his university.

Perhaps the teacher did not make clear that it was a temporary hack.

Or perhaps he is too young and believes everything a teacher says is the
absolute truth, without consideration. Perhaps I did that time ago. Dunno.

(1) IMO, the IDE should not close the console automatically!

>> Also, a tip: when people tell you, you are wrong check before arguing,
>> they might be correct. We’re all wrong sometimes, even once we have a
>> Computer Science degree.
>>
> I want to second that also, we all are wrong sometimes explicitly including
> myself and a degree in whatever subject does often not help being not wrong.

Indeed! :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

It seems one has to do even more arithmetic to see a benefit when using 64 bit.
Here is a very trivial example, not a masterpiece, but it should show how the faster 64 bit arithmetic of the x86_64 architecture now comes into effect.

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>

int64_t arr[100000000];

int main(int argc,char* argv])
{
	clock_t t = clock();
    int64_t i=0;
    
    for(i=0; i<100000000; i++)
    {
		arr* = i * (i + i) + i;
    }
    printf("Time in milli sec %lu
", (unsigned long) (clock() -t)/1000);
    return EXIT_SUCCESS;
}

With the results:

martinh@sirius:~/scratch> ./bench32
Time in milli sec 1120
martinh@sirius:~/scratch> ./bench64
Time in milli sec 690

Compiled with:


gcc -m64 bench.c -o bench64
gcc -m32 bench.c -o bench32

Here in Greece in educational system first you learn C and then C++.

Again you are wrong. C is the father of orbject oriented programming.

Greek universities books of programming Αντικειμενοστρεφής προγραμματισμός - Βικιπαίδεια](Αντικειμενοστρεφής προγραμματισμός - Βικιπαίδεια)

And secondly the meaning of Class and objects had started in C and then in C++.

system() itself should be standard (although the “pause” part is probably platform specific), but you’ll need to include <stdlib.h>

As I see in the first algorithm(Post 1) this library exist

#include <stdio.h>
#include <stdlib.h>

inline int is_prime2(long num){
        long den=1;
        do{
                den++;
        }while( num%den != 0);

        if(den == num){
                return 1;
        }else{
                return 0;
        }
}

int main(int argc,char* argv]){
        long i=0;
        int j=0;
        for(i=2;i<=200000;i++){
                if (is_prime2(i) ){
                        //printf("%li / ",i);
                        j++;
                }
        }
        printf("Num Primos: %i 
",j);
        return 0;
}

Firstly my university teacher is not here.
Secondly I took this program to study it and found some errors. I study only this program, this program which I see in my screen and nothing more.
In the first program(Post 1) I saw this

system() itself should be standard (although the “pause” part is probably platform specific), but you’ll need to include <stdlib.h>

As I see in the first algorithm(Post 1) this library exist

#include <stdio.h>
#include <stdlib.h>

inline int is_prime2(long num){
        long den=1;
        do{
                den++;
        }while( num%den != 0);

        if(den == num){
                return 1;
        }else{
                return 0;
        }
}

int main(int argc,char* argv]){
        long i=0;
        int j=0;
        for(i=2;i<=200000;i++){
                if (is_prime2(i) ){
                        //printf("%li / ",i);
                        j++;
                }
        }
        printf("Num Primos: %i 
",j);
        return 0;
}

Hi,

I think rather than finding errors you found gaps in your knowledge.
Which is great, now you can learn something, and better to learn it here than at a job interview.

Also, as you’ll no doubt be aware of, just because a header is included in
a C program, it doesn’t mean you have to call every function defined in
that header file.


Regards,
Barry D. Nichols

I have not gaps in my knowledge I develop in C and C++ since 2003. I have not gaps as you said.
I do not continue this conversation here. If an algorithm has errors it can not run.

stamostolias wrote:

> I have not gaps in my knowledge I develop in C and C++ since 2003. I
> have not gaps as you said.
> I do not continue this conversation here. If an algorithm has errors it
> can not run.
>
Which shows that you have understood nothing about this thread, there was
never a question if it runs or not or if it is correct or not, because the
original program from the first post runs and it runs correct without any
problems. The OPs question was never how to make it run (because it already
worked), but was a question why the runtime was different with 32 vs. 64
bit.

I doubt you even tried to compile the original program from rcornet
otherwise you would have noticed from the very beginning that it was
correct.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.2 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

Anyway it is impossible to run this program. End of this conversation now.

stamostolias wrote:

> Anyway it is impossible to run this program. End of this conversation
> now.
>
Three users including me have run it, it seems you live in a parallel
universe with other laws of nature.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.2 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram

I mean the first one(Post 1).
And I live in same universe as you and in the same planet. These are not laws of nature these are laws of programming. And these laws are written in all programming books. So stop play with me. I do like to say something again and again if you do not want to understand it. And please be careful with your comments.

stamostolias wrote:

>
> I mean the first one(Post 1).
>
I mean the same.


PC: oS 11.3 64 bit | Intel Core2 Quad Q8300@2.50GHz | KDE 4.6.2 | GeForce
9600 GT | 4GB Ram
Eee PC 1201n: oS 11.4 64 bit | Intel Atom 330@1.60GHz | KDE 4.6.0 | nVidia
ION | 3GB Ram