Hi -

I'm using an older version of Parrot (0.2.2) so I can use threads.

It seems that Parrot on Solaris doesn't ever use more than one processor.

The program attached should create argv[1] number of threads, and 
divide up over both of them argv[2] - ie perfect linear speedup.
I've got a dual-processor Xeon (a real one, not this hyperthreaded stuff)
and I indeed get speedup:

tonic(19)% time ./parrot /common/tmp/jon/thread_test.pir 1 500000000
<...>
18.870u 0.010s 0:18.93 99.7%    0+0k 0+0io 534pf+0w

tonic(20)% time ./parrot /common/tmp/jon/thread_test.pir 2 500000000
<...>
19.360u 0.030s 0:09.93 195.2%   0+0k 0+0io 534pf+0w
tonic(21)% 

However, on a Solaris machine that has 8 CPUs, we get no speedup:

pinot(6)% time ./parrot-solaris /common/tmp/jon/thread_test.pir 1 50000000
<...>
9.69u 0.05s 0:09.77 99.6%

pinot(7)% time ./parrot-solaris /common/tmp/jon/thread_test.pir 2 50000000
<...>
9.08u 0.09s 0:09.19 99.7%

pinot(8)% time ./parrot-solaris /common/tmp/jon/thread_test.pir 4 50000000
<...>
9.28u 0.07s 0:09.38 99.6%

pinot(9)% time ./parrot-solaris /common/tmp/jon/thread_test.pir 8 50000000
<...>
9.67u 0.03s 0:09.74 99.5%

Is there some way we can check to see if Parrot is actually creating more than 
one thread? Is it some sort of crazy green-thread issue?

Thanks,

-Erik


# Basic shared array program for parrot
.sub _main
        .param pmc argv
        .sym int threadIncs
        .sym pmc threads
        .sym pmc child
        .sym pmc Inc_array
        .local pmc increment_pass
        .local pmc seed_param
        .local int i, value, seed
        .local pmc temp
        .local int tmp
        .local int offset
        .local int numThreads
        .local pmc logtmlib
        .local pmc DoBreakpoint
        .local string parameter
        
        
        parameter = shift argv
        parameter = shift argv
        numThreads = parameter
        parameter = shift argv
        #numThreads = 1
        threadIncs = parameter
        threadIncs = threadIncs/numThreads
 
init_array:

        Inc_array = global "increment_array" # get function pointer
        
        # setup an array to hold threads
        threads = new .FixedPMCArray
        threads = 50
        
        # Set the number of increments to do in each thread
        increment_pass = new .Integer
        increment_pass = threadIncs
        
        seed = 54433
        seed_param = new .Integer
        
        i = 0
        
create_Thread:
        child = new ParrotThread  # basically new thread
        .sym pmc New_thread
        find_method New_thread, child, "thread3"
        seed_param = seed
        increment_pass = increment_pass 
        .pcc_begin
        .arg Inc_array
        .arg increment_pass
        .arg seed_param
        .invocant child
        .nci_call New_thread
        .pcc_end
        threads[i] = child
        inc i

        if i < numThreads goto create_Thread
        
        i = 0
# Join and wait on threads
_join_thread:
        .sym int tid
        .sym pmc Thread_join
        child = threads[i]
        tid = threads[i]
        find_method Thread_join, child, "join"
        
        .pcc_begin
        .arg tid
        .nci_call Thread_join
        .pcc_end
        threads[i] = child
        inc i
        if i < numThreads goto _join_thread
        
        #DoBreakpoint()
        i = 0
        tmp = 0
_main_print_loop:
        tmp = tmp + value
        print value
        print " "
        inc i
        if i < 100 goto _main_print_loop
        print "\n"
        print tmp
        print "\n"

.end


# The code to exectute in the thread
.sub increment_array
        .param pmc sub
        .param pmc increments
        .param pmc seed_param
        .local int i, tmp, value, numIncs, rand, index
        .local int temp
        
        numIncs = increments
        i = 0
        
s_loop:
        inc i
        if i < numIncs goto s_loop
        
        i = 0
.end


Reply via email to