C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 05-27-2008, 03:33 AM   #16
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by arno-nyme View Post
I did not realize that underscores are reserved. Does it lead to trouble or is it just a question od style. I am not really a programmer, I just write a msters thesis

Davoud

ATTACHMENT: JPG - generator
It is a style issue - the problem comes when one of your symbols collide with one of the implementations.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-27-2008, 03:48 AM   #17
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,439
Quote:
Does it lead to trouble
It can, when the next version of the compiler decides it wants that symbol for its own purposes.
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Old 05-27-2008, 07:06 AM   #18
Registered User
 
Join Date: May 2008
Posts: 10
I used the mypowf function, but my program became slower.
Any explenations?

I did not use "-ffast-math", as I did not know how. I am not a progammer, just an by exident scientist (not even that in my real live)

Davoud
arno-nyme is offline   Reply With Quote
Old 05-27-2008, 07:14 AM   #19
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
It is likely to run slower if you don't use -ffast-math. When you compile your code with gcc, you give it options, one of those would be -ffast-math - that will take some short cuts, but it's only really relevant when working in corner-cases - such as dealing with infinity as an input or result. For the use you have, -ffast-math should give the exact same result.

I had already figured you weren't a proficient programmer - the code is not that good [just like you would probably spot something similar if I started discussing economics, trading and such].

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-29-2008, 04:00 PM   #20
Registered User
 
Join Date: May 2008
Posts: 10
:-)

I tried to find it out myself, but how do I put compiler -ffast-math flags with gcc / code::Blocks?

I implemented the memcp, and its faster now!
Many thanks for the help and effort put.


Davoud
arno-nyme is offline   Reply With Quote
Old 05-29-2008, 05:17 PM   #21
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,381
Quote:
Originally Posted by arno-nyme View Post
I am programming a "agent based" computer simulation in gcc. It basically does vector operations and gives as output some text files. Its an console application. It is written for scientific purposes. I would like to find a way to running this program dedicating the complete (or like 80%) of my processing power to it. File is attached. (code is messy I am not a professional programmer)
Under most non-real-time schedulers, there is no way to force a process to be scheduled exclusively so that it uses 100% of the CPU. However you can adjust its priority to make it more "attractive" to the scheduler, which will cause it to be scheduled more often. Of course the simplest way to give it as many cycles as possible is to make sure that nothing else is running on the machine.

At least, that's how I interpreted your question. The others seem to have interpreted it in terms of optimization. Thought I'd give an answer orthogonal to those.
brewbuck is offline   Reply With Quote
Old 05-30-2008, 02:38 AM   #22
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by arno-nyme View Post
:-)

I tried to find it out myself, but how do I put compiler -ffast-math flags with gcc / code::Blocks?

I implemented the memcp, and its faster now!
Many thanks for the help and effort put.


Davoud
Not sure how code::Blocks deal with compiler settings, but I'm sure there is a way to add extra settings to the compile phase. There you do need to add -ffast-math.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-30-2008, 01:43 PM   #23
Registered User
 
Join Date: Apr 2008
Posts: 278
Quote:
...you can adjust its priority to make it more "attractive" to the scheduler, which will cause it to be scheduled more often.
...and to do that, use the command "nice" ("man nice" for details).
root4 is offline   Reply With Quote
Old 05-30-2008, 01:45 PM   #24
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Quote:
Originally Posted by root4 View Post
...and to do that, use the command "nice" ("man nice" for details).
But you can only make your process HIGHER priority if you have superuser (root) privileges.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 05-30-2008, 02:23 PM   #25
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,439
And it's only of use if there actually is a less important application stealing CPU time. It won't make your program run faster.
In other words, if your total CPU usage isn't at 100%, nice isn't going to help, since there is CPU power available; the program just doesn't use it.
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Old 05-30-2008, 03:05 PM   #26
Registered User
 
Join Date: Apr 2008
Posts: 278
Quote:
It won't make your program run faster.
No one said the program would run faster, it was only said it would be less interrupted (scheduled more often & longer) which was one of the OP requests.

Quote:
if your total CPU usage isn't at 100%, nice isn't going to help, since there is CPU power available;
Any reference about that? because as far as I know it does modify the scheduling policy of the process, the only 'unknown' parameter being when the new policy is applied (depending on the process current state).

Quote:
the program just doesn't use it.
The program has no choice, this is managed by the O/S.
root4 is offline   Reply With Quote
Old 05-30-2008, 03:11 PM   #27
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
The system will always attempt to use the CPU to 100% - only if there is no runnable task will it be lower than that. nice does not change what happens to a process that is sleeping because it's waiting for data from the disk, for example.

In this case, the application will use as much CPU-time as it can (it is doing some disk IO at the start and end, but it's marginal in the overall runtime). Unless there are other tasks running on the same machine, there will be little or no benefit from using nice.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 06-01-2008, 12:41 AM   #28
Registered User
 
Join Date: May 2008
Posts: 10
Hi,

I investigated the pow thing further. It appears that even using -ffast-math it is slower. I suppose the reason is that I use x<1 e.G. mypow(15,0.25) as exponents.
The other things work well. Thank you.

Davoud
arno-nyme is offline   Reply With Quote
Reply

Tags
agent based, gcc, speed

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a program dingolay C Programming 4 10-01-2006 09:03 PM
Running a console application maxorator C++ Programming 4 10-03-2005 04:23 AM
Trying to output to a directory other than the root of where the program is running Howie17 C++ Programming 3 09-05-2005 08:57 AM
Get the PID of a console program BianConiglio Windows Programming 6 05-24-2004 05:24 AM
C++ console program using Ms Visual Studio .NET matheo917 C++ Programming 4 09-05-2002 11:16 PM


All times are GMT -6. The time now is 04:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22