slide1
Download
Skip this Video
Download Presentation
CSS490 M++ Textbook No Corresponding Chapter

Loading in 2 Seconds...

play fullscreen
1 / 25

CSS490 M++ Textbook No Corresponding Chapter - PowerPoint PPT Presentation


  • 246 Views
  • Uploaded on

CSS490 M++ Textbook No Corresponding Chapter. Instructor: Munehiro Fukuda These slides were thoroughly the instructor’s original materials. Thread Migration overview. Moving: CPU status Stack (Heap). Migrating a thread. Memory access. Memory access.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'CSS490 M++ Textbook No Corresponding Chapter' - tan


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1
CSS490 M++

Textbook No Corresponding Chapter

Instructor: Munehiro Fukuda

These slides were thoroughly the instructor’s original materials.

CSS490 M++

thread migration overview
Thread Migrationoverview
  • Moving:
    • CPU status
    • Stack
    • (Heap)

Migrating a thread

Memory access

Memory access

Distributed Shared Memory (in most cases)

Local memory

Local memory

Local memory

Actual memory

access with high latency

LAN/SAN

CSS490 M++

slide4
M++
  • Mobile Agents
    • Merits: Inherent parallelism and multi-agent-base applications
    • Demerit: Performance problem because of their interpretation
  • Thread Migration
    • Merit: Fast migration
    • Demerits:DSM needed and No navigational autonomy
  • Logical Network
    • Global application-specific network
    • Constructed at run time
    • Node data referred to after migrating that node.
  • Extension of C++ Language
    • Agent encapsulated by object-oriented language
    • Navigational autonomy with strong migration

CSS490 M++

multi agent approach
Multi-Agent Approach

Simulate the interaction among agents

Advantages:

  • Overcomes the limitations of mathematical techniques
  • Encapsulates simulation models
  • Allows open-ended simulation

Disadvantages:

  • Performance
  • Parallel programming

CSS490 M++

parallelizing multi agent application with mpi
Object Queue

Object Queue

Obj 5

Obj 6

Obj 2

Obj 3

Obj 4

Obj 4

Obj 6

Obj 3

Obj 2

Obj 1

Obj 1

Obj 5

null

null

Exchange

Parallelizing Multi-Agent Application with MPI
  • MPI Process must
    • maintain each agent as a static object
    • maintain as a simulation space a two-dimensional array
    • change each status periodically
    • exchange them with remote processes
    • Synchronize with remote processes

Process 2

Process 1

Obj 7

LAN/SAN

CSS490 M++

parallelizing multi agent application with mobile agent
Parallelizing Multi-Agent Application with Mobile Agent
  • We don’t need a control process!
  • Each simulation entity works independently as an agent.

agent Shark {

Shark( ) { … }

void run( ) {

while (alive) {

compute( );

go( );

}

}

}

LAN/SAN

CSS490 M++

performance problem
Performance Problem
  • Mobile Agents:
    • They were cognitive agents designed to perform large remote jobs.
    • They are code in Java and Tcl, and thus interpreted.
    • Their size is so big and their speed is so slow.
  • Performance Improvement:
    • Self-migrating threads
    • Zero-copy migration library

CSS490 M++

m execution model
M++ Execution Model

1

Logical Network

hop([email protected])

Node

create Node with [email protected]

Link

Link

3

1

1

Thread

Node

Node

Node

Daemon Network

1

2

3

Daemon

Daemon

Daemon

Physical Network

LAN/SAN

CSS490 M++

m language overview
M++ Language Overview

class Node {// Defining nodes (and links) as C++ classes

public:

int var;

};

thread Thread { // Defining an M++ thread

private:

main() { // Executing its own behavior independently

create node with 1; // Creating a network node, (link, and thread)

hop( 1 ); // Migrating itself (and forking)

node.var = 10; // Accessing the current node, (and link)

}

};

CSS490 M++

m compilation
M++ Compilation

