Changeset 128

Show
Ignore:
Timestamp:
04/14/07 05:25:55
Author:
apokayi
Message:

added a new test, modified compound test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • guts_main/src/compound_test.upc

    r127 r128  
    33#include <stdio.h> 
    44 
     5#define  N      10 
     6#define  W      THREADS*(THREADS - 1)/2 
     7#define  Z      50 
     8 
    59shared [2] int *shared p; 
     10shared [N] int *p1; 
     11shared int sh_affinity; 
     12upc_lock_t   *lock1; 
    613 
    714int main() 
     
    1118         */ 
    1219         
    13         int i
     20        int i, j
    1421        int affinity; 
    1522 
     
    3340                upc_free(p); 
    3441 
     42        /* 
     43         * To check that shared pointer arithmetic works correctly on  
     44         * dynamically allocated shared memory with different block sizes 
     45         */ 
     46 
     47        i = 2*THREADS*N; 
     48 
     49        p1 =(shared[N] int *) upc_all_alloc(2*THREADS,N*sizeof(int)); 
     50 
     51        if(p1 ==NULL) 
     52                GULA_FAIL("failed to allocate memory"); 
     53 
     54        while(i != 0) { 
     55                affinity = upc_threadof(p1+i-1); 
     56                if(affinity != (((i-1)/N)%THREADS))  
     57                        GULA_FAIL("failed to allocate memory in sequential order"); 
     58                i--; 
     59        } 
     60 
     61        upc_barrier; 
     62 
     63        if( MYTHREAD == 0 ) 
     64                upc_free(p1); 
     65 
     66        /* 
     67         * To check that barriers work correctly when used within iterations 
     68         */ 
     69 
     70        lock1 = upc_all_lock_alloc(); 
     71        if(lock1 == NULL)  
     72                GULA_FAIL("failed to allocate lock"); 
     73 
     74        upc_forall(i=0; i<Z; i++;continue) { 
     75                upc_lock(lock1);     
     76                sh_affinity += MYTHREAD; 
     77                upc_notify; 
     78                upc_unlock(lock1); 
     79 
     80                if(MYTHREAD == 0) 
     81                        for(j=0;j<100;j++);           /* Do some more work for just only thread 0 */ 
     82                upc_wait; 
     83     
     84                if(sh_affinity != W * (i+1)) 
     85                        GULA_FAIL("failed to synchronize inside upc_forall"); 
     86        } 
     87 
     88        if( MYTHREAD == 0) 
     89                upc_lock_free(lock1); 
     90 
    3591        return 0; 
    3692}