Cid - PowerPoint PPT Presentation

About This Presentation
Title:

Cid

Description:

Model: MIMD threads with lock-protected shared data ... { nodep = (node*) malloc(sizeof(node)); cid_fork(jv; ) nodep- left = build_tree(d-1) ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 12
Provided by: charmC
Learn more at: http://charm.cs.uiuc.edu
Category:
Tags: cid | malloc

less

Transcript and Presenter's Notes

Title: Cid


1
Cid
  • CS498LVK
  • 4 April 2006
  • Aaron Becker
  • Abhinav Bhatele
  • Isaac Dooley

2
Overview
  • Model MIMD threads with lock-protected shared
    data
  • Intended to be similar to SMP threaded programs
  • Preprocessor for standard C compiler

3
Cid is C With
  • Global pointers
  • global int n
  • cid_get(n, CID_READ)
  • cid_rel(n)
  • Threads spawned on remote processors
  • cid_fork(jv )
  • do_work()
  • cid_jwait(jv)
  • More stuff well talk about later

4
  • struct node_s
  • int info
  • global struct node_s left
  • global struct node_s right
  • node
  • cid_forkable
  • global node build_tree(int d)
  • node nodep
  • cid_jvar jv CID_JVAR_INITIAL
  • if (d 0)
  • return CID_NULL
  • else
  • nodep (node) malloc(sizeof(node))
  • cid_fork(jv )
  • nodep-gtleft build_tree(d-1)
  • cid_fork(jv )
  • nodep-gtright build_tree(d-1)

5
  • cid_forkable
  • int sum_tree(global node nodep)
  • int i, s1, s2
  • cid_jvar jv CID_JVAR_INITIAL
  • if (nodep CID_NULL)
  • return 0
  • else
  • cid_get(nodep, CID_READ)
  • cid_fork(jv )
  • s1 sum_tree(nodep-gtleft)
  • cid_fork(jv )
  • s2 sum_tree(nodep-gtright)
  • i nodep-gtinfo
  • cid_rel(nodep)
  • cid_jwait(jv)
  • return i s1 s2

Whats wrong with this approach?
6
  • cid_forkable
  • int sum_tree(global node nodep)
  • int i, s1, s2
  • cid_jvar jv CID_JVAR_INITIAL
  • if (nodep CID_NULL)
  • return 0
  • else
  • cid_get(nodep, CID_READ)
  • cid_fork(jv cid_to_pe(nodep-gtleft))
  • s1 sum_tree(nodep-gtleft)
  • cid_fork(jv cid_to_pe(nodep-gtright))
  • s2 sum_tree(nodep-gtright)
  • i nodep-gtinfo
  • cid_rel(nodep)
  • cid_jwait(jv)
  • return i s1 s2

7
  • cid_forkable
  • int sum_graph(global node nodep)
  • int i, s1, s2
  • cid_jvar jv CID_JVAR_INITIAL
  • if (nodep CID_NULL)
  • return 0
  • else
  • cid_get(nodep, CID_WRITE)
  • if (nodep-gtmark TRUE)
  • cid_rel(nodep)
  • return 0
  • else
  • nodep-gtmark TRUE
  • cid_fork(jv cid_to_pe(nodep-gtleft))
  • s1 sum_graph(nodep-gtleft)
  • cid_fork(jv cid_to_pe(nodep-gtright))
  • s2 sum_graph(nodep-gtright)
  • i nodep-gtinfo

8
Automatic Load Balancing
  • On fork, if destination PE not specified, runtime
    attempts to choose underutilized processor
  • Work-stealing scheduler attempts to balance load
    dynamically

9
Accumulators
  • for (j0 jltN j)
  • cid_fork()
  • resultsj f()
  • s 0
  • for (j0 jltN j)
  • s resultsj

10
Accumulators
  • s 0
  • for (j0 jltN j)
  • cid_fork()
  • s f()

11
Distributed Arrays
  • Similar to HPF
  • cid_alloc_2d(jv, gp, NI, NJ,
  • sizeof_elem, distrib,
  • block_factor)

block, cyclic, etc.
size of dist. unit
Write a Comment
User Comments (0)
About PowerShow.com