I am porting a piece of C code to 64bit on Linux. I am using 64bit
integers. It is a floating point intensive code and when I compile
(gcc) on 64 bit machine, I don't see any runtime improvement when
optimizing -O3. If I construct a small program I can get significant
(>4x) speed improvement using -O3 versus -g. If I compile on a 32 bit
machine, it runs 5x faster on the 64 bit machine than does the 64bit
compiled code.
It seems like something is inhibiting the optimization. Someone on
comp.lang.fortr an suggested it might be an alignment problem. I am
trying to go through and eliminate all 32 bit integers righ now (this
is a pretty large hunk of code). But thought I would survey this
group, in case it is something naive I am missing.
Any opinion is welcomed. I really need this to run up to speed, and I
need the big address space. Thanks in advance.
Dick 4 3292
Thanks for all the hints and thoughts.
My small program is:
main()
{
struct timespec ts;
double x,y;
int i;
long long n;
n=15000000;
n *= 10000;
fprintf(stderr, "LONG %Ld\n",n);
/*
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
*/
printf(" _POSIX_THREAD_C PUTIME _POSIX_CPUTIME %d %d\n",
_POSIX_THREAD_C PUTIME
,_POSIX_CPUTIME );
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
n = ts.tv_nsec;
fprintf(stderr, "Before %d sec %d nsec\n",ts.tv_s ec,ts.tv_nsec);
fprintf(stderr, "Before %d sec %Ld nsec\n",ts.tv_s ec,ts.tv_nsec);
y=3.3;
for(i=0;i<11110 0000;i++) {
x=sqrt(y);
y += 1.0;
}
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
fprintf(stderr, "After %d sec %d nsec\n",ts.tv_s ec,ts.tv_nsec);
fprintf(stderr, "After %d sec %Ld nsec\n",ts.tv_s ec,ts.tv_nsec-n);
}
It shows considerable improvement with -O3.
I think the problem is something less esoteric than the cache,
wordsize, etc. One thing I didn't say, I have multi threading loaded,
though no new threads are created by these runs. I have tried a newer
redhat, have not tried Intel compilers.
Dick
I think I misspoke on my timer program. That one was used to attempt
to measure thread time. You can remove the references to the timers
and run it. It only shows about a 2x improvement on optimization.
The large difference I have actually seen is 32bit compile on another
machine, run on 64bit machine (12sec) versus 64bit code compiled on
64bit machine (70sec).
Sorry for the confusion.
Dick
In article <ee************ *************** *******@s19g200 0prg.googlegrou ps.com>,
Dick Dowell <di*********@av agotech.comwrot e:
>Thanks for all the hints and thoughts.
>My small program is:
>main() {
struct timespec ts;
double x,y;
int i;
long long n;
n=15000000;
n *= 10000;
fprintf(stderr, "LONG %Ld\n",n);
/*
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
*/
printf(" _POSIX_THREAD_C PUTIME _POSIX_CPUTIME %d %d\n", _POSIX_THREAD_ CPUTIME
,_POSIX_CPUTIME );
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
n = ts.tv_nsec;
fprintf(stderr, "Before %d sec %d nsec\n",ts.tv_s ec,ts.tv_nsec);
fprintf(stderr, "Before %d sec %Ld nsec\n",ts.tv_s ec,ts.tv_nsec);
y=3.3;
for(i=0;i<11110 0000;i++) {
x=sqrt(y);
y += 1.0;
}
clock_gettime(C LOCK_THREAD_CPU TIME_ID, &ts);
fprintf(stderr, "After %d sec %d nsec\n",ts.tv_s ec,ts.tv_nsec);
fprintf(stderr, "After %d sec %Ld nsec\n",ts.tv_s ec,ts.tv_nsec-n); }
>It shows considerable improvement with -O3.
You do not do anything with x after you compute it. Any good
optimizer would optimize away the x=sqrt(y) statement. Once that
is done, the optimizer could even eliminate the loop completely
and replace it by y += 111100000. Compilers that did the one or
both of these optimizations would result in much faster code than
compilers that did not. Your problem might have nothing to do
with 64 bit integers and everything to do with which optimizations
the compiler performs.
--
"The human mind is so strangely capricious, that, when freed from
the pressure of real misery, it becomes open and sensitive to the
ideal apprehension of ideal calamities." -- Sir Walter Scott
Thanks for all the suggestions. I've discovered the ineffectiveness
of optimization is data dependent. I managed to profile the code and
78% of the runtime is spent in something called
_mul [1] (from gprof output, the [1] just means #1 cpu user)
Here's another line from gprof report
granularity: each sample hit covers 4 byte(s) for 0.01% of 109.71
seconds
index % time self children called name
<spontaneous>
[1] 78.0 85.55 0.00 __mul [1]
-----------------------------------------------
Dick This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wen Jiang |
last post by:
Hi,
Has anyone been able to get pymat work on a 64bit linux system? I
compiled the CVS version of pymat with python2.3/matlab7.01 on
Mandrake10.1 64bit system, it can start the engine and use put/get
function, but segfaults with eval function.
|
by: Vijay |
last post by:
Hi all,
Im using
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20)
on 64bit linux server
im trying to compile following code
--------------------sam.cpp---------------------
#include <string>
#include <iostream>
#include <stdarg.h>
|
by: dwelch91 |
last post by:
I need to detect whether the operating system I am running on (not the
Python version) is 64bit or 32bit. One requirement is that I need to
include support for non-Intel/AMD architectures.
The 2 ways I have thought detecting 64bit are:
1. struct.calcsize("P") == 8
2. '64' in os.uname()
I'm not convinced that either one of these is really adequate. Does
|
by: llothar |
last post by:
I must say i didn't expect this. I just did some measures on FreeBSD
6.2 with gcc 3.4.6 and there is absolutely no significant difference
between 32 and 64 bit mode - neither in compilation speed, nor in
speed of the compiled result.
As a benchmark i took a bootstrap of the SmallEiffel Compiler (which
has 38 files with around 100 kloc). The times i got were very
reliable. The bootstraping (compile the c files from last eiffel
compiler...
|
by: Iros |
last post by:
Could anyone recommend debuggers for 64bit Linux platforms, SLES 10 in
particular? I'm a Firebug addict but had no luck getting it up and
running.
Thanks!
| |
by: cman |
last post by:
Hi guys, why does this fail raising bad_alloc
int *v = new int ;
if this succeeds
int *v = (int *) malloc((unsigned)6000000000)
both on the same machine, same compiler g++, 64bit linux red hat
enterprise 4, no ulimits on the user, enough virtual memory ecc...
in both cases compiled with
|
by: Leo Park |
last post by:
Hello, guys.
I want to compile 32bit *.c and *.cc files On 64bit x86_64 systems.
But, it is not work.
---------------------------------------------------------------------------------------------------------------
bmk_mgr@ikdp101: gcc --version
gcc (GCC) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)
|
by: Neetu |
last post by:
Hi Everybody,
Our reports works well on every machine but not on 64bit systems.
We can view the report but when we press print button it does nothing, it
just stay there and prompt nothing, even no exceptions.
Even it does not execute the test code we wrote:
Dim pd As New PrintDialog
pd.ShowDialog()
|
by: Aditi |
last post by:
I am working around a problem called Y2038 bug.
http://groups.google.co.in/group/comp.unix.programmer/browse_thread/thread/a2f678e4f2761fb0/2816aaf1f50f863e?hl=en&lnk=st&q=time.h+64+bit+linux#2816aaf1f50f863e
I am developing an application which need to be built both on windows
and linux and used time_t, ctime, mktime, localtime and gmtime
functions from <time.h>.
The application already exists and I have to replace these 32bit time...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |