[abc-dev] Cflow and threads

From: Bruno Harbulot <bruno.harbulot@cs.man.ac.uk>
Date: Thu Aug 04 2005 - 15:52:57 BST


I have written an extension for having a join point for loops in abc,
and I'm using it for parallelisation.

I am getting some problems when using multiple Java threads and cflow.
When I want to parallelise an outer loop, I write a pointcut similar to
    pointcut outerloop:
       loop() & !cflowbelow(loop()) ;

    pointcut loopstoparallelise(int min, int max, int stride):
       outerloop() && args(min, max, stride, ..) && within(somemethod());

(min and max represent the min and max values if the loop could be
written as for(int i = min; i<max; i+=stride))

Parallelising then works with an around piece of advice of this form:

    void around(final int min, final int max, final int stride):
        loopstoparallelise(min, max, stride) {
            Runnable runnables[] = new Runnable[THREADS_COUNT] ;
            for (int k = 0 ; k < THREADS_COUNT ; k++) {
                final int slice_min = ...
                final int slice_max = ...
                runnables[k] = new Runnable() {
                    public void run() {
                        proceed(slice_min, slice_max, stride) ;
                } ;

I'm having problems with the CFlowCounter (abc101runtime version).
The generated code uses incCounter(Counter) and decCounter(Counter) with
the same instance of Counter for all the threads. This leads to results
that are wrong (or some deadlock situations).

It seems that using CFlowCounter.inc() and dec() would have solved the
problem, since it would have used a per-thread counter via
Is there any means to force abc to use them? As far as I can see,
CflowOldCounterCodeGen in abc.weaving.weaver.CflowCodeGenUtils does not
use these methods at all.

I have not looked in details in the 1.0.2 cflow implementation, but it
seems that similar problems could occur.

Best regards,

Received on Thu Aug 4 15:53:05 2005

This archive was generated by hypermail 2.1.8 : Sat Aug 20 2005 - 11:20:08 BST