swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: optimization and C arrays (was Re: Return pointer to array: notposs


From: Paul E. Johnson
Subject: Re: optimization and C arrays (was Re: Return pointer to array: notpossible?)
Date: Thu, 01 Apr 1999 14:36:53 -0600

This is constructive commentary, I think.  Thank you very much.

"Theodore C. Belding" wrote:
 
> To profile, you have to
> compile your program with -pg. (I haven't used gprof specifically with Obj
> C, myself, but I've heard it works.) In general, you can assume that 90%
> of a program's run time is spent in just 10% of the code [1]. 

Yes, profiling does work, but after you take care of the easy problems,
you are left with a huge category objc_mesg_lookup, which consumes 85%
of the calls, and there's no way to differentiate among which messages
are using all the calls. 

I got the idea that a C-array was going to save objc_mesg_lookups,
instead of the Swarm array, that is constantly looking up messages to
pass array items in and out. But, given your advice, I guess my study is
best spent on other aspects of the problem.

In case people are interested, on my linux system I did not recompile
swarm with profiling, just my application, and the command that works is
   make CFLAGS='-g -pg -fno-inline'
and when  you run the application, it creates "gmon.out" file and you
view that with "gprof recruiter". 

> 1) Use the right algorithms and data structures for your problem. (If
> you're worried that a Swarm list container is too slow for millions of
> objects, maybe you should be using a binary tree or hash container
> instead, not a C array.)
If an action has to be carried out for each of 10 objects for each of 1
million agents, it was just my guess that I could save 10 lookups for
each of 1 million agents by going to a C array rather than swarm array. 
Is it not correct that when you have a C array, and you grab item 5 with
array[4], it uses less steps than [SomeArray atOffset:4] to retrieve the
same thing?

My main objective was not to use pointers, but to use a C array instead
of a Swarm Array.  But, if you all say so, I'm willing to chalk that up
to a learning experience.

> 3) Avoid calling unnecessary operating system routines and using
> unnecessary I/O (especially disk I/O). 
Can you give me an idea of how I can write periodic output into memory
and then save it at the end of the run, rather using fprintf at every
timestep?  

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]