Includes three pieces of agent code

  • Source program
    • must have an mpp extension.
    • may include two or more agent code.
  • The mpp compiler
    • first preprocesses the source code into C++ files, each corresponding to a different agent.
    • pass them to the g++ compiler, and generates executable files, each again corresponding to a different agent.

[email protected][16]% ls

Car.mpp profile

[email protected][17]% m++ Car.mpp

***** compiling GSCashier

***** compiling SportsCar

***** compiling Truck

[email protected][18]% ls

Car.mpp GSCashier* SportsCar* Truck* profile

[email protected][19]%

Compile it with the m++ compiler

Message printed out from m++

Three executable files obtained

CSS490 M++

m profile
M++ Profile

[email protected][21]% cat profile

port 10145

hostnum 4

mode sthread

describe daemonid

medusa 0

mnode1 1

mnode2 2

mnode3 3

describe_end

[email protected][22]%

CSS490 M++

m daemon invocation
M++ Daemon Invocation

[email protected][4]% nohup thrd& exit

[1] 6659

logout

rlogin: connection closed.

[email protected][3]% nohup thrd& exit

[1] 6678

logout

rlogin: connection closed.

[email protected][3]% nohup thrd& exit

[1] 8200

logout

rlogin: connection closed.

[email protected][10]% thrd&

[1] 4954

port : 10145

Connction established to medusa with daemon 0

Connction established to mnode1 with daemon 1

Connction established to mnode2 with daemon 2

Connction established to mnode3 with daemon 3

Total daemon(s) : 4

Mode : sthread

Stack : 65536 byte

Ready for being injected.

[email protected][11]%

  • Run “thrd” on each PC
    • Open a new window for each PC and type thrd, OR
    • Remotely login each PC and type “nohup thrd&”
  • All thrd print out “ready for being injected”
  • You are ready to launch new m++ threads.

CSS490 M++

m thread launching
M++ Thread Launching

[email protected][11]% inject medusa ./GSCashier 1

Injected 1 ./GSCashier thread(s) to medusa

[email protected][12]% GSCashier: Waiting for cars.

[email protected][12]% inject medusa ./Truck 1

Injected 1 ./Truck thread(s) to medusa

[email protected][13]% Truck: I'm at the GasStation.

GSCashier: Injected fuel to Truck

Diesel: 900 Regular: 1000

GSCashier: Waiting for cars.

Truck: I'm filled with fuel.

[email protected][13]% fg

thrd

thrd: Interrupted.

thrd: Closed all connections.

thrd: Terminated.

[email protected][14]%

  • To launch a M++ thread, type
    • Inject target_IPname executable_file #threads arguments
  • To stop the M++ system
    • Bring back one of thrds to foreground and type cntl+c

CSS490 M++

m language in details thread definitions and deployment
M++ Language in DetailsThread Definitions and Deployment

thread Child { // spawned by a Parent thread

public:

Child(int argc, const char** argv):id( atoi(argv[5])){

strncpy(msg, argv[4], 16 );

}

void main() { cout << msg << id << endl; }

private:

char msg[16];

int id;

};

thread Parent { // injected first

public:

void main( );

private:

int i;

char idstr[10];

};

void Parent::main( ) {

for (i=0; i<10; i<++ ) { // spawn 10 Child threads

sprintf(idstr, “%d”, i);

create thread(“I am Thread No”, idstr);

} }

  • A thread constructor receives arguments starting from argv[4]
  • A thread immediately starts its own execution in main( ).

CSS490 M++

m language in details logical network construction
1

20

Path

10

Place

