JCSP CSP HPC H.Nakahara 1
2
CSP A B HPC H.Nakahara 3
CSP HPC H.Nakahara 4
CSP Process A chan Process B ( DFD) HPC H.Nakahara 5
DFD HPC H.Nakahara 6
DFD FAX OK? HPC H.Nakahara 7
HPC H.Nakahara 8
HPC H.Nakahara 9
HPC H.Nakahara 10
Process A chan Process B Ready Ready or HPC H.Nakahara 11
Process A chan Process B Ready Ready or HPC H.Nakahara 12
Process A chan Process B HPC H.Nakahara 13
Process A chan Process B CSP HPC H.Nakahara 14
Controller 2 1 : 0.2 2 : 0.5 HPC H.Nakahara 15
CSP : Communicating Sequential Processes HPC H.Nakahara 16
CSP OCCAM OCCAM Transputer OCCAM/Transputer HPC H.Nakahara 17
CSP for JAVA Process A chan Process B JAVA CSP for JAVA JCSP HPC H.Nakahara 18
ch0 ch1 ch2 0 1 ON/OFF 2 ch6 3 4 HPC H.Nakahara 19
CSP ON/OFF HPC H.Nakahara 20
CSP ON/OFF HPC H.Nakahara 21
CSP Send ch Read HPC H.Nakahara 22
JCSP Send ch Read HPC H.Nakahara 23
JCSP Send ch Read HPC H.Nakahara 24
JCSP Send ch Read Send Read HPC H.Nakahara 25
JCSP Send ch Read Send Read HPC H.Nakahara 26
Send ch Read HPC H.Nakahara 27
run( ){ } Send ch run( ){ } Read run( ) run( ) HPC H.Nakahara 28
Send import org.jcsp.lang.*; //ver1.1 class Send implements CSProcess{ private ChannelOutput out; public Send(ChannelOutput out){ this.out=out; } public void run( ) { int i=0; while (true){ i=i+1; out.write (new Integer ( i ) ) ; } } } HPC H.Nakahara 29
Read import org.jcsp.lang.*; //ver1.1 class Read implements CSProcess{ private ChannelInput in; public Read(ChannelInput in){ this.in=in; } public void run( ) { Integer i; while (true){ i=(integer)in.read(); System.out.println( "data="+i.intvalue( ) ) ; } } } HPC H.Nakahara 30
import org.jcsp.lang.*; //ver1.1 public class ParaMain{ public static void main( String[] arg){ One2OneChannel chan=channel.one2one ( ) ; // ver1.1 Send send=new Send( chan.out( ) ); Read read=new Read( chan.in( ) ); CSProcess[] csp=new CSProcess[]{send,read}; Parallel Para=new Parallel(csp); Para.run(); // } } HPC H.Nakahara 31
SendPassRead Send ch1 Pass ch2 Read 10 HPC H.Nakahara 32
Pass class Pass implements CSProcess{ private ChannelInput in; private ChannelOutput out; public Pass(ChannelInput inch,channeloutput outch){ this.in=inch; this.out=outch; } public void run(){ Integer N; int i; for(i=0;i<10;i=i+1){ N=(Integer)in.read(); out.write(n); } } } HPC H.Nakahara 33
SendPassRead public static void main( String[] arg){ One2OneChannel ch1=channel.one2one ( ) ; // ver1.1 One2OneChannel ch2=channel.one2one(); Send send=new Send(ch1.out()); Pass pass=new Pass(ch1.in(),ch2.out()); Read read=new Read(ch2.in()); CSProcess[] csp=new CSProcess[]{send,read,pass}; Parallel Para=new Parallel(csp); Para.run(); } HPC H.Nakahara 34
ch1 ch0 Increase Increase ch2 Root Increase Increase Increase HPC H.Nakahara 35
Increase class Increase implements CSProcess{ private ChannelInput in ; private ChannelOutput out; public Increase(ChannelInput in,channeloutput out){ this.in=in; this.out=out; } public void run(){ int I, d; Integer ii; for (i=0;i<10;i=i+1){ ii=(integer)in.read(); d=ii.intvalue()+1; out.write( new Integer ( d ) ) ; } } } HPC H.Nakahara 36
Root class Root implements CSProcess{ private ChannelOutput out; private ChannelInput in; public Root(ChannelInput in,channeloutput out){ this.out=out; this.in=in; } public void run(){ Integer ii; int i=0; for (i=0;i<10;i=i+1){ ii=new Integer(i); out.write(ii); ii=(integer)in.read(); System.out.println( "data="+ii.intvalue()); } } } HPC H.Nakahara 37
Ring100 public static void main(string[] args){ int N=100; // Increase One2OneChannel[] ch=channel.one2onearray(n+1); CSProcess[] CspRing=new CSProcess[N+1]; int i; CspRing[0]=new Root(ch[N].in(),ch[0].out()); // for (i=1;i<=n;i=i+1){ CspRing[i]= new Increase(ch[i-1].in(),ch[i].out()); } Parallel Ring=new Parallel(CspRing); Ring.run(); } } HPC H.Nakahara 38
HPC H.Nakahara 39
OutSelect Gate (Worker ) Alt Select Worker0 Worker1 WorkerN Alt select HPC H.Nakahara 40
Proc3to1 Send0 ch0 Send1 Send2 ch1 ch2 Read HPC H.Nakahara 41
Proc3to1 Read public class Read implements CSProcess{ public void run(){ Integer ii; int i; for (i=0;i<10;i=i+1){ ii=(integer)in0.read(); } System.out.println(" 0 data= "+ii.intvalue() ); ii=(integer)in1.read(); System.out.println(" 1 data= "+ii.intvalue() ); ii=(integer)in2.read(); System.out.println(" 2 data= "+ii.intvalue() ); } HPC H.Nakahara 42
Alternative Send0 Send1 Send2 ch0 ch1 ch2 Read HPC H.Nakahara 43
Alternative class AltselectRead implements CSProcess{ public void run(){ String str ; int i,index; Guard[] gd=new Guard[]{(Guard)in0,(Guard)in1,(Guard)in2}; Alternative alt=new Alternative(gd); for (i=0;i<30;i=i+1){ index=alt.select(); switch(index){ case 0 : str =(String)in0.read() ; break; case 1 : str=(string)in1.read() ; break; case 2 : str=(string)in2.read() ; break; } } fairselect priselect HPC H.Nakahara 44
ALT Send0 Send1 Send2 ch0 ch1 ch2 Read HPC H.Nakahara 45
cmd_in ON/OFF data_in HPC H.Nakahara 46
run public void run(){ Guard[] chng=new Guard[]{cmdin,datain}; Alternative alt=new Alternative(chnG); while(true){ switch(alt.priselect()){ case 0: cmdin.read(); // } } cmdin.read(); // break; case 1: dataout.write(datain.read()) ; // break; HPC H.Nakahara 47 HPC H.Nakahara 47
cmd_in data_in HPC H.Nakahara 48
Gate Distribute cmd_in data_in Distribute HPC H.Nakahara 49
SendForm ActiveCheckbox etc DataOut Gate CSP extensions for all AWT HPC H.Nakahara 50
ReadForm ActiveTextField etc DataIn GateFalse CSP extensions for all AWT HPC H.Nakahara 51
Send Pass Pass Read 100 : st 1000 Pass =(et - st) / / =(et - st) /100/1000 Pentium4 : 2000MHz : JAVA1.5 12( s) : et HPC H.Nakahara 52
CNS P1 ch P2 HPC H.Nakahara 53
CNS ch? ch LAN ch? P1 P2 HPC H.Nakahara 54
P2P CNS P2P ch LAN P1 P2 P1 P2 HPC H.Nakahara 55
Send ch Read HPC H.Nakahara 56
public static void main( String[] arg){ One2OneChannel ch=channel.one2one(); Send send=new Send(ch.out()); Read read=new Read(ch.in()); CSProcess[ ] csp=new CSProcess[ ]{send,read}; Parallel Para=new Parallel(csp); Para.run( ); } HPC H.Nakahara 57
10.2.20.145 CNS ch LAN Send Read HPC H.Nakahara 58
Send public static void main(string[ ] args ) { System.setProperty( org.jcsp.tcpip.defaultcnsserver", "10.2.20.145") ; try { Node.getInstance().init( ); } catch (NodeInitFailedException e) { System.out.println("Node init failed n" + e); System.exit(-1) ; } new Send ( CNS.createOne2Net ( "ch" ) ). run( ) ; } HPC H.Nakahara 59
Read public static void main(string[ ] args ) { System.setProperty( org.jcsp.tcpip.defaultcnsserver", " 10.2.20.145 ") ; try { Node.getInstance().init( ); } catch (NodeInitFailedException e) { System.out.println("Node init failed n" + e); System.exit(-1) ; } new Read ( CNS.createNet2One ( "ch" ) ). run( ) ; } HPC H.Nakahara 60
Network One2Net ch Net2One Send Read HPC H.Nakahara 61
1. 10.2.20.145 CNS chan LAN HPC H.Nakahara 62
Node A Node C ON/OFF Node B PC Node Node D HPC H.Nakahara 63
(J#.NET) CNS chan LAN HPC H.Nakahara 64
CPU : Intel Celeron 1300MHz LAN : 100BASE OS : Windows XP : J#.NET ( Visual Studio 2003) 1 740 int 1/740=1.35 ms HPC H.Nakahara 65
HPC H.Nakahara 66
.NET CPU : Intel P4 3000MHz LAN : 1000BASE OS : Windows XP : JIBU (C#.NET Visual Studio 2005) 1 2,000 4,000 float 0.5 0.25 ms / HPC H.Nakahara 67
1 HPC H.Nakahara 68
2 HPC H.Nakahara 69
100 JAVA CSP OK CSP extensions for all AWT HPC H.Nakahara 70
HPC H.Nakahara 71
HPC H.Nakahara 72
GUI GUI HPC H.Nakahara 73
d 2 x dt 2 + x(t)=0 x(t) = sin(t) HPC H.Nakahara 74
HPC H.Nakahara 75
run public void run(){ Float xx; float x, y ; float t = 0.0f; while ( t < exetime){ ParIO.run(); xx = ( Float) chin.obj; x = xx.floatvalue(); y = y + x * dt; chout.obj = new Float(y); t = t + dt; } } HPC H.Nakahara 76