swarm-hackers
[Top][All Lists]
Advanced

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

Re: [swarm-hackers] A new (non-framework-related) problem...


From: Nima Talebi
Subject: Re: [swarm-hackers] A new (non-framework-related) problem...
Date: Sat, 14 Nov 2009 12:08:53 +1100

Hi Scott,

On Sat, Nov 14, 2009 at 6:12 AM, Scott Christley <address@hidden> wrote:
Hey Nima,

I've been working with both CUDA and recently OpenCL, but I would not say the work is "integrated" with Swarm.  Most of my GPU programs are doing continuous deterministic models (differential equations) not stochastic agent-based models.  You need to think very carefully about how to take advantage of the fine-grained data-parallelism of GPUs with your model, because the GPU programming model imposes many limitations.

Sounds like you're well ahead of me :) - I'm going through the excellent lectures/slides from macresearch at the moment (D. W. Gohara), so I'll leave making any decision until I'm a little more educated, however I think I'll probably try and start of with OpenCL first.

My iMac GPU doesn't support OpenCL, but for now, I'll just try and learn the language and run it in CPU.

I do have one stochastic agent-based model which I tried with OpenCL, and I do get a decent speedup with the GPU, but for this model, utilizing the 8 CPU cores in parallel on my Mac was actually faster.  One nice thing about OpenCL is that the exact same source code can be used either on GPU or CPU just by changing a flag.  I'm not using Swarm though.

Yes - that's a good reason to try out OpenCL which I've only just learned about :) Do you have any POC code you're able to share?
 
I've thought about changing all my CUDA programs over to OpenCL, but I've heard that OpenCL can be slower because you have less control to do fine-tuning optimizations that you can with CUDA.  I haven't had a chance to directly compare.  Though I have discovered that a GPU program using different memory access patterns can easily have a 2-3x speed difference.

...well with OpenCL, at least you're not tied to NVidia, but I don't know how much of a concern that should be these days, plenty of them going around, and all the current NVidia cards support CUDA without exception (apparently so I've read :).

Nima
 
cheers
Scott

On Nov 13, 2009, at 8:13 AM, Nima Talebi wrote:

All done! Thanks Scott - I found and fixed all the little problems.

Now the behavior of the agent is controlled by the external BH* classes - the agent doesn not even know about them, they just latch onto any existing SwarmObject object or sub-class of, and then control it's behaviour from there.

At there moment I've only written one concrete class behavior - GetComfortable - which mimics the old [Heatbug -step] method, but I can easily now add more and more.

Now...

Has anyone had any luck with integrating CUDA into swarm?

As the agent gets more complex (via additional behaviors), I'd like to mine the GPUs for some resources.

Nima

On Fri, Nov 13, 2009 at 1:48 PM, Scott Christley <address@hidden> wrote:

You need to check if the *new* position is already occupied by another object, before you place the object there; your code isn't doing that.  Also, firstTime will never get set to false because the IF statement has the wrong _expression_, should probably be "if (firstTime)"

You should use YES and NO for the ObjC BOOL data type, TRUE and FALSE are probably ok, but I'm not sure how they are defined, as far as I know they are not defined by the ObjC runtime.

Scott

On Nov 12, 2009, at 5:58 PM, Nima Talebi wrote:

I'm getting a continuous stream of warnings like this in my vastly modified version of heatbugs (as part of a learning process for myself, and working towards deciding what to do for my thesis next semester)...

...
Grid2d: you're overwriting object 26c128 at (82,45) with object 0x26ebc8 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 26e4d8 at (62,78) with object 0x270208 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 274b48 at (112,2) with object 0x273a68 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 2375f8 at (57,14) with object 0x26e668 (Heatbug).
....


I have assert statements prior to every single move that a heatbug makes...

- (void)setX:(int)inX andY:(int)inY {
    static BOOL firstTime = TRUE;
    if((inX != [self x]) && (inY != [self y])) {
        // Update heat where we were sitting.
        [heatSpace addHeat:[self outputHeat] X:[self x] Y:[self y]];
       
        NSString *s = [NSString stringWithFormat:@"Found agent %@ here, expected %@ (self)",
                       [world getObjectAtX:[self x] Y:[self y]], self];

        if(!firstTime) {
            NSAssert([world getObjectAtX:[self x] Y:[self y]] == self, s);
        }   
        [world putObject:nil atX:[self x] Y:[self y]];
       
        // And where we're going...
        x = inX;
        y = inY;
        if(!firstTime) {
            NSAssert([world getObjectAtX:[self x] Y:[self y]] == nil, @"shit 2");
            firstTime = FALSE;
        }   
        [world putObject:self atX:[self x] Y:[self y]];
    }   
}



...These never get triggered, so as far as I can tell, the -setX:andY: will only ever work, iff the new position is vacant.  If that is the case however, why am I getting these warnings?

Note: the reason for firstTime is because the initial positioning of the heatbugs from [HeatbugsModel -buildObjects] does no checking for double occupancy.


--
Nima Talebi
web: http://ai.autonomy.net.au/People/Nima
gpg: B51D 1F18 D8E2 B702 B027 23A4 E06B DAC1 BE70 ADC0
_______________________________________________
swarm-hackers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/swarm-hackers


_______________________________________________
swarm-hackers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/swarm-hackers




--
Nima Talebi
web: http://ai.autonomy.net.au/People/Nima
gpg: B51D 1F18 D8E2 B702 B027 23A4 E06B DAC1 BE70 ADC0
_______________________________________________
swarm-hackers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/swarm-hackers


_______________________________________________
swarm-hackers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/swarm-hackers




--
Nima Talebi
web: http://ai.autonomy.net.au/People/Nima
gpg: B51D 1F18 D8E2 B702 B027 23A4 E06B DAC1 BE70 ADC0

reply via email to

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