M++ Language in DetailsLogical Network Construction
  • Node creation and destruction
    • [e]create node(argsList) with (NodeId[@DaemonId]);
    • [e]destroy node(NodeId[@DaemonId]);
  • Link creation and destruction
    • [e]create link(argsList) with (SrcLinkId) to (NodeId[@DaemonId] with (DestLinkId)
    • [e]destory link(srcLinkId);
  • Only available in thread main( )

0

Init

class Place { };

class Path { };

thread Net {

public:

void main( ) {

create node( ) with( [email protected] );

create link( ) with(10)to([email protected]) with(20);

} }

1

0

Daemon

Daemon

CSS490 M++

m language in details network navigation
hi!

hi!

1

20

Path

10

Place

M++ Language in DetailsNetwork Navigation

0

Init

class Place { };

class Path { };

thread Net {

public:

void main( ) {

create node( ) with( [email protected] );

create link( ) with(10)to([email protected]) with(20);

hop( [email protected] );

hopalong( 20 );

forkalong( 10 );

cout << “hi!” << endl;

}

}

1

0

Daemon

Daemon

CSS490 M++

m language in details inter thread communication
Thread 2

Thread 1

Place

write

read

var

Daemon

M++ Language in DetailsInter-Thread Communication
  • Indirect communication: threads can read and write the same variable on the same node.
    • Thread 1

hop( [email protected] );

node.var = 10;

    • Thread 2

hop( [email protected] );

myVar = node.var;

  • Direct communication: A thread can access another thread directly.
    • Thread 1 reads Thread2

myVar = Thread[2].myVar;

    • Thread 2 writes Thread1

Thread[1].myVar = myVar;

Direct

myVar

myVar

Indirect

CSS490 M++

m language in details thread synchronization
M++ Language in DetailsThread Synchronization
  • Nodes are monitors
    • Unless a thread executes a network construction or a migration statement, it can continuously and exclusively run on the current node.
  • Synchronization statements
    • sleep: suspends until “wakeup threadId” or “wakeupall”.
    • sleep node: suspends until “wakeup[all] node”.
    • sleep daemon: suspends until “wakeup[all] daemon”.
    • wakeup threadId: resumes the thread with threadId.
    • wakeup node: resumes one thread sleeping on node.
    • wakeup daemon: resumes one thread sleeping on daemon.
    • wakeupall node: resumes all threads sleeping on node.
    • wakeupall daemon: resumes all threads sleeping on daemon.

CSS490 M++

slide21
ImplementationState Capturing

Thread

Thread

UsrClass thrvar;

thread Thread {

main() {

:

hop();

:

} };

UsrClass thrvar;

thread Thread {

main() {

:

hop();

:

} };

200

Execution

200

Resume

New pointer

Pointer

UsrClass thrvar;

200

UsrClass thrvar;

200

Old pointer

Pointer

Copy constructor

Dst

Daemon

Src

Daemon

Virtual function table

Virtual function table

Transfer

CSS490 M++

slide22
Main

Main

A

A

B

B

C

C

1

2

1

A

C

A

B

C

A

B

C

Main

C

Main

ImplementationThread Scheduling

Sthread Library

Pthread Library

User level

Kernel level

1:

1:

2:

CSS490 M++

slide23
Thread 2

Thread 3

ImplementationZero-copy communication

Receiver

Sender

User Area

User Area

Pin-downed pages

Thread 1

Thread 1

(2)

Thread 2

Thread 2

(3)

gather

scatter

Thread 3

Thread 3

Immediate

resumption

Packed Threads

Packed Thread

Kernel Area

Kernel Area

RAM

RAM

(1)

Zero-copy transfer

Network Interface

Network Interface

CSS490 M++

exercises no turn in
Exercises (No turn-in)
  • Consider the pros and cons of MPI and M++ when used to design a multi-agent application.
  • Why and when is thread migration necessary?
  • What is zero-copy communication? Why is it so effective?

CSS490 M++

final project
Final Project
  • Find a parallel application and program in both MPI and M++.
  • Compare their programmability and performance.
  • You may have a partner. One codes an MPI version, the other M++ version.
  • Exclude the following applications (already programmed):
    • Antfarm
    • Artificial societies
    • Growing neural network
    • Matrix multiplication
    • Mandelblot

CSS490 M++

ad