25 9 2008 9 M ICROEL ECTRON ICS & COMPU TER Vol. 25 No. 9 September 2008 J ava 1,2, 1,2, 1,2 (1, 330022 ; 2, 330022) :,. Apla - Java,,.. : PAR ;Apla - Java ; ;CMP ; : TP311 : A : 1000-7180 (2008) 09-0018 - 03 A Multi2Core Programming Method Based on Java Reusable Components J IE An2quan 1,2, SHI Hai2he 1,2, XU E Jin2yun 1,2 (1 School of Computer Information & Engineering, Jiangxi Normal University, Nanchang 330022, China ; 2 Key Laboratory for High2Performance Computing Technology Jiangxi Province, Nanchang 330022, China) Abstract : Multi2core software development lags behind the development of multi2core hardware at present, the difficulties of multi2core programming development is mainly concentrated in the software. In this paper,we introduced the design method of Apla2Java reusable components. We propose an approach to multi2core programming based on the Apla2Java reusable components. Some example shows this components can be applied to multi2core programming correctly. method has positive significance in improving the efficiency of multi2core programming. Key words : PAR ; Apla2Java ; reusable momponents ; CMP ; multi2core programming The 1 ( Chip Multi2Processor, CMP),.,.., Apla [122 ], PAR [2 ], Apla2Java [1 ],., Apla2Java,. 2,,,. Intel,,,,., ( HPF) (OpenMP) [3 ]., : 2008-03 - 13 : (2003CCA02800) ; ( GJJ08155)
9, : Java 19., [4 ]. 3 Apla2Java Apla PAR,Apla2Java Apla Java.,Apla,,, 1. 1 Apla Apla A[J ] Get elem (set A) A J A B Intersection(set A,set B) A B A B Union (set A,set B) A B 3. 1 Apla2Java PAR,. S = R, PA R. S [1 n ] R [1 n ] S R, S = R S R. R [ j ]). (1) Q : S [1 n ] R [1 n ], R : equal ( n) = Π( j 1 j n S [ j ] = (2), : equal ( i) = F( equal ( i - 1), S [ i ], R [ i ]) (3) : equal ( i) = Π ( j 1 j i S [ i ] = R [ j ]) = Π ( j 1 j i - 1 S [ i ] = R [ j ]) = ( j j = i S [ i ] = R [ j ]) = equal ( i - 1) ( S [ i ] = R [ i ]). : algorithm equal var i integer begin i = 1^equal (1) = true termination i n recur equal ( i) = equal ( i - 1) ^( S [ i ] = R [ i ]) end. (4) : flag = equal ( i) 1 i n. (5) Apla funtion equal ( n) :boolean var i :integer ; flag :boolean begin i = 1 flag = true do i n flag = flag^ S [ i ] = R [ i ] i = i + 1 od end. Apla Java. PAR [2 ]. 3. 2 Apla2Java,,,., Ja2 va, synchronized.,,,.,., pv [1 ]. Java., Semaphore [1 ],,, readlock () writelock ().,,,.,,. 2. 2 Copy() Exchange (int i,int j) Subseq(int i,int j),
20 2008, : public arraylist subseq(int i,int j) { / / } s1. readlock () ; / / { } s1. readunlock () ; / / return new arraylist (1) ;, Apla2Java. 4 Apla2Java,,.. Apla2Java,,.,. import AplaJava. 3 ; / / class sort extends Thread / / { quicksort parent ; pv s ; / / int left,right ; String name ; public void run () / / run () { System. out. println ( : + getname () ) ; run (parent,left,right) ; s. v() ; / / } public class quicksort / / quicksort {public pv sl = new pv(0) ; / / public pv sr = new pv(0) ; arraylist L = new arraylist (10) ; / / public quicksort () { initarray() ; / / } startthread() ; / / sl. p () ; / / sr. p () ; printarray() ; / / public void startthread() / / { int i, j ; newinteger t, x, y ; } int left = L. get2h () ; int right = L. get2t () ; partion (left,right) / / sort qul = new sort ( 1,this,0, i - 1,sl) ; sort qur = new sort ( 2,this, i + 1,9,sr) ; } Intel, [ 10 8 6 4 16 18 20 2 22 12 ] :. :1 1 : :2 :2 2 : :18 2 : :12 1 : :8 1 : :4 2 : :22 : 2 4 6 8 10 12 16 18 20 22 5, Java.,,,.. : [1 ]. Apla2Java [J ].,2006 (4) :361-364. [2 ]. Apla2Java [D ]. :,2004. [3 ]. [ M ]. :,2007. [4 ]. [ M ]. :, 2008. :, (1975 - ),,.., (1979 - ),,.., (1947 - ),,..