- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The prestress program reuses the same set of simple equations, I have never been a big user of functions, so just out of interest which will give me lower overhead or faster code
A function or a subroutine.
The main differences in the equations is a constant as the beam gets longer.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the case of function, there is a return value. Whereas subroutines an additional argument as reference to return value(s) if any.
Seeing that your code contains functions, it would seem that return values are used.
In the case of function, it requires no reference to the return argument to be pushed onto the stack as the (scalar) return (optimize code) is placed in a register which is then referenced after the call. The overhead for function can be as efficient as: call, code, move/compute to register in function, return, read from register.
In the case of subroutine (optimized code, but not inlined), the overhead would be: load reference to return, push that reference onto stack, call, code, read reference for return, move result via reference, return
IOW the overhead for return arguments are:
function: write/compute to register, read register
subroutine (slowest): read reference address, write (push) reference, read (stack) reference, write result via reference
subroutine (fastest where reference is passed via register): read reference address, write to register, write result via reference
*** Note, subroutine fastest only occurs in optimized code when there are 4 or fewer arguments .AND. where the code in the subroutine is simple enough .OR. does not call external procedures such that it be required to save and restore the registered reference to the return argument.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I will use the functions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jim:
At the moment I am watching a long running program that is looking at some very old bridges. It is a CPU hog.
In the mean time: Yesterday I was reading a Guardian article - called the long read, it was on Evolution. The interest in the article is the large dispute for want of a better word between the various groups. The evolution of eyes is apparently a hot topic, how did such a complex thing arise in Biology.
The article talks about the modelling of evolution using computer models. So whilst I was walking the mall, I was thinking about Fortran and the eye evolution speed problem and your comments on Functions. This is just a thought exercise, but I thought you might be interested, one would of course only program the exercise in Fortran and obviously I would use IFX.
It needs to be simple, but imagine a Fortran sea world. Make it a large 3 dimensional array. If it is a sea then make it closed volume fully occupied with a fluid. Each element of the array is an integer and the integer represents the characteristics of the creature that occupies the small space. Free space is just a zero.
I was thinking you could start with two creatures, A and B - who will eat each other, so I dropped the prey model, you could start with a 50 - 50 model at an average density and randomly assigned location. Set a group of rules so that if A or B are in adjacent cells one may eat the other. If one dies then use some rule to add an A and B. I was thinking that it should be based on population relative sizes.
Your comments on speed differences, prompted the thought, what if A is suddenly given the ability to "see" - very limited across say two cells in one axis direction. Amend the eating rules for sight, and see if A fills the space.
The space could be subject to a flow effect in some non-random way like the Atlantic current. Slowly improve the eyes and see what else is required. - I was thinking the eye is useless without movement to take advantage of the new information.
Some one has probably written a program like this, but it was fun to think about the problem and how you would code it in Fortran.
Have a nice day
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> CPU hog.
Have you arranged the code for improved vectorization?
Have you added OpenMP parallelization?
Have you VTuned the code to see if convergence routines are inefficient (incorrect)?"
>>Evolution
See Game of Life
Simple rule based evolution, 2D, written in the 1970. I ran that when I was in college
This would be a good starting point.
What you desire is much more complicated: Sight, hearing, small, electric field sensing, temperature, current, O2 level, CO2 level, classification for your prey, classification for your predator, satiated, starving, mating/spawning needs, age, life span, etc...
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CPU hog - I need to look at all of that stuff, it is just I get asked more questions than I can answer and the code morphs slowly.
The long view article was deeply discussing the apparent inability of some to see how the evolution of the eye proceeded. Yes, the game of life is a simple, and good game. I was just musing to myself as I walked as to whether you could live with just the eye as the control, but you need movement as well, the eye is of no use without an ability to move towards or away from something that triggers the eye. All the other things in the soup of life are common for all, so I was just looking at the simplest game.
It was just a thought experiment.
Thanks
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There was an article, which you should be able to find with a little googling. It was a description of the eye of a dragonfly and how (as I recall) only 8 neurons are involved in identifying prey .AND. navigating to it. This is hard to believe. Maybe there was more to it.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting stuff, that is a huge computation jump from a single receptor that tells you where the light is for a thing swimming in the ocean to the dragonfly.
The Guardian article was talking about the fact that biology was not the hard science of chemistry and physics and that the models for evolution were not agreed.
https://www.theguardian.com/science/2022/jun/28/do-we-need-a-new-theory-of-evolution
The question does a Fortran model exists that takes the DNA of the two cell eye and using standard mutation can you arrive at the 8 cell eye.
You need to use the same math encoding the biology of the body uses.
I am just not sure if it has been done.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page