# HG changeset patch
# User ryokka
# Date 1515137983 -32400
# Node ID 8fbc3ef749b637e8a6293cc5bcc6d1d834e47bed
# Parent f63a9a081b61be8cca8aaa96e6f3b966d3a139b9
separate Agda
diff -r f63a9a081b61 -r 8fbc3ef749b6 Dockerfile
--- a/Dockerfile Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-# docker build -t gears . # build container
-# docker run gears # launch container and attach
-
-FROM fedora:23
-
-WORKDIR /root
-RUN dnf update -y
-RUN dnf install -y gcc gcc-c++ mercurial git vim zsh tar findutils make gdb cmake
-RUN hg clone http://firefly.cr.ie.u-ryukyu.ac.jp/hg/CbC/CbC_llvm
-RUN mkdir /root/llvm_build
-WORKDIR /root/llvm_build
-RUN /root/CbC_llvm/configure --enable-assertions
-RUN make -j 2
-RUN make install
-ENV CBC_COMPILER /usr/local/bin/clang
-WORKDIR /root
-RUN git clone https://github.com/choller/llcov
-
-CMD zsh
diff -r f63a9a081b61 -r 8fbc3ef749b6 RedBlackTree.agda
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/RedBlackTree.agda Fri Jan 05 16:39:43 2018 +0900
@@ -0,0 +1,145 @@
+module RedBlackTree where
+
+open import stack
+open import Level
+
+record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
+ field
+ putImpl : treeImpl -> a -> (treeImpl -> t) -> t
+ getImpl : treeImpl -> (treeImpl -> Maybe a -> t) -> t
+open TreeMethods
+
+record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
+ field
+ tree : treeImpl
+ treeMethods : TreeMethods {n} {m} {a} {t} treeImpl
+ putTree : a -> (Tree treeImpl -> t) -> t
+ putTree d next = putImpl (treeMethods ) tree d (\t1 -> next (record {tree = t1 ; treeMethods = treeMethods} ))
+ getTree : (Tree treeImpl -> Maybe a -> t) -> t
+ getTree next = getImpl (treeMethods ) tree (\t1 d -> next (record {tree = t1 ; treeMethods = treeMethods} ) d )
+
+open Tree
+
+data Color {n : Level } : Set n where
+ Red : Color
+ Black : Color
+
+data CompareResult {n : Level } : Set n where
+ LT : CompareResult
+ GT : CompareResult
+ EQ : CompareResult
+
+record Node {n : Level } (a k : Set n) : Set n where
+ inductive
+ field
+ key : k
+ value : a
+ right : Maybe (Node a k)
+ left : Maybe (Node a k)
+ color : Color {n}
+open Node
+
+record RedBlackTree {n m : Level } {t : Set m} (a k si : Set n) : Set (m Level.⊔ n) where
+ field
+ root : Maybe (Node a k)
+ nodeStack : Stack {n} {m} (Node a k) {t} si
+ compare : k -> k -> CompareResult {n}
+
+open RedBlackTree
+
+open Stack
+
+--
+-- put new node at parent node, and rebuild tree to the top
+--
+{-# TERMINATING #-} -- https://agda.readthedocs.io/en/v2.5.3/language/termination-checking.html
+replaceNode : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+replaceNode {n} {m} {t} {a} {k} {si} tree s parent n0 next = popStack s (
+ \s grandParent -> replaceNode1 s grandParent ( compare tree (key parent) (key n0) ) )
+ where
+ replaceNode1 : Stack (Node a k) si -> Maybe ( Node a k ) -> CompareResult -> t
+ replaceNode1 s Nothing LT = next ( record tree { root = Just ( record parent { left = Just n0 ; color = Black } ) } )
+ replaceNode1 s Nothing GT = next ( record tree { root = Just ( record parent { right = Just n0 ; color = Black } ) } )
+ replaceNode1 s Nothing EQ = next ( record tree { root = Just ( record parent { right = Just n0 ; color = Black } ) } )
+ replaceNode1 s (Just grandParent) result with result
+ ... | LT = replaceNode tree s grandParent ( record parent { left = Just n0 } ) next
+ ... | GT = replaceNode tree s grandParent ( record parent { right = Just n0 } ) next
+ ... | EQ = next tree
+
+rotateRight : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+rotateRight {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
+
+rotateLeft : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+rotateLeft {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
+
+insertCase5 : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+insertCase5 {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
+
+insertCase4 : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+insertCase4 {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
+
+{-# TERMINATING #-}
+insertNode : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+insertNode {n} {m} {t} {a} {k} {si} tree s n0 next = get2Stack s (\ s d1 d2 -> insertCase1 s n0 d1 d2 )
+ where
+ insertCase1 : Stack (Node a k) si -> Node a k -> Maybe (Node a k) -> Maybe (Node a k) -> t -- placed here to allow mutual recursion
+ -- http://agda.readthedocs.io/en/v2.5.2/language/mutual-recursion.html
+ insertCase3 : Stack (Node a k) si -> Node a k -> Node a k -> Node a k -> t
+ insertCase3 s n0 parent grandParent with left grandParent | right grandParent
+ ... | Nothing | Nothing = insertCase4 tree s n0 parent grandParent next
+ ... | Nothing | Just uncle = insertCase4 tree s n0 parent grandParent next
+ ... | Just uncle | _ with compare tree ( key uncle ) ( key parent )
+ ... | EQ = insertCase4 tree s n0 parent grandParent next
+ ... | _ with color uncle
+ ... | Red = pop2Stack s ( \s p0 p1 -> insertCase1 s (
+ record grandParent { color = Red ; left = Just ( record parent { color = Black ; left = Just n0 } ) ; right = Just ( record uncle { color = Black } ) }) p0 p1 )
+ ... | Black = insertCase4 tree s n0 parent grandParent next
+ insertCase2 : Stack (Node a k) si -> Node a k -> Node a k -> Node a k -> t
+ insertCase2 s n0 parent grandParent with color parent
+ ... | Black = replaceNode tree s grandParent n0 next
+ ... | Red = insertCase3 s n0 parent grandParent
+ insertCase1 s n0 Nothing Nothing = next tree
+ insertCase1 s n0 Nothing (Just grandParent) = replaceNode tree s grandParent n0 next
+ insertCase1 s n0 (Just grandParent) Nothing = replaceNode tree s grandParent n0 next
+ insertCase1 s n0 (Just parent) (Just grandParent) = insertCase2 s n0 parent grandParent
+ where
+
+findNode : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> (Node a k) -> (Node a k) -> (RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> Node a k -> t) -> t
+findNode {n} {m} {a} {k} {si} {t} tree s n0 n1 next = pushStack s n1 (\ s -> findNode1 s n1)
+ where
+ findNode2 : Stack (Node a k) si -> (Maybe (Node a k)) -> t
+ findNode2 s Nothing = next tree s n0
+ findNode2 s (Just n) = findNode tree s n0 n next
+ findNode1 : Stack (Node a k) si -> (Node a k) -> t
+ findNode1 s n1 with (compare tree (key n0) (key n1))
+ ... | EQ = next tree s n0
+ ... | GT = findNode2 s (right n1)
+ ... | LT = findNode2 s (left n1)
+
+
+leafNode : {n : Level } {a k : Set n} -> k -> a -> Node a k
+leafNode k1 value = record {
+ key = k1 ;
+ value = value ;
+ right = Nothing ;
+ left = Nothing ;
+ color = Black
+ }
+
+putRedBlackTree : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> k -> a -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
+putRedBlackTree {n} {m} {a} {k} {si} {t} tree k1 value next with (root tree)
+... | Nothing = next (record tree {root = Just (leafNode k1 value) })
+... | Just n2 = findNode tree (nodeStack tree) (leafNode k1 value) n2 (\ tree1 s n1 -> insertNode tree1 s n1 next)
+
+getRedBlackTree : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> k -> (RedBlackTree {n} {m} {t} a k si -> (Maybe (Node a k)) -> t) -> t
+getRedBlackTree {_} {_} {a} {k} {_} {t} tree k1 cs = checkNode (root tree)
+ where
+ checkNode : Maybe (Node a k) -> t
+ checkNode Nothing = cs tree Nothing
+ checkNode (Just n) = search n
+ where
+ search : Node a k -> t
+ search n with compare tree k1 (key n)
+ search n | LT = checkNode (left n)
+ search n | GT = checkNode (right n)
+ search n | EQ = cs tree (Just n)
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/Cerium_on_Gears.mm
--- a/doc/Cerium_on_Gears.mm Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/ChangeLog.txt
--- a/doc/ChangeLog.txt Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-Mon Apr 13 20:13:54 JST 2015 kkb
-
- version 管理も built in であるべき
- プログラムを走らせるときに使うコードセグメントの集合は決まってる
- unix の command に相当
- context がすべて知っている必要がある
- プログラムの走り方で dynamic loding liblary が変わる
- Reflection を意識したプログラミング
-
-Fri Apr 10 17:52:46 JST 2015 Tatsuki IHA
-
- context.hにdata segmentの型を定義
- code segmentのaddressはcontextが持つ
- 呼ぶcode segmentはenumで持つ
- code segmentにはdefaultで一つdata segmentを持つ
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/CodeSegmentFlow.graffle
Binary file doc/CodeSegmentFlow.graffle has changed
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/Context.graffle
--- a/doc/Context.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,301 +0,0 @@
-
-
-
-
- ActiveLayerIndex
- 0
- ApplicationVersion
-
- com.omnigroup.OmniGraffle
- 139.18.0.187838
-
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {559, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- CreationDate
- 2015-02-17 15:18:26 +0000
- Creator
- kkb
- DisplayScale
- 1 0/72 in = 1.0000 in
- GraphDocumentVersion
- 8
- GraphicsList
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{75, 106}, {190, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 37
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 Context/Process/HTask}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{75, 120}, {190, 42}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 38
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 in\
-out\
-code segment}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 37
- 38
-
-
- ID
- 36
-
-
- GridInfo
-
- GuidesLocked
- NO
- GuidesVisible
- YES
- HPages
- 1
- ImageCounter
- 3
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-03-15 06:53:19 +0000
- Modifier
- kkb
- NotesVisible
- NO
- Orientation
- 2
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {595, 842}
-
- NSPrintReverseOrientation
-
- int
- 0
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- PrintOnePage
-
- ReadOnly
- NO
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- Canvas 1
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UniqueID
- 1
- UseEntirePage
-
- VPages
- 1
- WindowInfo
-
- CurrentSheet
- 0
- ExpandedCanvases
-
-
- name
- Canvas 1
-
-
- Frame
- {{1619, 633}, {693, 925}}
- ListView
-
- OutlineWidth
- 142
- RightSidebar
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 120
- VisibleRegion
- {{0, 0}, {558, 783}}
- Zoom
- 1
- ZoomValues
-
-
- Canvas 1
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/DataSegment.graffle
--- a/doc/DataSegment.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,506 +0,0 @@
-
-
-
-
- ActiveLayerIndex
- 0
- ApplicationVersion
-
- com.omnigroup.OmniGraffle
- 139.18.0.187838
-
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {559, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- CreationDate
- 2015-03-15 06:30:40 +0000
- Creator
- kkb
- DisplayScale
- 1 0/72 in = 1 0/72 in
- GraphDocumentVersion
- 8
- GraphicsList
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{107, 283}, {190, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 43
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 Meta Data Segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{107, 297}, {190, 42}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 44
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 DataSegment* \
-__code*\
-signature*}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 43
- 44
-
-
- ID
- 42
-
-
- Bounds
- {{21, 245}, {98, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 41
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Meta}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 40
- Points
-
- {21, 211}
- {505, 211}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
-
-
- Bounds
- {{21, 54}, {98, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 39
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Normal}
- VerticalPad
- 0
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{107, 103}, {190, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 37
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 Data Segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{107, 117}, {190, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 38
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 int\
-char}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 37
- 38
-
-
- ID
- 36
-
-
- GridInfo
-
- GuidesLocked
- NO
- GuidesVisible
- YES
- HPages
- 1
- ImageCounter
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-03-15 06:45:10 +0000
- Modifier
- kkb
- NotesVisible
- NO
- Orientation
- 2
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {595, 842}
-
- NSPrintReverseOrientation
-
- int
- 0
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- PrintOnePage
-
- ReadOnly
- NO
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- Canvas 1
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UniqueID
- 1
- UseEntirePage
-
- VPages
- 1
- WindowInfo
-
- CurrentSheet
- 0
- ExpandedCanvases
-
-
- name
- Canvas 1
-
-
- Frame
- {{795, 91}, {693, 925}}
- ListView
-
- OutlineWidth
- 142
- RightSidebar
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 120
- VisibleRegion
- {{0, 0}, {558, 783}}
- Zoom
- 1
- ZoomValues
-
-
- Canvas 1
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/GearBoxExample.graffle
--- a/doc/GearBoxExample.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1916 +0,0 @@
-
-
-
-
- ApplicationVersion
-
- com.omnigroup.OmniGraffle
- 139.18.0.187838
-
- CreationDate
- 2015-05-04 06:18:09 +0000
- Creator
- Tatsuki IHA
- GraphDocumentVersion
- 8
- GuidesLocked
- NO
- GuidesVisible
- YES
- ImageCounter
- 1
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-05-04 06:41:46 +0000
- Modifier
- Tatsuki IHA
- NotesVisible
- NO
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {594.99997329711914, 842}
-
- NSPrintReverseOrientation
-
- int
- 0
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- ReadOnly
- NO
- Sheets
-
-
- ActiveLayerIndex
- 0
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {558.99997329711914, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- DisplayScale
- 1 0/72 in = 1.0000 in
- GraphicsList
-
-
- Class
- LineGraphic
- Head
-
- ID
- 8
-
- ID
- 43
- Points
-
- {223.50215235012584, 162.75020370511052}
- {183.49998664855957, 159}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 40
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 40
-
- ID
- 42
- Points
-
- {375.49995613098145, 159}
- {335.49778661492263, 162.75020391369949}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 37
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{223.99996948242188, 161}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 40
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{223.99996948242188, 175}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 41
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 40
- 41
-
-
- ID
- 39
-
-
- Bounds
- {{414.49996948242188, 286}, {33, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 6
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 end}
- VerticalPad
- 0
-
-
-
- Bounds
- {{108.99998474121094, 36}, {38, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 5
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 start}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 38
- Points
-
- {431.04225592022601, 180}
- {430.49995613098145, 234}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{420.49995613098145, 238.5}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 24
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{415.99995613098145, 234}, {30, 30}}
- Class
- ShapedGraphic
- ID
- 3
- Shape
- Circle
- Style
-
-
-
- ID
- 1
-
-
- Bounds
- {{375.49995613098145, 138}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 37
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 code segment 2}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 36
- Points
-
- {335.48908011958167, 149.89405544557314}
- {375.99998664855957, 158.5}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 35
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{223.9999942779541, 110}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 34
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{223.9999942779541, 124}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 35
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 34
- 35
-
-
- ID
- 33
-
-
- Class
- LineGraphic
- Head
-
- ID
- 35
-
- ID
- 10
- Points
-
- {183.49998664855957, 159}
- {223.51154427454037, 150.24747246490509}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 8
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 8
- Info
- 2
-
- ID
- 9
- Points
-
- {128.54228643780414, 84}
- {127.99998664855957, 138}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{72.49998664855957, 138}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 8
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 code segment 1}
- VerticalPad
- 0
-
-
-
- Bounds
- {{117.49998664855957, 63}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 4
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- GridInfo
-
- HPages
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- Orientation
- 2
- PrintOnePage
-
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- example
- UniqueID
- 1
- VPages
- 1
-
-
- ActiveLayerIndex
- 0
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {558.99997329711914, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- DisplayScale
- 1 0/72 in = 1.0000 in
- GraphicsList
-
-
- Class
- LineGraphic
- Head
-
- ID
- 8
- Info
- 1
-
- ID
- 59
- Points
-
- {127.42646217346191, 221.25010681152344}
- {127.99998664855957, 180}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 57
-
- ID
- 58
- Points
-
- {127.99967208086677, 304.50000009137023}
- {127.97279128802096, 263.75010672015321}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 47
- Info
- 2
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{72.463226318359375, 221.25010681152344}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 56
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{72.463226318359375, 235.25010681152344}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 57
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 56
- 57
-
-
- ID
- 55
-
-
- Class
- LineGraphic
- ID
- 54
- Points
-
- {224, 325.91665649414062}
- {183.99997287473553, 325.49998954491912}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 41
-
- ID
- 53
- Points
-
- {375.5, 326}
- {335.49997287473553, 325.58333305077849}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 46
- Info
- 4
-
-
-
- Class
- LineGraphic
- ID
- 52
- Points
-
- {430.5, 263.5}
- {430.5, 304.5}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 49
-
- ID
- 51
- Points
-
- {431, 180}
- {431, 221}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 37
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{375.5, 221.5}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 49
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{375.5, 235.5}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 50
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 49
- 50
-
-
- ID
- 48
-
-
- Bounds
- {{72.500001907348633, 305}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 47
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : code segment 2}
- VerticalPad
- 0
-
-
-
- Bounds
- {{375.5, 305}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 46
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 code segment 2}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 37
-
- ID
- 45
- Points
-
- {335.49985336964573, 158.5}
- {375.5, 159}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 35
-
- ID
- 44
- Points
-
- {183.49998664855957, 159}
- {223.50010276133571, 159.83333568612193}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 8
- Info
- 3
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{224, 297}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 40
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{224, 311}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 41
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 40
- 41
-
-
- ID
- 39
-
-
- Bounds
- {{111.5, 443}, {33, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 6
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 end}
- VerticalPad
- 0
-
-
-
- Bounds
- {{108.99998474121094, 37}, {38, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 5
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 start}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 38
- Points
-
- {128.04228643780414, 347}
- {127.49998664855957, 401}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{117.49998664855957, 405.5}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 24
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{112.99998664855957, 401}, {30, 30}}
- Class
- ShapedGraphic
- ID
- 3
- Shape
- Circle
- Style
-
-
-
- ID
- 1
-
-
- Bounds
- {{375.5, 138}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 37
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : code segment 1}
- VerticalPad
- 0
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{223.9999942779541, 133}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 34
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{223.9999942779541, 147}, {111, 28}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 35
- Shape
- Rectangle
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 34
- 35
-
-
- ID
- 33
-
-
- Class
- LineGraphic
- Head
-
- ID
- 8
- Info
- 2
-
- ID
- 9
- Points
-
- {128.54228643780414, 84}
- {127.99998664855957, 138}
-
- Style
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{72.49998664855957, 138}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 8
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Shape
- Rectangle
- Style
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 code segment 1}
- VerticalPad
- 0
-
-
-
- Bounds
- {{118.99998664855957, 63}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 4
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- GridInfo
-
- HPages
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- Orientation
- 2
- PrintOnePage
-
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- meta example
- UniqueID
- 2
- VPages
- 1
-
-
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UseEntirePage
-
- WindowInfo
-
- CurrentSheet
- 1
- ExpandedCanvases
-
-
- name
- example
-
-
- Frame
- {{2507, 112}, {693, 925}}
- ListView
-
- OutlineWidth
- 142
- RightSidebar
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 120
- VisibleRegion
- {{0, 0}, {558, 783}}
- Zoom
- 1
- ZoomValues
-
-
- example
- 1
- 1
-
-
- meta example
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/GearsOS.mm
--- a/doc/GearsOS.mm Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/GearsOS_arch.graffle
--- a/doc/GearsOS_arch.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1866 +0,0 @@
-
-
-
-
- ActiveLayerIndex
- 0
- ApplicationVersion
-
- com.omnigroup.OmniGraffle
- 139.18.0.187838
-
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {1118, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- CreationDate
- 2015-05-06 12:15:09 +0000
- Creator
- kkb
- DisplayScale
- 1 0/72 in = 1.0000 in
- GraphDocumentVersion
- 8
- GraphicsList
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{487, 387}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 148
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 pointer}
- VerticalPad
- 0
-
-
-
- Bounds
- {{517, 278.04542541503918}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 149
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 goto}
- VerticalPad
- 0
-
-
-
- Bounds
- {{625, 445.117431640625}, {115, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 150
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Temporal Data Gear}
- VerticalPad
- 0
-
-
-
- Bounds
- {{625, 428.117431640625}, {115, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 151
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Temporal Data Gear}
- VerticalPad
- 0
-
-
-
- Bounds
- {{625, 410}, {115, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 152
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Temporal Data Gear}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 159
-
- ID
- 153
- Points
-
- {478.21863675031523, 362.20520265171882}
- {594.78136057069594, 405.55697719473693}
-
- Style
-
- stroke
-
- HeadArrow
- FilledArrow
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 160
-
-
-
- Class
- LineGraphic
- ID
- 154
- Points
-
- {618.37499999999989, 409.61743185433227}
- {618.37499999999989, 426.61743222053235}
-
- Style
-
- stroke
-
- HeadArrow
- NegativeControls
- Legacy
-
- TailArrow
- NegativeControls
-
-
-
-
- Class
- LineGraphic
- ID
- 155
- Points
-
- {618.37499999999989, 443.61743148813241}
- {618.37499999999989, 460.61743185433232}
-
- Style
-
- stroke
-
- HeadArrow
- NegativeControls
- Legacy
-
- TailArrow
- NegativeControls
-
-
-
-
- Class
- LineGraphic
- ID
- 156
- Points
-
- {618.37499999999989, 426.6174318122105}
- {618.37499999999989, 443.61743217841041}
-
- Style
-
- stroke
-
- HeadArrow
- NegativeControls
- Legacy
-
- TailArrow
- NegativeControls
-
-
-
-
- Class
- LineGraphic
- ID
- 157
- Points
-
- {604, 409.007568359375}
- {604, 460.007568359375}
-
- Style
-
- stroke
-
- HeadArrow
- NegativeControls
- Legacy
-
- TailArrow
- FilledArrow
-
-
-
-
- Bounds
- {{584.625, 477.617431640625}, {176, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 158
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 memory}
- VerticalPad
- 0
-
-
-
- Bounds
- {{595.25000000000023, 401.007568359375}, {154.75, 67}}
- Class
- ShapedGraphic
- ID
- 159
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{424.24999901761652, 337.07452548890376}, {53.5, 30.015151977539062}}
- Class
- ShapedGraphic
- ID
- 160
- Line
-
- ID
- 162
- Position
- 0.8249744176864624
- RotationType
- 0
-
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 context}
-
-
-
- Bounds
- {{431.99999999999977, 436.00000000000006}, {176, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 161
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Worker}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 166
-
- ID
- 162
- Points
-
- {487.6373629440061, 243.93544826469429}
- {448.1091003417971, 233}
- {414.1091003417971, 289}
- {443.60910034179653, 350}
- {489.18166043264989, 336.52187917772261}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- LineType
- 1
- TailArrow
- FilledArrow
-
-
- Tail
-
- ID
- 165
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 166
-
- ID
- 163
- Points
-
- {533.10911435610967, 274.51516072232459}
- {533.10911435610967, 305.53029521029288}
-
- Style
-
- stroke
-
- HeadArrow
- FilledArrow
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 165
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 165
-
- ID
- 164
- Points
-
- {533.10910873370131, 207}
- {533.10910873370131, 238.51514324504049}
-
- Style
-
- stroke
-
- HeadArrow
- FilledArrow
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 167
-
-
-
- Bounds
- {{469.1091003417971, 239.01515197753895}, {128, 35}}
- Class
- ShapedGraphic
- ID
- 165
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Code Gear}
-
-
-
- Bounds
- {{469.1091003417971, 306.03030395507801}, {128, 35}}
- Class
- ShapedGraphic
- ID
- 166
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Meta Code Gear}
-
-
-
- Bounds
- {{500.10910034179688, 193}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 167
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Data Gear}
- VerticalPad
- 0
-
-
-
- Bounds
- {{11.999999999999659, 410}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 168
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 copy}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 169
- Points
-
- {42.5, 387}
- {49.5, 407}
- {71.5, 410}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- LineType
- 1
- TailArrow
- FilledArrow
-
-
-
-
- Bounds
- {{325.99999999999977, 319}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 170
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 store}
- VerticalPad
- 0
-
-
-
- Bounds
- {{325.99999999999977, 201.49999237060553}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 171
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 read}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 172
- Points
-
- {324.99999999999983, 342}
- {392.99999999999972, 342}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- FilledArrow
-
-
-
-
- Class
- LineGraphic
- ID
- 173
- Points
-
- {324.99999999999983, 222.99996692238005}
- {392.99999999999972, 222.99996692238005}
-
- Style
-
- stroke
-
- HeadArrow
- FilledArrow
- Legacy
-
- TailArrow
- 0
-
-
-
-
- Bounds
- {{393.49999999999966, 139}, {253.00000000000014, 282.99999999999989}}
- Class
- ShapedGraphic
- ID
- 174
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{436.49999999999943, 104}, {253.00000000000014, 282.99999999999989}}
- Class
- ShapedGraphic
- ID
- 175
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{480.49999999999989, 67}, {253.00000000000014, 282.99999999999989}}
- Class
- ShapedGraphic
- ID
- 176
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{140.04924011230443, 219.98726987838751}, {90.3162841796875, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- FontInfo
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
-
- ID
- 178
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;\red255\green0\blue0;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf2 Meta Data Gear}
- VerticalPad
- 0
-
-
-
- Bounds
- {{184.84185791015599, 165.74242401123053}, {66, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 179
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Data Gear}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 181
-
- ID
- 180
- Points
-
- {260.63904413799833, 263.95532240098333}
- {280.67900017936921, 297.04476486031871}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 192
-
-
-
- Bounds
- {{275.01515151515122, 295.55045454545473}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 181
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 183
-
- ID
- 182
- Points
-
- {246.60852778601273, 263.75146804005476}
- {225.01280748159624, 297.24861517565887}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 192
-
-
-
- Bounds
- {{205.31818181818156, 295.55045454545473}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 183
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 189
-
- ID
- 184
- Points
-
- {169.80478370166296, 263.34126189283182}
- {144.99834329838677, 297.65881143385616}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 193
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 187
-
- ID
- 185
- Points
-
- {144.84289549965422, 319.19965217661098}
- {165.60387963053429, 348.8259453571161}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 189
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 188
-
- ID
- 186
- Points
-
- {129.09588004179938, 318.7553353748965}
- {105.12017528879785, 349.27023962899653}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 189
-
-
-
- Bounds
- {{160.66856060605991, 346.83348484848455}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 187
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{84.437499999999631, 346.83348484848455}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 188
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{124.73106060606054, 295.55045454545473}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 189
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 192
-
- ID
- 190
- Points
-
- {225.43001671177532, 212.1741976311564}
- {246.19100084265605, 241.80049081166203}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 194
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 193
-
- ID
- 191
- Points
-
- {209.68300125392042, 211.72988082944192}
- {185.70729650091866, 242.24478508354238}
-
- Style
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- HeadArrow
- 0
- Legacy
-
- TailArrow
- 0
-
-
- Tail
-
- ID
- 194
-
-
-
- Bounds
- {{241.25568181818173, 239.80803030303042}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 192
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{165.02462121212042, 239.80803030303042}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 193
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{205.31818181818156, 188.52500000000018}, {25.047348484848513, 25.64151515151514}}
- Class
- ShapedGraphic
- ID
- 194
- Shape
- Circle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{71.499999999999687, 139.00000000000011}, {253.00000000000014, 282.99999999999989}}
- Class
- ShapedGraphic
- ID
- 195
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- ID
- 177
-
-
- Bounds
- {{32.999999999999716, 104}, {253.00000000000014, 282.99999999999989}}
- Class
- ShapedGraphic
- ID
- 196
- Shape
- Rectangle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{109.99999999999979, 436.00000000000006}, {176, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 197
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 Persistent Data Gear}
- VerticalPad
- 0
-
-
-
- ID
- 147
-
-
- GridInfo
-
- GuidesLocked
- NO
- GuidesVisible
- YES
- HPages
- 2
- ImageCounter
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-05-06 13:15:37 +0000
- Modifier
- kkb
- NotesVisible
- NO
- Orientation
- 2
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {595, 842}
-
- NSPrintReverseOrientation
-
- int
- 0
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- PrintOnePage
-
- ReadOnly
- NO
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- Canvas 1
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UniqueID
- 1
- UseEntirePage
-
- VPages
- 1
- WindowInfo
-
- CurrentSheet
- 0
- ExpandedCanvases
-
-
- name
- Canvas 1
-
-
- Frame
- {{433, 832}, {1003, 925}}
- ListView
-
- OutlineWidth
- 142
- RightSidebar
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 120
- VisibleRegion
- {{0, 0}, {868, 783}}
- Zoom
- 1
- ZoomValues
-
-
- Canvas 1
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/GearsProgramming.mm
--- a/doc/GearsProgramming.mm Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/Interface.mm
--- a/doc/Interface.mm Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-Interfaceのtypedef はコールフレームを定義する
-Interfaceの呼び出しの時に使える引数はtypedefに定義されている必要がある
-... は呼び出し側のコールフレームを保存するのに使う
-
-
-typedef struct Stack{
- Type* stack;
- Type* data;
- Type* data1;
- __code whenEmpty(...);
- __code clear(Impl* stack,__code next(...));
- __code push(Impl* stack,Type* data, __code next(...));
- __code pop(Impl* stack, __code next(Type* data, ...));
- __code pop2(Impl* stack, __code next(Type* data, Type* data1, ...));
- __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
- __code get(Impl* stack, __code next(Type* data, ...));
- __code get2(Impl* stack, __code next(Type* data, Type* data1, ...));
- __code next(...);
-} Stack;
-
-呼び出し方の例
- goto nodeStack->push(newNode, replaceNode1);
-newNode はdataに対応する replaceNode1はnextに対応する。
-replaceNode1のコールフレームは...に格納される。
-つまり、replaceNode1はCodeGearのクロージャに相当する。
-
-Interfaceから値を返す場合は継続経由で値を返す
-__code get2(Impl* stack, __code next(Type* data, Type* data1, ...));
-継続の型はInterfaceで定義されていて、この型に合うCodeGearを引数として渡す
- goto nodeStack->get2(insertCase1,tree) //意味的にはtreeの後ろに...
-
-
-__code insertCase1(struct Node *parent, struct Node *grandparent, struct RedBlackTree* tree) { //こっちも後ろに...があるはず
-
-goto next(data, data1, ...);
-
-createはinterfaceの実装を定義する
-interfaceのメソッドの番号をここで指定する
-
-implimentation側のDataGearは格納される実装依存の状態を持つ
-
-
- struct SingleLinkedStack {
- struct Element* top;
- } SingleLinkedStack;
-
-Stack* createSingleLinkedStack(struct Context* context) {
- struct Stack* stack = new Stack();
- struct SingleLinkedStack* singleLinkedStack = new SingleLinkedStack();
- stack->stack = (union Data*)singleLinkedStack;
- singleLinkedStack->top = NULL;
- stack->push = C_pushSingleLinkedStack;
- stack->pop = C_popSingleLinkedStack;
- stack->pop2 = C_pop2SingleLinkedStack;
- stack->get = C_getSingleLinkedStack;
- stack->get2 = C_get2SingleLinkedStack;
- stack->isEmpty = C_isEmptySingleLinkedStack;
- stack->clear = C_clearSingleLinkedStack;
- return stack;
-}
-
-
-実装内部で使うCodeGearの引数はコールフレームで決まる
-コールフレームに含まれない中間変数を使っても良いが、辻褄は合ってる必要はある
-一般的にはコールフレームに含まれている引数しか書けない
-実装側の引数を書いても良い(ようにするか?)
-
-実装の状態にアクセスする時にはコールフレーム内の実装を表すDataGearから取り出してくる
-
-
-__code replaceNode1(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
-
-呼び出しの例
- goto insertNode(tree, tree->nodeStack, node);
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/List.graffle
Binary file doc/List.graffle has changed
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/allocate.graffle
--- a/doc/allocate.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1543 +0,0 @@
-
-
-
-
- ActiveLayerIndex
- 0
- ApplicationVersion
-
- com.omnigroup.OmniGraffle
- 139.18.0.187838
-
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {559, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- CreationDate
- 2015-04-07 04:20:51 +0000
- Creator
- kkb
- DisplayScale
- 1 0/72 in = 1 0/72 in
- GraphDocumentVersion
- 8
- GraphicsList
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 85
- Points
-
- {198, 261}
- {297, 297}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 84
- Points
-
- {198, 216}
- {297, 252}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{288, 234}, {36, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 83
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 mds 2}
- VerticalPad
- 0
-
-
-
- Bounds
- {{297, 252}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 82
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 81
- Points
-
- {198, 216}
- {297, 225}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 80
- Points
-
- {198, 198}
- {297, 207}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{288, 186.5}, {36, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 79
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 mds 1}
- VerticalPad
- 0
-
-
-
- Bounds
- {{297, 207}, {18, 18}}
- Class
- ShapedGraphic
- ID
- 78
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 77
- Points
-
- {198, 180}
- {297, 180}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 76
- Points
-
- {198, 135}
- {297, 135}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{288, 117}, {36, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 74
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 ds 2}
- VerticalPad
- 0
-
-
-
- Bounds
- {{288, 67}, {36, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 73
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 ds 1}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 72
- Points
-
- {198, 135}
- {297, 108}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 71
- Points
-
- {198, 117}
- {297, 90}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{297, 135}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 70
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{297, 90}, {18, 18}}
- Class
- ShapedGraphic
- ID
- 69
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{0, 468}, {63, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 68
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 mds_heap}
- VerticalPad
- 0
-
-
-
- Bounds
- {{9, 387}, {54, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 67
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 ds_heap}
- VerticalPad
- 0
-
-
-
- Bounds
- {{9, 324}, {54, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 66
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 context}
- VerticalPad
- 0
-
-
-
- Bounds
- {{0, 258.5}, {63, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 65
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 mds_heap}
- VerticalPad
- 0
-
-
-
- Bounds
- {{9, 177.5}, {54, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 64
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 ds_heap}
- VerticalPad
- 0
-
-
-
- Bounds
- {{9, 117}, {54, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 63
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 context}
- VerticalPad
- 0
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 62
- Points
-
- {81, 513}
- {180, 531}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 61
- Points
-
- {81, 306}
- {180, 324}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- ID
- 60
- Points
-
- {81, 306}
- {180, 279}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- AllowConnections
- NO
- AllowLabelDrop
-
- AllowToConnect
-
- Class
- LineGraphic
- ID
- 59
- Points
-
- {81, 99}
- {180, 72}
-
- Style
-
- stroke
-
- HeadArrow
- 0
- Legacy
-
- Pattern
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{180, 450}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 51
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{180, 369}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 50
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{180, 324}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 49
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{180, 198}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 48
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{180, 117}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 47
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{180, 72}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 46
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 432}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 45
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 351}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 44
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 306}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 43
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 225}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 41
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 144}, {18, 81}}
- Class
- ShapedGraphic
- ID
- 40
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{63, 99}, {18, 45}}
- Class
- ShapedGraphic
- ID
- 39
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{144, 299}, {90, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 18
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 worker 2}
- VerticalPad
- 0
-
-
-
- Bounds
- {{144, 49}, {90, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 17
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 worker 1}
- VerticalPad
- 0
-
-
-
- Bounds
- {{27, 76}, {90, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 4
- Shape
- Rectangle
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Pad
- 0
- Text
- {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
-\cocoascreenfonts1{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc
-
-\f0\fs24 \cf0 main}
- VerticalPad
- 0
-
-
-
- GridInfo
-
- ShowsGrid
- YES
- SnapsToGrid
- YES
-
- GuidesLocked
- NO
- GuidesVisible
- YES
- HPages
- 1
- ImageCounter
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- dotRankSep
- 0.0
- layoutEngine
- dot
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-04-07 05:07:49 +0000
- Modifier
- kkb
- NotesVisible
- NO
- Orientation
- 2
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {595, 842}
-
- NSPrintReverseOrientation
-
- int
- 0
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- PrintOnePage
-
- ReadOnly
- NO
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- Canvas 1
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UniqueID
- 1
- UseEntirePage
-
- VPages
- 1
- WindowInfo
-
- CurrentSheet
- 0
- ExpandedCanvases
-
-
- name
- Canvas 1
-
-
- Frame
- {{616, 555}, {693, 925}}
- ListView
-
- OutlineWidth
- 142
- RightSidebar
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 120
- VisibleRegion
- {{0, 0}, {558, 783}}
- Zoom
- 1
- ZoomValues
-
-
- Canvas 1
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/dependency.graffle
Binary file doc/dependency.graffle has changed
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/gears_structure.graffle
Binary file doc/gears_structure.graffle has changed
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/scheduler.graffle
Binary file doc/scheduler.graffle has changed
diff -r f63a9a081b61 -r 8fbc3ef749b6 doc/synchronizedQueue.graffle
--- a/doc/synchronizedQueue.graffle Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2536 +0,0 @@
-
-
-
-
- ActiveLayerIndex
- 0
- ApplicationVersion
-
- com.omnigroup.OmniGraffle6
- 159.11.0.228015
-
- AutoAdjust
-
- BackgroundGraphic
-
- Bounds
- {{0, 0}, {1118, 783}}
- Class
- SolidGraphic
- ID
- 2
- Style
-
- stroke
-
- Draws
- NO
-
-
-
- BaseZoom
- 0
- CanvasOrigin
- {0, 0}
- ColumnAlign
- 1
- ColumnSpacing
- 36
- CreationDate
- 2015-05-04 06:37:26 +0000
- Creator
- Tatsuki IHA
- DisplayScale
- 1 in = 1.00000 in
- GraphDocumentVersion
- 12
- GraphicsList
-
-
- Class
- LineGraphic
- Head
-
- ID
- 103
- Info
- 2
-
- ID
- 104
- Points
-
- {654.31997136771679, 372.25999866425991}
- {653.81998662650585, 410.63499866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 93
- Info
- 1
-
-
-
- Bounds
- {{598.31998662650585, 410.63499866425991}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 103
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;\red255\green0\blue0;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf2 over flow}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 101
- Info
- 2
-
- ID
- 102
- Points
-
- {128.49996948242188, 366.5}
- {128.49997711181641, 404.875}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 61
-
-
-
- Bounds
- {{72.999977111816406, 404.875}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 101
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Color
-
- b
- 0
- g
- 0
- r
- 1
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;\red255\green0\blue0;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf2 empty}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 99
- Points
-
- {653.31998662650585, 246.00999866425991}
- {653.31998662650585, 204.25999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 97
-
- ID
- 98
- Points
-
- {654.31997136771679, 330.25999866425991}
- {654.31997136771679, 290.50999866425985}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 93
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{598.81997899711132, 246.00999866425991}, {110.99999237060547, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 96
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{598.81997899711132, 260.00999866425991}, {110.99999237060547, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 97
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 96
- 97
-
-
- ID
- 95
-
-
- Class
- LineGraphic
- ID
- 94
- Points
-
- {749.81997136771679, 354.67665515840054}
- {709.81996524681813, 354.25998833691187}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{598.81997136771679, 330.25999866425991}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 93
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : put}
- VerticalPad
- 0
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{749.81997899711132, 325.75999866425991}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 91
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{749.81997899711132, 339.75999866425991}, {111, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 92
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 91
- 92
-
-
- ID
- 90
-
-
- Class
- LineGraphic
- Head
-
- ID
- 92
-
- ID
- 89
- Points
-
- {901.31995801627636, 354.75999866425991}
- {861.31997899711132, 354.75999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 87
-
-
-
- Class
- LineGraphic
- ID
- 88
- Points
-
- {956.31995801627636, 290.25999866425991}
- {956.31995801627636, 333.75999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{901.31995801627636, 333.75999866425991}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 87
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 put}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 84
-
- ID
- 86
- Points
-
- {956.81995801627636, 203.75999866425991}
- {956.81995801627636, 247.25999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 76
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{901.31997518241405, 247.75999866425991}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 84
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{901.31997518241405, 261.75999866425991}, {111, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 85
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 84
- 85
-
-
- ID
- 83
-
-
- Bounds
- {{1046.8200018852949, 219.75999866425991}, {33, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 82
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 end}
- VerticalPad
- 0
-
-
-
- Bounds
- {{634.81998662650585, 59.759998664259911}, {38, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 81
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 start}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 80
- Points
-
- {1012.3199580162764, 182.75999866425991}
- {1049.8200018852949, 181.75999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 76
- Info
- 3
-
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{1052.8199885338545, 172.25999866425991}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 78
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{1048.3199885338545, 167.75999866425991}, {30, 30}}
- Class
- ShapedGraphic
- ID
- 79
- Shape
- Circle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- ID
- 77
-
-
- Bounds
- {{901.31995801627636, 161.75999866425991}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 76
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : sender}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 75
- Points
-
- {861.31991478906843, 182.88953340220792}
- {901.81998853385448, 182.25999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 74
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{749.81997518241405, 141.75999866425991}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 73
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{749.81997518241405, 155.75999866425991}, {111, 56}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 74
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 first\
-last\
-count\
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 73
- 74
-
-
- ID
- 72
-
-
- Class
- LineGraphic
- Head
-
- ID
- 74
-
- ID
- 71
- Points
-
- {709.31998853385448, 182.75999866425991}
- {749.3200023069503, 183.17666553234531}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 69
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 69
- Info
- 2
-
- ID
- 70
- Points
-
- {654.36228832309905, 107.75999866425991}
- {653.81998853385448, 161.75999866425991}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{598.31998853385448, 161.75999866425991}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 69
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 sender}
- VerticalPad
- 0
-
-
-
- Bounds
- {{643.31998853385448, 86.759998664259911}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 68
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- Class
- LineGraphic
- ID
- 67
- Points
-
- {127.49998474121094, 240.25}
- {127.49998474121094, 198.5}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 65
-
- ID
- 66
- Points
-
- {128.49996948242188, 324.5}
- {128.49996948242188, 284.75}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 61
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{72.999977111816406, 240.25}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 64
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{72.999977111816406, 254.25}, {111, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 65
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 64
- 65
-
-
- ID
- 63
-
-
- Class
- LineGraphic
- ID
- 62
- Points
-
- {223.99996948242188, 348.91665649414062}
- {183.99996336152327, 348.49998967265191}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{72.999969482421875, 324.5}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 61
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : get}
- VerticalPad
- 0
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{223.99997711181641, 320}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 57
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 2}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{223.99997711181641, 334}, {111, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 59
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 57
- 59
-
-
- ID
- 56
-
-
- Class
- LineGraphic
- Head
-
- ID
- 59
-
- ID
- 60
- Points
-
- {375.49995613098145, 349}
- {335.49997711181641, 349}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 53
-
-
-
- Class
- LineGraphic
- ID
- 54
- Points
-
- {430.49995613098145, 284.5}
- {430.49995613098145, 328}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{375.49995613098145, 328}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 53
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 get}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 50
-
- ID
- 52
- Points
-
- {430.99995613098145, 198}
- {430.99995613098145, 241.5}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 37
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{375.49997329711914, 242}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 50
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{375.49997329711914, 256}, {111, 30}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 51
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 \
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 50
- 51
-
-
- ID
- 49
-
-
- Bounds
- {{521, 214}, {33, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 6
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 end}
- VerticalPad
- 0
-
-
-
- Bounds
- {{108.99998474121094, 54}, {38, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 5
- Style
-
- fill
-
- Draws
- NO
-
- shadow
-
- Draws
- NO
-
- stroke
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 start}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 38
- Points
-
- {486.49995613098145, 177}
- {524, 176}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 37
- Info
- 3
-
-
-
- Class
- Group
- Graphics
-
-
- Bounds
- {{526.99998664855957, 166.5}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 24
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- Bounds
- {{522.49998664855957, 162}, {30, 30}}
- Class
- ShapedGraphic
- ID
- 3
- Shape
- Circle
- Style
-
- shadow
-
- Draws
- NO
-
-
-
-
- ID
- 1
-
-
- Bounds
- {{375.49995613098145, 156}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 37
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 M : receiver}
- VerticalPad
- 0
-
-
-
- Class
- LineGraphic
- ID
- 36
- Points
-
- {335.49991290377352, 177.12953473794801}
- {375.99998664855957, 176.5}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 35
-
-
-
- Class
- TableGroup
- Graphics
-
-
- Bounds
- {{223.99997329711914, 136}, {111, 14}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 34
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 data segment 1}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- Bounds
- {{223.99997329711914, 150}, {111, 56}}
- Class
- ShapedGraphic
- FitText
- Vertical
- Flow
- Resize
- ID
- 35
- Style
-
- fill
-
- GradientCenter
- {-0.29411799999999999, -0.264706}
-
- shadow
-
- Draws
- NO
-
-
- Text
-
- Align
- 0
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720
-
-\f0\fs24 \cf0 first\
-last\
-count\
-}
- VerticalPad
- 0
-
- TextPlacement
- 0
-
-
- GridH
-
- 34
- 35
-
-
- ID
- 33
-
-
- Class
- LineGraphic
- Head
-
- ID
- 35
-
- ID
- 10
- Points
-
- {183.49998664855957, 177}
- {223.50000042165541, 177.4166668680854}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
- Tail
-
- ID
- 8
-
-
-
- Class
- LineGraphic
- Head
-
- ID
- 8
- Info
- 2
-
- ID
- 9
- Points
-
- {128.54228643780414, 102}
- {127.99998664855957, 156}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- HeadArrow
- StickArrow
- Legacy
-
- LineType
- 1
- TailArrow
- 0
-
-
-
-
- Bounds
- {{72.49998664855957, 156}, {111, 42}}
- Class
- ShapedGraphic
- ID
- 8
- Magnets
-
- {0, 1}
- {0, -1}
- {1, 0}
- {-1, 0}
-
- Style
-
- shadow
-
- Draws
- NO
-
- stroke
-
- CornerRadius
- 5
-
-
- Text
-
- Text
- {\rtf1\ansi\ansicpg65001\cocoartf1344\cocoasubrtf720
-{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
-{\colortbl;\red255\green255\blue255;}
-\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc
-
-\f0\b\fs24 \cf0 receiver}
- VerticalPad
- 0
-
-
-
- Bounds
- {{117.49998664855957, 81}, {21, 21}}
- Class
- ShapedGraphic
- ID
- 4
- Shape
- Circle
- Style
-
- fill
-
- Color
-
- b
- 0
- g
- 0
- r
- 0
-
-
- shadow
-
- Draws
- NO
-
-
-
-
- GridInfo
-
- GuidesLocked
- NO
- GuidesVisible
- YES
- HPages
- 2
- ImageCounter
- 1
- KeepToScale
-
- Layers
-
-
- Lock
- NO
- Name
- Layer 1
- Print
- YES
- View
- YES
-
-
- LayoutInfo
-
- Animate
- NO
- circoMinDist
- 18
- circoSeparation
- 0.0
- layoutEngine
- dot
- neatoLineLength
- 0.20000000298023224
- neatoSeparation
- 0.0
- twopiSeparation
- 0.0
-
- LinksVisible
- NO
- MagnetsVisible
- NO
- MasterSheets
-
- ModificationDate
- 2015-05-24 17:35:18 +0000
- Modifier
- one
- NotesVisible
- NO
- Orientation
- 2
- OriginVisible
- NO
- PageBreaks
- YES
- PrintInfo
-
- NSBottomMargin
-
- float
- 41
-
- NSHorizonalPagination
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSLeftMargin
-
- float
- 18
-
- NSPaperSize
-
- size
- {595, 842}
-
- NSPrintReverseOrientation
-
- coded
- BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG
-
- NSRightMargin
-
- float
- 18
-
- NSTopMargin
-
- float
- 18
-
-
- PrintOnePage
-
- ReadOnly
- NO
- RowAlign
- 1
- RowSpacing
- 36
- SheetTitle
- sender receiver
- SmartAlignmentGuidesActive
- YES
- SmartDistanceGuidesActive
- YES
- UniqueID
- 1
- UseEntirePage
-
- VPages
- 1
- WindowInfo
-
- CurrentSheet
- 0
- Expanded_Canvases
-
- Frame
- {{597, 594}, {1325, 925}}
- ShowInfo
-
- ShowRuler
-
- Sidebar
-
- SidebarWidth
- 200
- TopSlabHeight
- 250
- VisibleRegion
- {{248, 15}, {811, 768}}
- Zoom
- 1
- ZoomValues
-
-
- sender receiver
- 1
- 1
-
-
-
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/CMakeLists.txt
--- a/src/CMakeLists.txt Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-cmake_minimum_required(VERSION 3.3)
-
-# output compile log
-set(CMAKE_VERBOSE_MAKEFILE 1)
-
-# set compiler
-set(CMAKE_C_COMPILER $ENV{CBC_COMPILER})
-
-# compile option
-add_definitions("-Wall -g -O0")
-
-include_directories(include)
-include_directories($ENV{CUDA_PATH})
-add_subdirectory(allocate)
-add_subdirectory(list)
-add_subdirectory(llrb)
-add_subdirectory(synchronizedQueue)
-add_subdirectory(parallel_execution)
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/include/allocate.h
--- a/src/include/allocate.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-__code allocate();
-__code meta_allocate();
-
-__code allocate(struct Context* context) {
- goto meta_allocate(context);
-}
-
-__code meta_allocate(struct Context* context) {
- context->data[++context->dataNum] = context->heap;
- context->heap += context->data[0]->allocate.size;
-
- goto meta(context, context->next[--context->current]);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/include/context.h
--- a/src/include/context.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-typedef struct Context_st {
- void* ds;
- void* mds;
- void* ds_heap;
- void* mds_heap;
- __code (*next)();
- void* head;
-} Context;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/include/origin_cs.h
--- a/src/include/origin_cs.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-extern __code start_code(struct Context* context, enum Code next);
-extern __code exit_code(struct Context* context);
-extern __code meta(struct Context* context, enum Code next);
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/CMakeLists.txt
--- a/src/llrb/CMakeLists.txt Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-add_definitions("-Wall -g -O0")
-
-set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang)
-
-include_directories(include)
-add_executable(llrb
- main.c
- llrb.c
- llrbContext.c
- allocate.c
- compare.c
- stack.c
- origin_cs.c
-)
-
-
-add_executable(llrb_with_put_verify
- main.c
- llrb.c
- llrbContext.c
- allocate.c
- compare.c
- stack.c
- verifier/llrbContextWithVerifier.c
- verifier/verify_put_cs.c
-)
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/allocate.c
--- a/src/llrb/allocate.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#include "llrbContext.h"
-
-void allocator(struct Context* context) {
- context->data[++context->dataNum] = context->heap;
- context->heap += context->data[Allocate]->allocate.size;
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/compare.c
--- a/src/llrb/compare.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-#include "llrbContext.h"
-
-void compare(struct Context* context, struct Tree* tree, int key1, int key2) {
- if (key1 == key2) {
- tree->result = EQ;
- } else if (key1 < key2) {
- tree->result = GT;
- } else {
- tree->result = LT;
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/include/llrbContext.h
--- a/src/llrb/include/llrbContext.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/* Context definition for llrb example */
-#include "stack.h"
-
-#define ALLOCATE_SIZE 1000
-
-enum Code {
- Code1,
- Code2,
- Code3,
- Code4,
- Code5,
- Find,
- Not_find,
- Code6,
- Allocator,
- Put,
- Replace,
- Insert,
- Compare,
- RotateL,
- RotateR,
- SetTree,
- InsertCase1,
- InsertCase2,
- InsertCase3,
- InsertCase4,
- InsertCase4_1,
- InsertCase4_2,
- InsertCase5,
- StackClear,
- Get,
- Search,
- Delete,
- Delete1,
- Delete2,
- Delete3,
- Replace_d1,
- Replace_d2,
- FindMax1,
- FindMax2,
- DeleteCase1,
- DeleteCase2,
- DeleteCase3,
- DeleteCase4,
- DeleteCase5,
- DeleteCase6,
- Exit,
-};
-
-enum Relational {
- EQ,
- GT,
- LT,
-};
-
-enum UniqueData {
- Allocate,
- Tree,
- Node,
-};
-
-struct Context {
- enum Code next;
- int codeNum;
- __code (**code) (struct Context*);
- void* heapStart;
- void* heap;
- long heapLimit;
- int dataNum;
- stack_ptr code_stack;
- stack_ptr node_stack;
- union Data **data;
-};
-
-union Data {
- struct Comparable { // inteface
- enum Code compare;
- union Data* data;
- } compare;
- struct Count {
- enum Code next;
- long i;
- } count;
- struct Tree {
- enum Code next;
- struct Node* root;
- struct Node* current;
- struct Node* deleted;
- int result;
- } tree;
- struct Node {
- // need to tree
- enum Code next;
- int key; // comparable data segment
- int value;
- struct Node* left;
- struct Node* right;
- // need to balancing
- enum Color {
- Red,
- Black,
- } color;
- } node;
- struct Allocate {
- enum Code next;
- long size;
- } allocate;
-};
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/include/stack.h
--- a/src/llrb/include/stack.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#include
-
-typedef struct {
- size_t size;
- int max;
- int num;
- void* data;
-} stack, *stack_ptr;
-
-extern stack_ptr stack_init();
-extern stack_ptr stack_realloc();
-extern void stack_free();
-extern int stack_push();
-extern int stack_pop();
-extern int isMax();
-extern int isEmpty();
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/llrb.c
--- a/src/llrb/llrb.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,669 +0,0 @@
-#include
-
-#include "llrbContext.h"
-#include "origin_cs.h"
-
-extern void allocator(struct Context* context);
-extern void compare(struct Context* context, struct Tree* tree, int key1, int key2);
-
-extern int num;
-
-__code put(struct Context* context, struct Tree* tree, struct Node* root, struct Allocate* allocate) {
- allocate->size = sizeof(struct Node);
- allocator(context);
-
- stack_push(context->code_stack, &context->next);
-
- context->next = StackClear;
- stack_push(context->code_stack, &context->next);
-
- tree->root = &context->data[context->dataNum]->node;
-
- if (root) {
- tree->current = root;
- compare(context, tree, tree->current->key, context->data[Node]->node.key);
-
- goto meta(context, Replace);
- }
-
- goto meta(context, Insert);
-}
-
-__code put_stub(struct Context* context) {
- goto put(context, &context->data[Tree]->tree, context->data[Tree]->tree.root, &context->data[Allocate]->allocate);
-}
-
-__code replaceNode(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode, int result) {
- *newNode = *oldNode;
- stack_push(context->node_stack, &newNode);
-
- if (result == EQ) {
- newNode->value = context->data[Node]->node.value;
-
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
- } else if (result == GT) {
- tree->current = oldNode->right;
- newNode->right = context->heap;
- } else {
- tree->current = oldNode->left;
- newNode->left = context->heap;
- }
-
- context->data[Allocate]->allocate.size = sizeof(struct Node);
- allocator(context);
-
- if (tree->current) {
- compare(context, tree, tree->current->key, context->data[Node]->node.key);
- goto meta(context, Replace);
- }
-
- goto meta(context, Insert);
-}
-
-__code replaceNode_stub(struct Context* context) {
- goto replaceNode(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node, context->data[Tree]->tree.result);
-}
-
-__code insertNode(struct Context* context, struct Tree* tree, struct Node* node, struct Node* newNode) {
- node->color = Red;
- *newNode = *node;
-
- tree->current = newNode;
-
- goto meta(context, InsertCase1);
-}
-
-__code insertNode_stub(struct Context* context) {
- goto insertNode(context, &context->data[Tree]->tree, &context->data[Node]->node, &context->data[context->dataNum]->node);
-}
-
-__code insertCase1(struct Context* context, struct Tree* tree, struct Node* current) {
- if (!isEmpty(context->node_stack))
- goto meta(context, InsertCase2);
-
- tree->root->color = Black;
-
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
-}
-
-__code insert1_stub(struct Context* context) {
- goto insertCase1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
-}
-
-__code insertCase2(struct Context* context, struct Node* current) {
- struct Node* parent;
- stack_pop(context->node_stack, &parent);
-
- if (parent->color == Black) {
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
- }
-
- stack_push(context->node_stack, &parent);
- goto meta(context, InsertCase3);
-}
-
-__code insert2_stub(struct Context* context) {
- goto insertCase2(context, context->data[Tree]->tree.current);
-}
-
-__code insertCase3(struct Context* context, struct Tree* tree, struct Node* current) {
- struct Node* parent;
- struct Node* uncle;
- struct Node* grandparent;
-
- stack_pop(context->node_stack, &parent);
- stack_pop(context->node_stack, &grandparent);
-
- if (grandparent->left == parent)
- uncle = grandparent->right;
- else
- uncle = grandparent->left;
-
- if (uncle && (uncle->color == Red)) {
- parent->color = Black;
- uncle->color = Black;
- grandparent->color = Red;
- tree->current = grandparent;
- goto meta(context, InsertCase1);
- }
-
- stack_push(context->node_stack, &grandparent);
- stack_push(context->node_stack, &parent);
-
- goto meta(context, InsertCase4);
-}
-
-__code insert3_stub(struct Context* context) {
- goto insertCase3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
-}
-
-__code insertCase4(struct Context* context, struct Tree* tree, struct Node* current) {
- struct Node* parent;
- struct Node* grandparent;
-
- stack_pop(context->node_stack, &parent);
- stack_pop(context->node_stack, &grandparent);
-
- stack_push(context->node_stack, &grandparent);
-
- tree->current = parent;
-
- if ((current == parent->right) && (parent == grandparent->left)) {
- context->next = InsertCase4_1;
-
- stack_push(context->code_stack, &context->next);
- goto meta(context, RotateL);
- } else if ((current == parent->left) && (parent == grandparent->right)) {
- context->next = InsertCase4_2;
-
- stack_push(context->code_stack, &context->next);
- goto meta(context, RotateR);
- }
-
- stack_push(context->node_stack, &parent);
- tree->current = current;
- goto meta(context, InsertCase5);
-}
-
-__code insert4_stub(struct Context* context) {
- goto insertCase4(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
-}
-
-__code insertCase4_1(struct Context* context, struct Tree* tree) {
- stack_push(context->node_stack, &tree->current);
- tree->current = tree->current->left;
- goto meta(context, InsertCase5);
-}
-
-__code insert4_1_stub(struct Context* context) {
- goto insertCase4_1(context, &context->data[Tree]->tree);
-}
-
-__code insertCase4_2(struct Context* context, struct Tree* tree) {
- stack_push(context->node_stack, &tree->current);
- tree->current = tree->current->right;
- goto meta(context, InsertCase5);
-}
-
-__code insert4_2_stub(struct Context* context) {
- goto insertCase4_2(context, &context->data[Tree]->tree);
-}
-
-__code insertCase5(struct Context* context, struct Tree* tree, struct Node* current) {
- struct Node* parent;
- struct Node* grandparent;
-
- stack_pop(context->node_stack, &parent);
- stack_pop(context->node_stack, &grandparent);
-
- parent->color = Black;
- grandparent->color = Red;
-
- tree->current = grandparent;
-
- if ((current == parent->left) && (parent == grandparent->left))
- goto meta(context, RotateR);
- else
- goto meta(context, RotateL);
-}
-
-__code insert5_stub(struct Context* context) {
- goto insertCase5(context, &context->data[Tree]->tree, context->data[Tree]->tree.current);
-}
-
-__code rotateLeft(struct Context* context, struct Node* node, struct Tree* tree) {
- struct Node* tmp = node->right;
- struct Node* parent = 0;
-
- stack_pop(context->node_stack, &parent);
-
- if (parent) {
- if (node == parent->left)
- parent->left = tmp;
- else
- parent->right = tmp;
- } else {
- tree->root = tmp;
- }
-
- stack_push(context->node_stack, &parent);
-
- node->right = tmp->left;
- tmp->left = node;
- tree->current = tmp;
-
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
-}
-
-__code rotateLeft_stub(struct Context* context) {
- goto rotateLeft(context, context->data[Tree]->tree.current, &context->data[Tree]->tree);
-}
-
-__code rotateRight(struct Context* context, struct Node* node, struct Tree* tree) {
- struct Node* tmp = node->left;
- struct Node* parent = 0;
-
- stack_pop(context->node_stack, &parent);
-
- if (parent) {
- if (node == parent->left)
- parent->left = tmp;
- else
- parent->right = tmp;
- } else {
- tree->root = tmp;
- }
-
- stack_push(context->node_stack, &parent);
-
- node->left = tmp->right;
- tmp->right = node;
- tree->current = tmp;
-
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
-}
-
-__code rotateRight_stub(struct Context* context) {
- goto rotateRight(context, context->data[Tree]->tree.current, &context->data[Tree]->tree);
-}
-
-__code stackClear(struct Context* context, stack_ptr node_stack, struct Tree* tree) {
- if (stack_pop(node_stack, &tree->current) == 0)
- goto meta(context, StackClear);
-
- tree->current = 0;
-
- stack_pop(context->code_stack, &context->next);
- goto meta(context, context->next);
-}
-
-__code stackClear_stub(struct Context* context) {
- goto stackClear(context, context->node_stack, &context->data[Tree]->tree);
-}
-
-
-/* /\* __code get(struct Context* context, struct Tree* tree) { *\/ */
-/* /\* if (tree->root) { *\/ */
-/* /\* tree->current = tree->root; *\/ */
-
-/* /\* goto meta(context, Search); *\/ */
-/* /\* } *\/ */
-
-/* /\* stack_pop(context->code_stack, &context->next); *\/ */
-/* /\* goto meta(context, context->next); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code get_stub(struct Context* context) { *\/ */
-/* /\* goto get(context, &context->data[Tree]->tree); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code search(struct Context* context, struct Tree* tree, struct Node* node) { *\/ */
-/* /\* compare(context, tree, tree->current->key, node->key); *\/ */
-
-/* /\* if (tree->result == EQ) { *\/ */
-/* /\* *node = *tree->current; *\/ */
-
-/* /\* goto meta(context, context->next); *\/ */
-/* /\* } else if (tree->result == GT) { *\/ */
-/* /\* tree->current = tree->current->right; *\/ */
-/* /\* } else { *\/ */
-/* /\* tree->current = tree->current->left; *\/ */
-/* /\* } *\/ */
-
-/* /\* if (tree->current) *\/ */
-/* /\* goto meta(context, Search); *\/ */
-
-/* /\* stack_pop(context->code_stack, &context->next); *\/ */
-/* /\* goto meta(context, context->next); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code search_stub(struct Context* context) { *\/ */
-/* /\* goto search(context, &context->data[Tree]->tree, &context->data[Node]->node); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete(struct Context* context, struct Tree* tree) { *\/ */
-/* /\* if (tree->root) { *\/ */
-/* /\* stack_push(context->code_stack, &context->next); *\/ */
-/* /\* context->next = Delete1; *\/ */
-/* /\* goto meta(context, Get); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, context->next); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete_stub(struct Context* context) { *\/ */
-/* /\* goto delete(context, &context->data[Tree]->tree); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete1(struct Context* context, struct Tree* tree, struct Allocate* allocate) { *\/ */
-/* /\* allocate->size = sizeof(struct Node); *\/ */
-/* /\* allocator(context); *\/ */
-
-/* /\* struct Node* root = tree->root; *\/ */
-
-/* /\* tree->root = &context->data[context->dataNum]->node; *\/ */
-/* /\* tree->current = root; *\/ */
-
-/* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */
-
-/* /\* goto meta(context, Replace_d1); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete1_stub(struct Context* context) { *\/ */
-/* /\* goto delete1(context, &context->data[Tree]->tree, &context->data[Allocate]->allocate); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete2(struct Context* context, struct Node* current) { *\/ */
-/* /\* if (current->color == Black) { *\/ */
-/* /\* struct Node* child = current->right == NULL ? current->left : current->right; *\/ */
-/* /\* current->color = child == NULL ? Black : child->color; *\/ */
-
-/* /\* goto meta(context, DeleteCase1); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, Delete3); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete2_stub(struct Context* context) { *\/ */
-/* /\* goto delete2(context, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
-/* /\* struct Node* tmp = current->right == NULL ? current->left : current->right; *\/ */
-
-/* /\* if (current->parent) { *\/ */
-/* /\* if (current == current->parent->left) *\/ */
-/* /\* current->parent->left = tmp; *\/ */
-/* /\* else *\/ */
-/* /\* current->parent->right = tmp; *\/ */
-/* /\* } else { *\/ */
-/* /\* tree->root = tmp; *\/ */
-/* /\* } *\/ */
-
-/* /\* if (tmp) *\/ */
-/* /\* tmp->parent = current->parent; *\/ */
-
-/* /\* if (current->parent == NULL && tmp) *\/ */
-/* /\* tmp->color = Black; *\/ */
-
-/* /\* current == current->parent->left ? (current->parent->left = NULL) : (current->parent->right = NULL); *\/ */
-
-/* /\* stack_pop(context->code_stack, &context->next); *\/ */
-/* /\* goto meta(context, context->next); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code delete3_stub(struct Context* context) { *\/ */
-/* /\* goto delete3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code replaceNodeForDelete1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode, int result) { *\/ */
-/* /\* *newNode = *oldNode; *\/ */
-
-/* /\* if (result == EQ) *\/ */
-/* /\* goto meta(context, Replace_d2); *\/ */
-/* /\* else if (result == GT) *\/ */
-/* /\* tree->current = newNode->right; *\/ */
-/* /\* else *\/ */
-/* /\* tree->current = newNode->left; *\/ */
-
-/* /\* tree->current->parent = newNode; *\/ */
-
-/* /\* if (tree->current->left == NULL && tree->current->right == NULL) *\/ */
-/* /\* goto meta(context, Delete2); *\/ */
-
-/* /\* if (result == GT) *\/ */
-/* /\* newNode->right = context->heap; *\/ */
-/* /\* else if (result == LT) *\/ */
-/* /\* newNode->left = context->heap; *\/ */
-
-/* /\* allocator(context); *\/ */
-
-/* /\* compare(context, tree, tree->current->key, context->data[Node]->node.key); *\/ */
-
-/* /\* goto meta(context, Replace_d1); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code replaceNodeForDelete1_stub(struct Context* context) { *\/ */
-/* /\* goto replaceNodeForDelete1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node, context->data[Tree]->tree.result); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code replaceNodeForDelete2(struct Context* context, struct Tree* tree, struct Node* newNode) { *\/ */
-/* /\* if (tree->current->left && tree->current->right) { *\/ */
-/* /\* newNode->left->parent = newNode; *\/ */
-/* /\* tree->current = newNode->left; *\/ */
-/* /\* newNode->left = context->heap; *\/ */
-/* /\* tree->deleted = newNode; *\/ */
-
-/* /\* allocator(context); *\/ */
-/* /\* tree->current->parent = newNode; *\/ */
-
-/* /\* goto meta(context, FindMax1); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, Delete2); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code replaceNodeForDelete2_stub(struct Context* context) { *\/ */
-/* /\* goto replaceNodeForDelete2(context, &context->data[Tree]->tree, &context->data[context->dataNum]->node); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code findMax1(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */
-/* /\* *newNode = *oldNode; *\/ */
-
-/* /\* if (newNode->right) *\/ */
-/* /\* goto meta(context, FindMax2); *\/ */
-
-/* /\* tree->deleted->key = newNode->key; *\/ */
-/* /\* tree->deleted->value = newNode->value; *\/ */
-
-/* /\* tree->current = newNode; *\/ */
-
-/* /\* goto meta(context, Delete2); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code findMax1_stub(struct Context* context) { *\/ */
-/* /\* goto findMax1(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */
-/* /\* } *\/ */
-
-
-/* /\* __code findMax2(struct Context* context, struct Tree* tree, struct Node* oldNode, struct Node* newNode) { *\/ */
-/* /\* *newNode = *oldNode; *\/ */
-
-/* /\* if (newNode->right->right) { *\/ */
-/* /\* tree->current = newNode->right; *\/ */
-/* /\* newNode->right = context->heap; *\/ */
-
-/* /\* allocator(context); *\/ */
-/* /\* tree->current->parent = newNode; *\/ */
-
-/* /\* goto meta(context, FindMax2); *\/ */
-/* /\* } *\/ */
-
-/* /\* tree->deleted->key = newNode->right->key; *\/ */
-/* /\* tree->deleted->value = newNode->right->value; *\/ */
-
-/* /\* tree->current = newNode; *\/ */
-
-/* /\* goto meta(context, Delete2); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code findMax2_stub(struct Context* context) { *\/ */
-/* /\* goto findMax2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current, &context->data[context->dataNum]->node); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase1(struct Context* context, struct Node* current) { *\/ */
-/* /\* if (current->parent) *\/ */
-/* /\* goto meta(context, DeleteCase2); *\/ */
-
-/* /\* goto meta(context, Delete3); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase1_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase1(context, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase2(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
-/* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
-
-/* /\* if ((sibling == NULL ? Black : sibling->color) == Red) { *\/ */
-/* /\* current->parent->color = Red; *\/ */
-/* /\* sibling->color = Black; *\/ */
-
-/* /\* current == current->parent->left ? (current->parent->left = context->heap) : (current->parent->right = context->heap); *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* context->data[context->dataNum]->node = *sibling; *\/ */
-
-/* /\* tree->current = current->parent; *\/ */
-
-/* /\* context->next = DeleteCase3; *\/ */
-/* /\* stack_push(context->code_stack, &context->next); *\/ */
-
-/* /\* if (current == current->parent->left) *\/ */
-/* /\* goto meta(context, RotateL); *\/ */
-/* /\* else *\/ */
-/* /\* goto meta(context, RotateR); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, DeleteCase3); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase2_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase2(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase3(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
-/* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
-
-/* /\* if (current->parent->color == Black && *\/ */
-/* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
-/* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
-/* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
-/* /\* sibling->color = Red; *\/ */
-
-/* /\* tree->current = current->parent; *\/ */
-/* /\* goto meta(context, DeleteCase1); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, DeleteCase4); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase3_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase3(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase4(struct Context* context, struct Node* current) { *\/ */
-/* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
-
-/* /\* if (current->parent->color == Red && *\/ */
-/* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
-/* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
-/* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
-/* /\* sibling->color = Red; *\/ */
-/* /\* current->parent->color = Black; *\/ */
-
-/* /\* goto meta(context, Delete3); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, DeleteCase5); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase4_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase4(context, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase5(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
-/* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
-/* /\* sibling->parent = current->parent; *\/ */
-
-/* /\* if (current == current->parent->left && *\/ */
-/* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
-/* /\* (sibling->left == NULL ? Black : sibling->left->color) == Red && *\/ */
-/* /\* (sibling->right == NULL ? Black : sibling->right->color) == Black) { *\/ */
-/* /\* sibling->color = Red; *\/ */
-/* /\* sibling->left->color = Black; *\/ */
-
-/* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
-/* /\* *tmp = *sibling; *\/ */
-/* /\* tmp->parent = current; *\/ */
-
-/* /\* tmp->left = context->heap; *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* context->data[context->dataNum]->node = *sibling->left; *\/ */
-/* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */
-
-/* /\* tree->current = tmp; *\/ */
-
-/* /\* context->next = DeleteCase6; *\/ */
-/* /\* stack_push(context->code_stack, &context->next); *\/ */
-
-/* /\* goto meta(context, RotateR); *\/ */
-/* /\* } else if (current == current->parent->right && *\/ */
-/* /\* (sibling == NULL ? Black : sibling->color) == Black && *\/ */
-/* /\* (sibling->left == NULL ? Black : sibling->left->color) == Black && *\/ */
-/* /\* (sibling->right == NULL ? Black : sibling->right->color) == Red) { *\/ */
-/* /\* sibling->color = Red; *\/ */
-/* /\* sibling->right->color = Black; *\/ */
-
-/* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
-/* /\* *tmp = *sibling; *\/ */
-/* /\* tmp->parent = current; *\/ */
-
-/* /\* tmp->right = context->heap; *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* context->data[context->dataNum]->node = *sibling->right; *\/ */
-/* /\* context->data[context->dataNum]->node.parent = tmp; *\/ */
-
-/* /\* tree->current = tmp; *\/ */
-
-/* /\* context->next = DeleteCase6; *\/ */
-/* /\* stack_push(context->code_stack, &context->next); *\/ */
-/* /\* goto meta(context, RotateL); *\/ */
-/* /\* } *\/ */
-
-/* /\* goto meta(context, DeleteCase6); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase5_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase5(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase6(struct Context* context, struct Tree* tree, struct Node* current) { *\/ */
-/* /\* struct Node* sibling = current == current->parent->left ? current->parent->right : current->parent->left; *\/ */
-
-/* /\* sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap); *\/ */
-/* /\* allocator(context); *\/ */
-/* /\* struct Node* tmp = &context->data[context->dataNum]->node; *\/ */
-/* /\* *tmp = *sibling; *\/ */
-/* /\* tmp->parent = current; *\/ */
-
-/* /\* tmp->color = current->parent->color; *\/ */
-/* /\* current->parent->color = Black; *\/ */
-
-/* /\* context->next = Delete3; *\/ */
-/* /\* stack_push(context->code_stack, &context->next); *\/ */
-
-/* /\* if (current == current->parent->left) { *\/ */
-/* /\* tmp->right->color = Black; *\/ */
-/* /\* tree->current = current->parent; *\/ */
-
-/* /\* goto meta(context, RotateL); *\/ */
-/* /\* } else { *\/ */
-/* /\* tmp->left->color = Black; *\/ */
-/* /\* tree->current = current->parent; *\/ */
-
-/* /\* goto meta(context, RotateR); *\/ */
-/* /\* } *\/ */
-/* /\* } *\/ */
-
-/* /\* __code deleteCase6_stub(struct Context* context) { *\/ */
-/* /\* goto deleteCase6(context, &context->data[Tree]->tree, context->data[Tree]->tree.current); *\/ */
-/* /\* } *\/ */
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/llrbContext.c
--- a/src/llrb/llrbContext.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-#include
-
-#include "llrbContext.h"
-
-extern __code code1_stub(struct Context*);
-extern __code code2_stub(struct Context*);
-extern __code code3_stub(struct Context*);
-extern __code code4(struct Context*);
-extern __code code5(struct Context*);
-extern __code find(struct Context*);
-extern __code not_find(struct Context*);
-extern __code code6(struct Context*);
-extern __code meta(struct Context*);
-extern __code put_stub(struct Context*);
-extern __code replaceNode_stub(struct Context*);
-extern __code insertNode_stub(struct Context*);
-extern __code rotateLeft_stub(struct Context*);
-extern __code rotateRight_stub(struct Context*);
-extern __code colorFlip_stub(struct Context*);
-extern __code fixUp_stub(struct Context*);
-extern __code changeReference_stub(struct Context*);
-extern __code insert1_stub(struct Context*);
-extern __code insert2_stub(struct Context*);
-extern __code insert3_stub(struct Context*);
-extern __code insert4_stub(struct Context*);
-extern __code insert4_1_stub(struct Context*);
-extern __code insert4_2_stub(struct Context*);
-extern __code insert5_stub(struct Context*);
-extern __code stackClear_stub(struct Context*);
-extern __code get_stub(struct Context*);
-extern __code search_stub(struct Context*);
-extern __code delete_stub(struct Context*);
-extern __code delete1_stub(struct Context*);
-extern __code delete2_stub(struct Context*);
-extern __code delete3_stub(struct Context*);
-extern __code replaceNodeForDelete1_stub(struct Context*);
-extern __code replaceNodeForDelete2_stub(struct Context*);
-extern __code findMax1_stub(struct Context*);
-extern __code findMax2_stub(struct Context*);
-extern __code deleteCase1_stub(struct Context*);
-extern __code deleteCase2_stub(struct Context*);
-extern __code deleteCase3_stub(struct Context*);
-extern __code deleteCase4_stub(struct Context*);
-extern __code deleteCase5_stub(struct Context*);
-extern __code deleteCase6_stub(struct Context*);
-extern __code exit_code(struct Context*);
-
-__code initLLRBContext(struct Context* context, int num) {
- context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
- context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE);
- context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
- context->heapStart = malloc(context->heapLimit);
-
- context->codeNum = Exit;
-
- context->code[Code1] = code1_stub;
- context->code[Code2] = code2_stub;
- context->code[Code3] = code3_stub;
- context->code[Code4] = code4;
- context->code[Code5] = code5;
- context->code[Find] = find;
- context->code[Not_find] = not_find;
- context->code[Code6] = code6;
- context->code[Put] = put_stub;
- context->code[Replace] = replaceNode_stub;
- context->code[Insert] = insertNode_stub;
- context->code[RotateL] = rotateLeft_stub;
- context->code[RotateR] = rotateRight_stub;
- context->code[InsertCase1] = insert1_stub;
- context->code[InsertCase2] = insert2_stub;
- context->code[InsertCase3] = insert3_stub;
- context->code[InsertCase4] = insert4_stub;
- context->code[InsertCase4_1] = insert4_1_stub;
- context->code[InsertCase4_2] = insert4_2_stub;
- context->code[InsertCase5] = insert5_stub;
- context->code[StackClear] = stackClear_stub;
- /* context->code[Get] = get_stub; */
- /* context->code[Search] = search_stub; */
- /* context->code[Delete] = delete_stub; */
- /* context->code[Delete1] = delete1_stub; */
- /* context->code[Delete2] = delete2_stub; */
- /* context->code[Delete3] = delete3_stub; */
- /* context->code[Replace_d1] = replaceNodeForDelete1_stub; */
- /* context->code[Replace_d2] = replaceNodeForDelete2_stub; */
- /* context->code[FindMax1] = findMax1_stub; */
- /* context->code[FindMax2] = findMax2_stub; */
- /* context->code[DeleteCase1] = deleteCase1_stub; */
- /* context->code[DeleteCase2] = deleteCase2_stub; */
- /* context->code[DeleteCase3] = deleteCase3_stub; */
- /* context->code[DeleteCase4] = deleteCase4_stub; */
- /* context->code[DeleteCase5] = deleteCase5_stub; */
- /* context->code[DeleteCase6] = deleteCase6_stub; */
- context->code[Exit] = exit_code;
-
- context->heap = context->heapStart;
-
- context->data[Allocate] = context->heap;
- context->heap += sizeof(struct Allocate);
-
- context->data[Tree] = context->heap;
- context->heap += sizeof(struct Tree);
-
- context->data[Node] = context->heap;
- context->heap += sizeof(struct Node);
-
- context->dataNum = Node;
-
- struct Tree* tree = &context->data[Tree]->tree;
- tree->root = 0;
- tree->current = 0;
- tree->deleted = 0;
-
- context->node_stack = stack_init(sizeof(struct Node*), 100);
- context->code_stack = stack_init(sizeof(enum Code), 100);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/main.c
--- a/src/llrb/main.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-#include
-#include
-#include
-
-#include "llrbContext.h"
-#include "origin_cs.h"
-
-static double st_time;
-static double ed_time;
-static clock_t c1,c2;
-
-int num;
-
-extern __code initLLRBContext(struct Context* context, int);
-extern void allocator(struct Context* context);
-
-static double getTime() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return tv.tv_sec + (double)tv.tv_usec*1e-6;
-}
-
-void print_tree(struct Node* node, int n) {
- if (node != 0) {
- print_tree(node->left, n+1);
- for (int i=0;ikey, node->value,/* n, */node->color==0? "R":"B", node);
- print_tree(node->right, n+1);
- }
-}
-
-/*
-__code code1(Allocate allocate) {
- allocate.size = sizeof(long);
- allocate.next = Code2;
- goto Allocate(allocate);
-}
-*/
-
-__code code1(struct Context* context, struct Allocate *allocate) {
- allocate->size = sizeof(struct Count);
- allocator(context);
- goto meta(context, Code2);
-}
-
-__code code1_stub(struct Context* context) {
- goto code1(context, &context->data[Allocate]->allocate);
-}
-
-/*
-__code code2(Allocate allocate, Count count) {
- count.count = 0;
- goto code3(count);
-}
-*/
-
-__code code2(struct Context* context, struct Count* count) {
- count->i = num;
- goto meta(context, Code3);
-}
-
-__code code2_stub(struct Context* context) {
- goto code2(context, &context->data[context->dataNum]->count);
-}
-
-__code code3(struct Context* context, struct Node* node, struct Count* count) {
- if (count->i == 0) {
- goto meta(context, Code4);
- }
-
- print_tree(context->data[Tree]->tree.root, 0);
- puts("");
- context->next = Code3;
- node->key = rand()%100+1;
- node->value = count->i;
-
- count->i--;
- goto meta(context, Put);
-}
-
-__code code3_stub(struct Context* context) {
- goto code3(context, &context->data[Node]->node, &context->data[3]->count);
-}
-
-__code code4(struct Context* context) {
- puts("---before---");
- print_tree(context->data[Tree]->tree.root, 0);
-
- struct Node* node = &context->data[Node]->node;
- node->key = 4;
-
- context->next = Code5;
-
- goto meta(context, Exit);
-}
-
-__code code5(struct Context* context) {
- puts("---after---");
- print_tree(context->data[Tree]->tree.root, 0);
- puts("--Number of Data--");
- printf("%d\n", context->dataNum);
-
- goto meta(context, Exit);
-}
-
-__code find(struct Context* context) {
- context->data[Node]->node.key = 2;
- context->next = Not_find;
-
- goto meta(context, Get);
-}
-
-__code not_find(struct Context* context) {
- context->data[Node]->node.key = 10;
- context->next = Code6;
-
- printf("%p\n", context->data[Tree]->tree.current);
- context->data[Tree]->tree.current = 0;
- goto meta(context, Get);
-}
-
-__code code6(struct Context* context) {
- printf("%p\n", context->data[Tree]->tree.current);
-
- stack_free(context->node_stack);
-
- goto meta(context, Exit);
-}
-
-int main(int argc, char** argv) {
- num = (int)atoi(argv[1]);
- struct Context* context = (struct Context*)malloc(sizeof(struct Context));
- initLLRBContext(context, num);
- goto start_code(context, Code1);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/origin_cs.c
--- a/src/llrb/origin_cs.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#include
-#include "llrbContext.h"
-
-__code meta(struct Context* context, enum Code next) {
- goto (context->code[next])(context);
-}
-
-__code start_code(struct Context* context, enum Code next) {
- goto meta(context, next);
-}
-
-__code exit_code(struct Context* context) {
- free(context->code);
- free(context->data);
- free(context->heapStart);
- goto exit(0);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/llrb/stack.c
--- a/src/llrb/stack.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#include
-#include "stack.h"
-
-stack_ptr stack_init(size_t size, int max) {
- stack_ptr stack_ptr;
-
- if ((stack_ptr = calloc(1, sizeof(stack))) == NULL)
- return NULL;
-
- if ((stack_ptr->data = calloc(max, size)) == NULL) {
- free(stack_ptr);
- return NULL;
- }
-
- stack_ptr->size = size;
- stack_ptr->max = max;
- stack_ptr->num = 0;
-
- return stack_ptr;
-}
-
-stack_ptr stack_realloc(stack_ptr stack_ptr, int max) {
- if (stack_ptr == NULL)
- return NULL;
-
- if ((stack_ptr->data = realloc(stack_ptr->data, stack_ptr->size*max)) == NULL)
- return NULL;
-
- stack_ptr->max = max;
-
- return stack_ptr;
-}
-
-void stack_free(stack_ptr stack_ptr) {
- if (stack_ptr != NULL && stack_ptr->data != NULL) {
- free(stack_ptr->data);
- free(stack_ptr);
- }
-}
-
-int stack_push(stack_ptr stack_ptr, void* data) {
- if (stack_ptr->max <= stack_ptr->num)
- return -1;
-
- memcpy((char*)stack_ptr->data+stack_ptr->num*stack_ptr->size, data, stack_ptr->size);
- stack_ptr->num++;
-
- return 0;
-}
-
-int stack_pop(stack_ptr stack_ptr, void* data) {
- if (stack_ptr->num == 0)
- return -1;
-
- stack_ptr->num--;
-
- memcpy(data, (char*)stack_ptr->data+stack_ptr->num*stack_ptr->size, stack_ptr->size);
-
- return 0;
-}
-
-int isMax(const stack_ptr stack_ptr) {
- return stack_ptr->max<=stack_ptr->num;
-}
-
-int isEmpty(const stack_ptr stack_ptr) {
- return stack_ptr->num<=0;
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Atomic.h
--- a/src/parallel_execution/Atomic.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-typedef struct Atomic{
- union Data* atomic;
- union Data** ptr;
- union Data* oldData;
- union Data* newData;
- __code checkAndSet(Impl* atomic, union Data** ptr, union Data* oldData, union Data* newData, __code next(...), __code fail(...));
- __code next(...);
- __code fail(...);
-} Atomic;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/AtomicReference.cbc
--- a/src/parallel_execution/AtomicReference.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#include "../context.h"
-#interface "Atomic.h"
-#include
-
-Atomic* createAtomicReference(struct Context* context) {
- struct Atomic* atomic = new Atomic();
- struct AtomicReference* atomicReference = new AtomicReference();
- atomic->atomic = (union Data*)atomicReference;
- atomic->checkAndSet = C_checkAndSetAtomicReference;
- return atomic;
-}
-
-__code checkAndSetAtomicReference(struct AtomicReference* atomic, union Data** ptr, union Data* oldData, union Data* newData, __code next(...), __code fail(...)) {
- if (__sync_bool_compare_and_swap(ptr, oldData, newData)) {
- goto next(...);
- }
- goto fail(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Buffer.h
--- a/src/parallel_execution/Buffer.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-typedef struct Buffer{
- union Data* buffer;
- union Data* data;
- __code put(Impl* buffer, union Data* data, __code next(...));
- __code take(Impl* buffer, __code next(union Data*, ...));
- __code next(...);
-} Buffer;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/CMakeLists.txt
--- a/src/parallel_execution/CMakeLists.txt Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-cmake_minimum_required(VERSION 3.8)
-
-set(USE_CUDA,0)
-# -DUSE_CUDA
-# add_definitions("-Wall -g -O")
-
-set(CMAKE_C_COMPILER $ENV{CBC_COMPILER})
-add_definitions("-Wall -g")
-
-# -DCMAKE_BUILD_TYPE=Debug
-set(CMAKE_C_FLAGS_DEBUG "-O0")
-
-if (${USE_CUDA})
- include_directories("/usr/local/cuda/include")
- set(NVCCFLAG "-std=c++11" "-g" "-O0" )
- if (UNIX AND NOT APPLE) # LINUX
- set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
- elseif (APPLE)
- set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /usr/local/cuda/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib")
- endif()
- find_package(CUDA REQUIRED)
- SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
-endif()
-
-macro( GearsCommand )
- set( _OPTIONS_ARGS )
- set( _ONE_VALUE_ARGS TARGET )
- set( _MULTI_VALUE_ARGS SOURCES )
- cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
-
- set (_Gears_CSOURCES)
- foreach(i ${_Gears_SOURCES})
- if (${i} MATCHES "\\.cbc")
- string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
- add_custom_command (
- OUTPUT ${j}
- DEPENDS ${i}
- COMMAND "perl" "generate_stub.pl" "-o" ${j} ${i}
- )
- elseif (${i} MATCHES "\\.cu")
- string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
- add_custom_command (
- OUTPUT ${j}
- DEPENDS ${i}
- COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
- )
- else()
- set(j ${i})
- endif()
- list(APPEND _Gears_CSOURCES ${j})
- endforeach(i)
-
- add_custom_command (
- OUTPUT c/${_Gears_TARGET}-context.c
- DEPENDS ${_Gears_CSOURCES}
- COMMAND "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES}
- )
- add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c)
- target_link_libraries(${_Gears_TARGET} m pthread)
-endmacro()
-
-
-GearsCommand(
- TARGET
- twice
- SOURCES
- examples/twice/main.cbc examples/twice/createArray.cbc examples/twice/twice.cbc examples/twice/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc TimerImpl.cbc MultiDimIterator.cbc AtomicReference.cbc
-)
-
-GearsCommand(
- TARGET
- calc
- SOURCES
- examples/calc/calc.cbc examples/calc/add.cbc examples/calc/mult.cbc examples/calc/initIntegerDataGears.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc AtomicReference.cbc
-)
-
-GearsCommand(
- TARGET
- bitonicSort
- SOURCES
- examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc TimerImpl.cbc AtomicReference.cbc
-)
-
-if (${USE_CUDA})
- GearsCommand(
- TARGET
- CUDAtwice
- SOURCES
- examples/twice/main.cbc examples/twice/twice.cbc examples/twice/CUDAtwice.cu examples/twice/createArray.cbc examples/twice/printArray.cbc CPUWorker.cbc TimerImpl.cbc examples/twice/twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc CUDAWorker.cbc cuda.c MultiDimIterator.cbc CUDAExecutor.cbc AtomicReference.cbc
- )
- set_target_properties(CUDAtwice PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1")
-
- GearsCommand(
- TARGET
- CUDAbitonicSort
- SOURCES
- examples/bitonicSort/bitonicSort.cbc examples/bitonicSort/bitonicSwap.cbc examples/bitonicSort/CUDAbitonicSwap.cu examples/bitonicSort/makeArray.cbc examples/bitonicSort/printArray.cbc CPUWorker.cbc CUDAWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc cuda.c MultiDimIterator.cbc TimerImpl.cbc CUDAExecutor.cbc AtomicReference.cbc
- )
- set_target_properties(CUDAbitonicSort PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1")
-endif()
-
-GearsCommand(
- TARGET
- queue_test
- SOURCES
- test/queue_test.cbc SingleLinkedQueue.cbc
-)
-
-GearsCommand(
- TARGET
- stack_test
- SOURCES
- test/stack_test.cbc SingleLinkedStack.cbc SingleLinkedQueue.cbc
-)
-
-GearsCommand(
- TARGET
- multiDimIterator_test
- SOURCES
- test/multiDimIterator_test.cbc test/printIterator.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc
-)
-
-GearsCommand(
- TARGET
- sort
- SOURCES
- examples/bitonicSort/sort.cbc
-)
-
-GearsCommand(
- TARGET
- rbtree
- SOURCES
- SingleLinkedQueue.cbc test/rbTree_test.cbc RedBlackTree.cbc SingleLinkedStack.cbc
-)
-
-GearsCommand(
- TARGET
- boundedBuffer
- SOURCES
- examples/boundedBuffer/main.cbc examples/boundedBuffer/initBuffer.cbc examples/boundedBuffer/SemaphoreImpl.cbc examples/boundedBuffer/BoundedBuffer.cbc examples/boundedBuffer/consumer.cbc examples/boundedBuffer/producer.cbc SpinLock.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc MultiDimIterator.cbc AtomicReference.cbc
-)
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/CPUWorker.cbc
--- a/src/parallel_execution/CPUWorker.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-#include "../context.h"
-#interface "TaskManager.h"
-#interface "Worker.h"
-#interface "Iterator.h"
-#interface "Queue.h"
-
-static void startWorker(Worker* worker);
-
-Worker* createCPUWorker(struct Context* context, int id, Queue* queue) {
- struct Worker* worker = new Worker();
- struct CPUWorker* cpuWorker = new CPUWorker();
- worker->worker = (union Data*)cpuWorker;
- worker->tasks = queue;
- cpuWorker->id = id;
- cpuWorker->loopCounter = 0;
- worker->taskReceive = C_taskReceiveCPUWorker;
- worker->shutdown = C_shutdownCPUWorker;
- pthread_create(&worker->thread, NULL, (void*)&startWorker, worker);
- return worker;
-}
-
-static void startWorker(struct Worker* worker) {
- struct CPUWorker* cpuWorker = &worker->worker->CPUWorker;
- cpuWorker->context = NEW(struct Context);
- initContext(cpuWorker->context);
- Gearef(cpuWorker->context, Worker)->worker = (union Data*)worker;
- Gearef(cpuWorker->context, Worker)->tasks = worker->tasks;
- goto meta(cpuWorker->context, worker->taskReceive);
-}
-
-__code taskReceiveCPUWorker(struct CPUWorker* worker, struct Queue* tasks) {
- goto tasks->take(getTaskCPUWorker);
-}
-
-__code getTaskCPUWorker(struct CPUWorker* cpuWorker, struct Context* task, struct Worker* worker) {
- if (!task) {
- goto worker->shutdown(); // end thread
- }
- task->worker = worker;
- enum Code taskCg = task->next;
- task->next = C_odgCommitCPUWorker; // commit outputDG after task exec
- goto meta(task, taskCg); // switch task context
-}
-
-__code getTaskCPUWorker_stub(struct Context* context) {
- CPUWorker* cpuWorker = (CPUWorker*)GearImpl(context, Worker, worker);
- Worker* worker = &Gearef(context,Worker)->worker->Worker;
- struct Context* task = &Gearef(context, Queue)->data->Context;
- goto getTaskCPUWorker(context, cpuWorker, task, worker);
-}
-
-__code odgCommitCPUWorker(struct CPUWorker* worker, struct Context* task) {
- if (task->iterate) {
- struct Iterator* iterator = task->iterator;
- goto iterator->barrier(task, odgCommitCPUWorker1, odgCommitCPUWorker6);
- } else {
- goto odgCommitCPUWorker1();
- }
-}
-
-__code odgCommitCPUWorker_stub(struct Context* context) {
- // switch worker context
- struct Context* workerContext = context->worker->worker->CPUWorker.context;
- Gearef(workerContext, Worker)->worker = (union Data*)context->worker;
- Gearef(workerContext, Worker)->task = context;
- CPUWorker* cpuWorker = (CPUWorker*)GearImpl(workerContext, Worker, worker);
- goto odgCommitCPUWorker(workerContext,
- cpuWorker,
- context);
-}
-
-__code odgCommitCPUWorker1(struct CPUWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- if (task->odg+i < task->maxOdg) {
- goto odgCommitCPUWorker2();
- }
- worker->loopCounter = 0;
- struct TaskManager* taskManager = task->taskManager;
- goto taskManager->decrementTaskCount(odgCommitCPUWorker6);
-}
-
-__code odgCommitCPUWorker2(struct CPUWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- struct Queue* queue = GET_WAIT_LIST(task->data[task->odg+i]);
- goto queue->isEmpty(odgCommitCPUWorker3, odgCommitCPUWorker5);
-}
-
-__code odgCommitCPUWorker3(struct CPUWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- struct Queue* queue = GET_WAIT_LIST(task->data[task->odg+i]);
- goto queue->take(odgCommitCPUWorker4);
-}
-
-__code odgCommitCPUWorker4(struct CPUWorker* worker, struct Context* task, struct Context* waitTask) {
- if (__sync_fetch_and_sub(&waitTask->idgCount, 1) == 1) { // atomic decrement idg counter(__sync_fetch_and_sub function return initial value of waitTask->idgCount point)
- struct TaskManager* taskManager = waitTask->taskManager;
- goto taskManager->spawn(waitTask, odgCommitCPUWorker2);
- }
- goto odgCommitCPUWorker2();
-}
-
-__code odgCommitCPUWorker4_stub(struct Context* context) {
- CPUWorker* cpuWorker = (CPUWorker*)GearImpl(context, Worker, worker);
- struct Context* task = Gearef(context, Worker)->task;
- struct Context* waitTask = &Gearef(context, Queue)->data->Context;
- goto odgCommitCPUWorker4(context,
- cpuWorker,
- task,
- waitTask);
-}
-
-__code odgCommitCPUWorker5(struct CPUWorker* worker, struct Context* task) {
- worker->loopCounter++;
- goto odgCommitCPUWorker1();
-}
-
-__code odgCommitCPUWorker6(struct CPUWorker* worker, struct Context* task) {
- struct Worker* taskWorker = task->worker;
- goto taskWorker->taskReceive(taskWorker->tasks);
-}
-
-__code shutdownCPUWorker(struct CPUWorker* worker) {
- goto exit_code();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/CUDAExecutor.cbc
--- a/src/parallel_execution/CUDAExecutor.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#include "../context.h"
-#interface "Executor.h"
-#include
-
-Executor* createCUDAExecutor(struct Context* context, CUdevice device) {
- struct Executor* executor = new Executor();
- struct CUDAExecutor* cudaExecutor = new CUDAExecutor();
- checkCudaErrors(cuDeviceGetAttribute(&cudaExecutor->maxThreadPerBlock, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK, device));
- executor->executor = (union Data*)cudaExecutor;
- executor->read = C_readCUDAExecutor;
- executor->exec = C_execCUDAExecutor;
- executor->write = C_writeCUDAExecutor;
- return executor;
-}
-
-__code readCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) {
- struct CUDABuffer* buffer = executor->buffer;
- int paramLen = buffer->inputLen + buffer->outputLen;
- executor->kernelParams = (CUdeviceptr**)ALLOCATE_PTR_ARRAY(context, CUdeviceptr, paramLen);
- for (int i = 0; i < paramLen; i++) {
- CUdeviceptr* deviceptr = new CUdeviceptr();
- // memory allocate
- union Data* data = i < buffer->inputLen? buffer->inputData[i] : buffer->outputData[i-buffer->inputLen];
- checkCudaErrors(cuMemAlloc(deviceptr, GET_SIZE(data)));
- checkCudaErrors(cuMemcpyHtoD(*deviceptr, data, GET_SIZE(data)));
- // Synchronous data transfer(host to device)
- executor->kernelParams[i] = deviceptr;
- }
- // TODO: Implements pipeline
- // goto next(...);
- goto meta(context, C_execCUDAExecutor);
-}
-
-int computeblockDim(int count, int maxThreadPerBlock) {
- return count < maxThreadPerBlock ? count : maxThreadPerBlock;
-}
-
-__code execCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) {
- // Asynchronous launch kernel
- task->num_exec = 1;
- if (task->iterate) {
- struct MultiDimIterator* iterator = &task->iterator->iterator->MultiDimIterator;
- int blockDimX = computeblockDim(iterator->x, executor->maxThreadPerBlock);
- int blockDimY = computeblockDim(iterator->y, executor->maxThreadPerBlock);
- int blockDimZ = computeblockDim(iterator->z, executor->maxThreadPerBlock);
- checkCudaErrors(cuLaunchKernel(task->function,
- iterator->x/blockDimX, iterator->y/blockDimY, iterator->z/blockDimZ,
- blockDimX, blockDimY, blockDimZ,
- 0, NULL, (void**)executor->kernelParams, NULL));
- } else {
- checkCudaErrors(cuLaunchKernel(task->function,
- 1, 1, 1,
- 1, 1, 1,
- 0, NULL, (void**)executor->kernelParams, NULL));
- }
- // TODO: Implements pipeline
- // goto next(...);
- goto meta(context, C_writeCUDAExecutor);
-}
-
-__code writeCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) {
- //結果を取ってくるコマンドを入力する
- //コマンドの終了待ちを行う
- struct CUDABuffer* buffer = executor->buffer;
- int paramLen = buffer->inputLen + buffer->outputLen;
- for (int i = 0; i < paramLen; i++) {
- CUdeviceptr deviceptr = *(executor->kernelParams[i]);
- union Data* data = i < buffer->inputLen? buffer->inputData[i] : buffer->outputData[i-buffer->inputLen];
- checkCudaErrors(cuMemcpyDtoH(data, deviceptr, GET_SIZE(data)));
- cuMemFree(deviceptr);
- }
- // wait for stream
- checkCudaErrors(cuCtxSynchronize());
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/CUDAWorker.cbc
--- a/src/parallel_execution/CUDAWorker.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-#include "../context.h"
-#interface "TaskManager.h"
-#interface "Worker.h"
-#interface "Iterator.h"
-#interface "Queue.h"
-
-extern void cudaInit(struct CUDAWorker *cudaWorker,int phase, int deviceNum);
-extern void cudaShutdown(CUDAWorker *cudaWorker);
-
-static void startCUDAWorker(Worker* worker);
-
-Worker* createCUDAWorker(struct Context* context, int id, Queue* queue, int deviceNum) {
- struct Worker* worker = new Worker();
- struct CUDAWorker* cudaWorker = new CUDAWorker();
- worker->worker = (union Data*)cudaWorker;
- worker->tasks = queue;
- cudaWorker->id = id;
- cudaWorker->loopCounter = 0;
- cudaWorker->deviceNum = deviceNum;
- worker->taskReceive = C_taskReceiveCUDAWorker;
- worker->shutdown = C_shutdownCUDAWorker;
- pthread_create(&worker->thread, NULL, (void*)&startCUDAWorker, worker);
- return worker;
-}
-
-static void startCUDAWorker(Worker* worker) {
- struct CUDAWorker* cudaWorker = &worker->worker->CUDAWorker;
- cudaInit(cudaWorker, 0, cudaWorker->deviceNum);
- cudaWorker->context = NEW(struct Context);
- initContext(cudaWorker->context);
- cudaWorker->executor = createCUDAExecutor(cudaWorker->context, cudaWorker->device);
- Gearef(cudaWorker->context, Worker)->worker = (union Data*)worker;
- Gearef(cudaWorker->context, Worker)->tasks = worker->tasks;
- goto meta(cudaWorker->context, worker->taskReceive);
-}
-
-__code taskReceiveCUDAWorker(struct Worker* worker, struct Queue* tasks) {
- goto tasks->take(getTaskCUDAWorker);
-}
-
-__code getTaskCUDAWorker(struct CUDAWorker* cudaWorker, struct Context* task, struct Worker* worker) {
- if (!task) {
- goto worker->shutdown(); // end thread
- }
- task->worker = worker;
- enum Code taskCg = task->next;
- task->next = C_odgCommitCUDAWorker; // commit outputDG after task exec
- goto meta(task, taskCg); // switch task context
-}
-
-__code getTaskCUDAWorker_stub(struct Context* context) {
- CUDAWorker* cudaWorker = (CUDAWorker*)GearImpl(context, Worker, worker);
- Worker* worker = &Gearef(context,Worker)->worker->Worker;
- struct Context* task = &Gearef(context, Queue)->data->Context;
- goto getTaskCUDAWorker(context, cudaWorker, task, worker);
-}
-
-__code odgCommitCUDAWorker(struct CUDAWorker* worker, struct Context* task) {
- if (task->iterate) {
- struct Iterator* iterator = task->iterator;
- goto iterator->barrier(task, odgCommitCUDAWorker1, odgCommitCUDAWorker6);
- } else {
- goto odgCommitCUDAWorker1();
- }
-}
-
-__code odgCommitCUDAWorker_stub(struct Context* context) {
- // switch worker context
- struct Context* workerContext = context->worker->worker->CUDAWorker.context;
- Gearef(workerContext, Worker)->worker = (union Data*)context->worker;
- Gearef(workerContext, Worker)->task = context;
- CUDAWorker* cudaWorker = (CUDAWorker*)GearImpl(workerContext, Worker, worker);
- goto odgCommitCUDAWorker(workerContext,
- cudaWorker,
- context);
-}
-
-__code odgCommitCUDAWorker1(struct CUDAWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- if (task->odg+i < task->maxOdg) {
- goto odgCommitCUDAWorker2();
- }
- worker->loopCounter = 0;
- struct TaskManager* taskManager = task->taskManager;
- goto taskManager->decrementTaskCount(odgCommitCUDAWorker6);
-}
-
-__code odgCommitCUDAWorker2(struct CUDAWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- struct Queue* queue = GET_WAIT_LIST(task->data[task->odg+i]);
- goto queue->isEmpty(odgCommitCUDAWorker3, odgCommitCUDAWorker5);
-}
-
-__code odgCommitCUDAWorker3(struct CUDAWorker* worker, struct Context* task) {
- int i = worker->loopCounter;
- struct Queue* queue = GET_WAIT_LIST(task->data[task->odg+i]);
- goto queue->take(odgCommitCUDAWorker4);
-}
-
-__code odgCommitCUDAWorker4(struct CUDAWorker* worker, struct Context* task, struct Context* waitTask) {
- if (__sync_fetch_and_sub(&waitTask->idgCount, 1) == 1) { // atomic decrement idg counter(__sync_fetch_and_sub function return initial value of waitTask->idgCount point)
- struct TaskManager* taskManager = waitTask->taskManager;
- goto taskManager->spawn(waitTask, odgCommitCUDAWorker2);
- }
- goto odgCommitCUDAWorker2();
-}
-
-__code odgCommitCUDAWorker4_stub(struct Context* context) {
- CUDAWorker* cudaWorker = (CUDAWorker*)GearImpl(context, Worker, worker);
- struct Context* task = Gearef(context, Worker)->task;
- struct Context* waitTask = &Gearef(context, Queue)->data->Context;
- goto odgCommitCUDAWorker4(context,
- cudaWorker,
- task,
- waitTask);
-}
-
-__code odgCommitCUDAWorker5(struct CUDAWorker* worker, struct Context* task) {
- worker->loopCounter++;
- goto odgCommitCUDAWorker1();
-}
-
-__code odgCommitCUDAWorker6(struct CUDAWorker* worker, struct Context* task) {
- struct Worker* taskWorker = task->worker;
- goto taskWorker->taskReceive(taskWorker->tasks);
-}
-
-__code shutdownCUDAWorker(struct CUDAWorker* worker) {
- cudaShutdown(worker);
- goto meta(context, C_exit_code);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/CodeGear.h
--- a/src/parallel_execution/CodeGear.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-typedef struct CodeGear{
- union Data* codeGear;
- enum Code code;
- __code code(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...));
- __code setInfo(struct Context* codeGear, union Data** dataGears, __code next(...));
- union Data* dataGears[10];
- __code next(...);
-} CodeGear;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Executor.h
--- a/src/parallel_execution/Executor.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-typedef struct Executor{
- Type* Executor;
- struct Context* task;
- __code read(Impl* executor, struct Context* task, __code next(...));
- __code exec(Impl* executor, struct Context* task, __code next(...));
- __code write(Impl* executor, struct Context* task, __code next(...));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Iterator.h
--- a/src/parallel_execution/Iterator.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-typedef struct Iterator{
- union Data* iterator;
- struct Context* task;
- int numGPU;
- __code exec(Impl* iterator, struct Context* task, int numGPU, __code next(...));
- __code barrier(Impl* iterator, struct Context* task, __code next(...), __code whenWait(...));
- __code whenWait(...);
- __code next(...);
-} Iterator;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Lock.h
--- a/src/parallel_execution/Lock.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-typedef struct Lock{
- union Data* lock;
- __code doLock(Impl* lock, __code next(...));
- __code doUnlock(Impl* lock, __code next(...));
- __code next(...);
-} Lock;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/LockImpl.cbc
--- a/src/parallel_execution/LockImpl.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-#include "../context.h"
-#interface "Queue.h"
-#interface "Atomic.h"
-#interface "Lock.h"
-#interface "Worker.h"
-#interface "TaskManager.h"
-
-Lock* createLockImpl(struct Context* context) {
- struct Lock* lock = new Lock();
- struct LockImpl* lockImpl = new LockImpl();
- lockImpl->lock = NULL;
- lockImpl->waitThreadQueue = createSynchronizedQueue(context);
- lockImpl->atomic = createAtomicReference(context);
- lock->lock = (union Data*)lockImpl;
- lock->doLock = C_doLockLockImpl;
- lock->doUnlock = C_doUnlockLockImpl;
- return lock;
-}
-
-__code doLockLockImpl(struct LockImpl* lock, __code next(...)) {
- struct Atomic* atomic = lock->atomic;
- goto atomic->checkAndSet(&lock->lock, NULL, 1, doLockLockImpl1, doLockLockImpl2);
-}
-
-__code doLockLockImpl1(struct LockImpl* lock, __code next(...)) {
- lock->lockContext = context;
- goto next(...);
-}
-
-__code doLockLockImpl2(struct LockImpl* lock, __code next(...)) {
- struct Queue* queue = lock->waitThreadQueue;
- context->next= C_doLockLockImpl;
- printf("Put task\n");
- goto queue->put(context, doLockLockImpl3);
-}
-
-__code doLockLockImpl3(struct LockImpl* lock, struct Worker* worker, __code next(...)) {
- goto worker->taskReceive(); // goto shceduler
-}
-
-__code doLockLockImpl3_stub(struct Context* context) {
- // switch worker context
- struct Context* workerContext = context->worker->worker->CPUWorker.context;
- LockImpl* lockImpl = (LockImpl*)GearImpl(context, Lock, lock);
- goto doLockLockImpl3(workerContext,
- lockImpl,
- context->worker,
- Gearef(context, Lock)->next);
-}
-
-__code doUnlockLockImpl(struct LockImpl* lock, __code next(...)) {
- if (lock->lockContext == context) {
- struct Atomic* atomic = lock->atomic;
- goto atomic->checkAndSet(&lock->lock, 1, NULL, doUnlockLockImpl1, doUnlockLockImpl);
- }
- goto next(...);
-}
-
-__code doUnlockLockImpl1(struct LockImpl* lock, __code next(...)) {
- struct Queue* queue = lock->waitThreadQueue;
- goto queue->isEmpty(doUnlockLockImpl2, doUnlockLockImpl4);
-}
-
-__code doUnlockLockImpl2(struct LockImpl* lock, __code next(...)) {
- struct Queue* queue = lock->waitThreadQueue;
- printf("%p: Take task\n", lock);
- goto queue->take(doUnlockLockImpl3);
-}
-
-__code doUnlockLockImpl3(struct LockImpl* lock, struct Context* waitTask, __code next(...)) {
- struct TaskManager* taskManager = waitTask->taskManager;
- goto taskManager->spawn(waitTask, next(...)); //notify
-}
-
-__code doUnlockLockImpl3_stub(struct Context* context) {
- LockImpl* lockImpl = (LockImpl*)GearImpl(context, Lock, lock);
- struct Context* waitTask = &Gearef(context, Queue)->data->Context;
- goto doUnlockLockImpl3(context,
- lockImpl,
- waitTask,
- Gearef(context, Lock)->next);
-}
-
-__code doUnlockLockImpl4(struct LockImpl* lock, __code next(...)) {
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/MultiDimIterator.cbc
--- a/src/parallel_execution/MultiDimIterator.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-#include "../context.h"
-#interface "Iterator.h"
-#interface "TaskManager.h"
-#include
-
-Iterator* createMultiDimIterator(struct Context* context, int x, int y, int z) {
- struct Iterator* iterator = new Iterator();
- struct MultiDimIterator* multiDimIterator = new MultiDimIterator();
- iterator->iterator = (union Data*)multiDimIterator;
- iterator->exec = C_execMultiDimIterator;
- iterator->barrier = C_barrierMultiDimIterator;
- multiDimIterator->x = x;
- multiDimIterator->y = y;
- multiDimIterator->z = z;
- multiDimIterator->count = x * y * z;
- multiDimIterator->counterX = 0;
- multiDimIterator->counterY = 0;
- multiDimIterator->counterZ = 0;
- return iterator;
-}
-
-/**
- * create iterateTask with index, that copy from task argument
- * @return created iterateTask
- * @param task task of the copy source
- * @x index
- */
-struct Context* createMultiDimIterateTask(struct Context* task, int x, int y, int z) {
- struct Context* task1 = NEW(struct Context);
- initContext(task1);
- task1->taskManager = task->taskManager;
- task1->next = task->next;
- task1->iterate = 1;
- task1->iterator = task->iterator;
- task1->idgCount = task->idgCount;
- task1->idg = task->idg;
- task1->maxIdg = task->maxIdg;
- for(int i = task1->idg; i < task1->maxIdg; i++) {
- task1->data[i] = task->data[i];
- }
-
- // create index data gear and register input data to iterate task
- struct MultiDim* multiDim = &ALLOCATE_DATA_GEAR(task1, MultiDim)->MultiDim;
- multiDim->x = x;
- multiDim->y = y;
- multiDim->z = z;
- task1->data[task1->maxIdg++] = (union Data*)multiDim;
- task1->odg = task->odg + 1;
- task1->maxOdg = task->maxOdg + 1;
- for (int i = task1->odg; i < task1->maxOdg; i++) {
- task1->data[i] = task->data[i-1];
- }
-
- return task1;
-}
-
-__code execMultiDimIterator(struct MultiDimIterator* iterator, struct Context* task, int numGPU, __code next(...)) {
- // No GPU device
- if (numGPU == 0) {
- goto meta(context, C_execMultiDimIterator1);
- }
- task->iterate = 1;
- task->gpu = 1;
- struct TaskManager* taskManager = task->taskManager;
- goto taskManager->spawn(task, next(...));
-}
-
-__code execMultiDimIterator1(struct MultiDimIterator* iterator, struct Context* task, __code next(...)) {
- int x = iterator->counterX;
- int y = iterator->counterY;
- int z = iterator->counterZ;
- struct Context* iterateTask = createMultiDimIterateTask(task, x, y, z);
- struct TaskManager* taskManager = task->taskManager;
- goto taskManager->spawn(iterateTask, execMultiDimIterator2);
-}
-
-__code execMultiDimIterator2(struct MultiDimIterator* iterator, struct Context* task, __code next(...)) {
- if (++iterator->counterX >= iterator->x) {
- iterator->counterX = 0;
- if (++iterator->counterY >= iterator->y) {
- iterator->counterY = 0;
- if (++iterator->counterZ >= iterator->z) {
- iterator->counterZ = 0;
- goto next(...);
- }
- }
- }
- goto meta(context, C_execMultiDimIterator1);
-}
-
-__code barrierMultiDimIterator(struct MultiDimIterator* iterator, struct Context* task, __code next(...), __code whenWait(...)) {
- if (task->gpu || __sync_fetch_and_sub(&iterator->count, 1) == 1) {
- goto next(...);
- }
- goto whenWait(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Queue.h
--- a/src/parallel_execution/Queue.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-typedef struct Queue{
- union Data* queue;
- union Data* data;
- __code whenEmpty(...);
- __code clear(Impl* queue, __code next(...));
- __code put(Impl* queue, union Data* data, __code next(...));
- __code take(Impl* queue, __code next(union Data*, ...));
- __code isEmpty(Impl* queue, __code next(...), __code whenEmpty(...));
- __code next(...);
-} Queue;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/RedBlackTree.agda
--- a/src/parallel_execution/RedBlackTree.agda Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-module RedBlackTree where
-
-open import stack
-open import Level
-
-record TreeMethods {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
- field
- putImpl : treeImpl -> a -> (treeImpl -> t) -> t
- getImpl : treeImpl -> (treeImpl -> Maybe a -> t) -> t
-open TreeMethods
-
-record Tree {n m : Level } {a : Set n } {t : Set m } (treeImpl : Set n ) : Set (m Level.⊔ n) where
- field
- tree : treeImpl
- treeMethods : TreeMethods {n} {m} {a} {t} treeImpl
- putTree : a -> (Tree treeImpl -> t) -> t
- putTree d next = putImpl (treeMethods ) tree d (\t1 -> next (record {tree = t1 ; treeMethods = treeMethods} ))
- getTree : (Tree treeImpl -> Maybe a -> t) -> t
- getTree next = getImpl (treeMethods ) tree (\t1 d -> next (record {tree = t1 ; treeMethods = treeMethods} ) d )
-
-open Tree
-
-data Color {n : Level } : Set n where
- Red : Color
- Black : Color
-
-data CompareResult {n : Level } : Set n where
- LT : CompareResult
- GT : CompareResult
- EQ : CompareResult
-
-record Node {n : Level } (a k : Set n) : Set n where
- inductive
- field
- key : k
- value : a
- right : Maybe (Node a k)
- left : Maybe (Node a k)
- color : Color {n}
-open Node
-
-record RedBlackTree {n m : Level } {t : Set m} (a k si : Set n) : Set (m Level.⊔ n) where
- field
- root : Maybe (Node a k)
- nodeStack : Stack {n} {m} (Node a k) {t} si
- compare : k -> k -> CompareResult {n}
-
-open RedBlackTree
-
-open Stack
-
---
--- put new node at parent node, and rebuild tree to the top
---
-{-# TERMINATING #-} -- https://agda.readthedocs.io/en/v2.5.3/language/termination-checking.html
-replaceNode : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-replaceNode {n} {m} {t} {a} {k} {si} tree s parent n0 next = popStack s (
- \s grandParent -> replaceNode1 s grandParent ( compare tree (key parent) (key n0) ) )
- where
- replaceNode1 : Stack (Node a k) si -> Maybe ( Node a k ) -> CompareResult -> t
- replaceNode1 s Nothing LT = next ( record tree { root = Just ( record parent { left = Just n0 ; color = Black } ) } )
- replaceNode1 s Nothing GT = next ( record tree { root = Just ( record parent { right = Just n0 ; color = Black } ) } )
- replaceNode1 s Nothing EQ = next ( record tree { root = Just ( record parent { right = Just n0 ; color = Black } ) } )
- replaceNode1 s (Just grandParent) result with result
- ... | LT = replaceNode tree s grandParent ( record parent { left = Just n0 } ) next
- ... | GT = replaceNode tree s grandParent ( record parent { right = Just n0 } ) next
- ... | EQ = next tree
-
-rotateRight : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-rotateRight {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
-
-rotateLeft : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-rotateLeft {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
-
-insertCase5 : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-insertCase5 {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
-
-insertCase4 : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> Node a k -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-insertCase4 {n} {m} {t} {a} {k} {si} tree s n0 parent grandParent next = {!!}
-
-{-# TERMINATING #-}
-insertNode : {n m : Level } {t : Set m } {a k si : Set n} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) {t} si -> Node a k -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-insertNode {n} {m} {t} {a} {k} {si} tree s n0 next = get2Stack s (\ s d1 d2 -> insertCase1 s n0 d1 d2 )
- where
- insertCase1 : Stack (Node a k) si -> Node a k -> Maybe (Node a k) -> Maybe (Node a k) -> t -- placed here to allow mutual recursion
- -- http://agda.readthedocs.io/en/v2.5.2/language/mutual-recursion.html
- insertCase3 : Stack (Node a k) si -> Node a k -> Node a k -> Node a k -> t
- insertCase3 s n0 parent grandParent with left grandParent | right grandParent
- ... | Nothing | Nothing = insertCase4 tree s n0 parent grandParent next
- ... | Nothing | Just uncle = insertCase4 tree s n0 parent grandParent next
- ... | Just uncle | _ with compare tree ( key uncle ) ( key parent )
- ... | EQ = insertCase4 tree s n0 parent grandParent next
- ... | _ with color uncle
- ... | Red = pop2Stack s ( \s p0 p1 -> insertCase1 s (
- record grandParent { color = Red ; left = Just ( record parent { color = Black ; left = Just n0 } ) ; right = Just ( record uncle { color = Black } ) }) p0 p1 )
- ... | Black = insertCase4 tree s n0 parent grandParent next
- insertCase2 : Stack (Node a k) si -> Node a k -> Node a k -> Node a k -> t
- insertCase2 s n0 parent grandParent with color parent
- ... | Black = replaceNode tree s grandParent n0 next
- ... | Red = insertCase3 s n0 parent grandParent
- insertCase1 s n0 Nothing Nothing = next tree
- insertCase1 s n0 Nothing (Just grandParent) = replaceNode tree s grandParent n0 next
- insertCase1 s n0 (Just grandParent) Nothing = replaceNode tree s grandParent n0 next
- insertCase1 s n0 (Just parent) (Just grandParent) = insertCase2 s n0 parent grandParent
- where
-
-findNode : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> (Node a k) -> (Node a k) -> (RedBlackTree {n} {m} {t} a k si -> Stack (Node a k) si -> Node a k -> t) -> t
-findNode {n} {m} {a} {k} {si} {t} tree s n0 n1 next = pushStack s n1 (\ s -> findNode1 s n1)
- where
- findNode2 : Stack (Node a k) si -> (Maybe (Node a k)) -> t
- findNode2 s Nothing = next tree s n0
- findNode2 s (Just n) = findNode tree s n0 n next
- findNode1 : Stack (Node a k) si -> (Node a k) -> t
- findNode1 s n1 with (compare tree (key n0) (key n1))
- ... | EQ = next tree s n0
- ... | GT = findNode2 s (right n1)
- ... | LT = findNode2 s (left n1)
-
-
-leafNode : {n : Level } {a k : Set n} -> k -> a -> Node a k
-leafNode k1 value = record {
- key = k1 ;
- value = value ;
- right = Nothing ;
- left = Nothing ;
- color = Black
- }
-
-putRedBlackTree : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> k -> a -> (RedBlackTree {n} {m} {t} a k si -> t) -> t
-putRedBlackTree {n} {m} {a} {k} {si} {t} tree k1 value next with (root tree)
-... | Nothing = next (record tree {root = Just (leafNode k1 value) })
-... | Just n2 = findNode tree (nodeStack tree) (leafNode k1 value) n2 (\ tree1 s n1 -> insertNode tree1 s n1 next)
-
-getRedBlackTree : {n m : Level } {a k si : Set n} {t : Set m} -> RedBlackTree {n} {m} {t} a k si -> k -> (RedBlackTree {n} {m} {t} a k si -> (Maybe (Node a k)) -> t) -> t
-getRedBlackTree {_} {_} {a} {k} {_} {t} tree k1 cs = checkNode (root tree)
- where
- checkNode : Maybe (Node a k) -> t
- checkNode Nothing = cs tree Nothing
- checkNode (Just n) = search n
- where
- search : Node a k -> t
- search n with compare tree k1 (key n)
- search n | LT = checkNode (left n)
- search n | GT = checkNode (right n)
- search n | EQ = cs tree (Just n)
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/RedBlackTree.cbc
--- a/src/parallel_execution/RedBlackTree.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,597 +0,0 @@
-#include
-
-#include "../context.h"
-#interface "Tree.h"
-#interface "Stack.h"
-#include "compare.c"
-
-extern enum Relational compare(struct Node* node1, struct Node* node2);
-
-Tree* createRedBlackTree(struct Context* context) {
- struct Tree* tree = new Tree();
- struct RedBlackTree* redBlackTree = new RedBlackTree();
- tree->tree = (union Data*)redBlackTree;
- redBlackTree->root = NULL;
- redBlackTree->nodeStack = createSingleLinkedStack(context);
- tree->put = C_putRedBlackTree;
- tree->get = C_getRedBlackTree;
- tree->remove = C_removeRedBlackTree;
- // tree->clear = C_clearRedBlackTree;
- return tree;
-}
-
-void printTree1(union Data* data) {
- struct Node* node = &data->Node;
- if (node == NULL) {
- printf("NULL");
- } else {
- printf("key = %d (", node->key);
- printTree1((union Data*)(node->right));
- printf("), (");
- printTree1((union Data*)(node->left));
- printf(")");
- }
-}
-
-void printTree(union Data* data) {
- printTree1(data);
- printf("\n");
-}
-
-__code putRedBlackTree(struct RedBlackTree* tree, struct Node* node) {
- struct Node* newNode = &ALLOCATE(context, Node)->Node;
- struct Node* root = tree->root;
- printTree((union Data*)(tree->root));
- tree->newNode = newNode;
- tree->root = newNode; // this should done at stackClear
- tree->parent = NULL;
- if (root) {
- tree->current = root;
- tree->result = compare(tree->current, node);
- tree->findNodeNext = C_insertNode;
- goto findNode(tree);
- }
- goto insertNode(tree, node);
-}
-
-__code findNode(struct RedBlackTree* tree) {
- struct Stack* nodeStack = tree->nodeStack;
- struct Node* oldNode = tree->current;
- struct Node* newNode = tree->newNode;
- tree->previous = newNode;
- *newNode = *oldNode;
- goto nodeStack->push((union Data*)newNode, findNode1);
-}
-
-__code findNode1(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
- struct Node* oldNode = tree->current;
- struct Node* newNode = tree->previous;
- struct Node* newnewNode = &ALLOCATE(context, Node)->Node;
- int result = tree->result;
- if (result == EQ) {
- newNode->value = node->value;
- // go to stack clear
- goto next(...);
- } else if (result == GT) {
- tree->current = oldNode->right;
- newNode->right = newnewNode;
- } else {
- tree->current = oldNode->left;
- newNode->left = newnewNode;
- }
- tree->newNode = newnewNode;
- if (tree->current) {
- tree->result = compare(tree->current, node);
- goto findNode(tree);
- }
- goto meta(context, tree->findNodeNext);
- // gato tree->findNodeNext(tree, node);
-
-}
-
-__code insertNode(struct RedBlackTree* tree, struct Node* node) {
- struct Stack* nodeStack = tree->nodeStack;
- struct Node* newNode = tree->newNode;
- *newNode = *node;
- newNode->color = Red;
- tree->current = newNode;
- goto nodeStack->get2(insertCase1);
-}
-
-__code insertCase1(struct RedBlackTree* tree, struct Node *parent, struct Node *grandparent) {
- if (parent != NULL) {
- tree->parent = parent;
- tree->grandparent = grandparent;
- goto insertCase2(tree);
- }
- tree->root->color = Black;
- goto stackClear();
-}
-
-__code insertCase1_stub(struct Context* context) {
- goto insertCase1(context,
- &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree,
- &context->data[D_Stack]->Stack.data->Node,
- &context->data[D_Stack]->Stack.data1->Node);
-}
-
-__code insertCase2(struct RedBlackTree* tree) {
- if (tree->parent->color == Black) {
- goto stackClear();
- }
- goto insertCase3(tree);
-}
-
-__code insertCase3(struct RedBlackTree* tree) {
- struct Stack* nodeStack = tree->nodeStack;
- struct Node* uncle;
-
- if (tree->grandparent->left == tree->parent)
- uncle = tree->grandparent->right;
- else
- uncle = tree->grandparent->left;
-
- if (uncle && (uncle->color == Red)) {
- // do insertcase1 on grandparent, stack must be pop by two
- tree->parent->color = Black;
- uncle->color = Black;
- tree->grandparent->color = Red;
- tree->current = tree->grandparent;
- goto nodeStack->pop2(insertCase1);
- }
- goto insertCase4();
-}
-
-__code insertCase4(struct RedBlackTree* tree, struct RotateTree* rotateTree) {
- struct Stack* nodeStack = tree->nodeStack;
-
- if ((tree->current == tree->parent->right) && (tree->parent == tree->grandparent->left)) {
- tree->current = tree->current->left;
- tree->parent = tree->grandparent;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_insertCase5;
-
- goto nodeStack->pop(rotateLeft);
- } else if ((tree->current == tree->parent->left) && (tree->parent == tree->grandparent->right)) {
- tree->parent = tree->grandparent;
- tree->current = tree->current->right;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_insertCase5;
-
- goto nodeStack->pop(rotateRight);
- }
-
- goto insertCase5();
-}
-
-__code insertCase5(struct RedBlackTree* tree) {
- struct Stack* nodeStack = tree->nodeStack;
- goto nodeStack->pop2(insertCase51);
-}
-
-__code insertCase51(struct RedBlackTree* tree, struct RotateTree* rotateTree, struct Node* parent, struct Node* grandparent) {
- struct Node* current = tree->current;
- tree->parent = parent;
- tree->grandparent = grandparent;
-
- parent->color = Black;
- grandparent->color = Red;
-
- tree->current = grandparent;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_stackClear;
-
- if ((current == parent->left) && (parent == grandparent->left))
- goto rotateRight();
- else
- goto rotateLeft();
-}
-
-__code insertCase51_stub(struct Context* context) {
- struct Node* parent = &context->data[D_Stack]->Stack.data->Node;
- struct Node* grandparent = &context->data[D_Stack]->Stack.data1->Node;
- goto insertCase51(context,
- &Gearef(context, Tree)->tree->Tree.tree->RedBlackTree,
- Gearef(context, RotateTree),
- parent,
- grandparent);
-}
-
-__code rotateLeft(struct RedBlackTree* tree) {
- struct Stack* nodeStack = tree->nodeStack;
- goto nodeStack->get(rotateLeft1);
-}
-
-__code rotateLeft_stub(struct Context* context) {
- struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
- goto rotateLeft(context, traverse);
-}
-
-__code rotateLeft1(struct Node* node, struct RedBlackTree* tree, struct Node* parent, struct RotateTree* rotateTree) {
- struct Node* tmp = node->right;
-
- if (parent) {
- if (node == parent->left)
- parent->left = tmp;
- else
- parent->right = tmp;
- } else {
- tree->root = tmp;
- }
-
- node->right = tmp->left;
- tmp->left = node;
- tree->current = tmp;
-
- goto meta(context, rotateTree->next);
-}
-
-__code rotateLeft1_stub(struct Context* context) {
- struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
- struct Node* parent = &context->data[D_Stack]->Stack.data->Node;
- goto rotateLeft1(context,
- traverse->current,
- traverse,
- parent,
- Gearef(context, RotateTree));
-}
-
-__code rotateRight(struct RedBlackTree* tree) {
- struct Stack* nodeStack = tree->nodeStack;
- goto nodeStack->get(rotateRight1);
-}
-
-__code rotateRight_stub(struct Context* context) {
- struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
- goto rotateLeft(context, traverse);
-}
-
-__code rotateRight1(struct Node* node, struct RedBlackTree* traverse,struct Node *parent,struct RotateTree *rotateTree) {
- struct Node* tmp = node->left;
-
- if (parent) {
- if (node == parent->left)
- parent->left = tmp;
- else
- parent->right = tmp;
- } else {
- traverse->root = tmp;
- }
-
- node->left = tmp->right;
- tmp->right = node;
- traverse->current = tmp;
-
- goto meta(context, rotateTree->next);
-}
-
-__code rotateRight1_stub(struct Context* context) {
- struct RedBlackTree* traverse = context->data[D_RotateTree]->RotateTree.traverse;
- struct Node* parent = &context->data[D_Stack]->Stack.data->Node;
- goto rotateRight1(context,
- traverse->current,
- traverse,
- parent,
- Gearef(context, RotateTree));
-}
-
-__code stackClear(struct RedBlackTree* tree, struct Stack* nodeStack, __code next(...)) {
- tree->current = 0;
- nodeStack->stack = (union Data*)tree->nodeStack;
- nodeStack->next = next;
- goto meta(context, tree->nodeStack->clear);
-}
-
-__code getRedBlackTree(struct RedBlackTree* tree, __code next(...)) {
- if (tree->root) {
- tree->current = tree->root;
-
- goto search();
- }
-
- goto next(...);
-}
-
-__code search(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
- // compare(context, traverse, traverse->current->key, node->key);
- tree->result = compare(tree->current, node);
- if (tree->result == EQ) {
- *node = *tree->current;
-
- goto meta(context, next);
- } else if (tree->result == GT) {
- tree->current = tree->current->right;
- } else {
- tree->current = tree->current->left;
- }
-
- if (tree->current)
- goto meta(context, C_search);
-
- goto next(...);
-}
-
-
-__code removeRedBlackTree(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
- struct Node* newNode = &ALLOCATE(context, Node)->Node;
- struct Node* root = tree->root;
- printTree((union Data*)(tree->root));
- tree->newNode = newNode;
- tree->root = newNode; // this should done at stackClear
- tree->parent = NULL;
- if (root) {
- tree->current = root;
- tree->result = compare(tree->current, node);
- tree->findNodeNext = C_replaceNodeForDelete2;
- goto findNode(tree);
- }
- goto next(...);
-}
-
-
-
-__code delete2(struct Node* current) {
- if (current->color == Black) {
- struct Node* child = current->right == NULL ? current->left : current->right;
- current->color = child == NULL ? Black : child->color;
-
- goto deleteCase1(current);
- }
-
- goto delete3(tree, current);
-}
-
-
-
-__code delete3(struct RedBlackTree* tree, struct Node* current, __code next(...)) {
- struct Node* tmp = current->right == NULL ? current->left : current->right;
- struct Stack* nodeStack = tree->nodeStack;
-
- if (tree->parent) {
- if (current == tree->parent->left)
- tree->parent->left = tmp;
- else
- tree->parent->right = tmp;
- } else {
- tree->root = tmp;
- }
-
-
- if (tree->parent == NULL && tmp)
- tmp->color = Black;
-
- current == tree->parent->left ? (tree->parent->left = NULL) : (tree->parent->right = NULL);
-
- Gearef(context, Stack)->stack = (union Data*) nodeStack;
- Gearef(context, Stack)->next = next;
- goto meta(context, nodeStack->pop);
-
-// gato nodeStack->pop(next);
-}
-
-
-
-__code replaceNodeForDelete2(struct RedBlackTree* tree, struct Node* newNode) {
- if (tree->current->left && tree->current->right) {
- tree->parent = newNode;
- tree->current = newNode->left;
- newNode->left = context->heap;
-
-
- tree->parent = newNode;
-
- goto findMax1(tree,oldNode, newNode);
- }
-
- goto delete2(current);
-}
-
-
-__code findMax1(struct RedBlackTree* tree, struct Node* oldNode, struct Node* newNode) {
- *newNode = *oldNode;
-
- if (newNode->right)
- goto findMax2(tree, oldNode, newNode);
-
- tree->current = newNode;
-
- goto delete2(current);
-}
-
-
-
-
-__code findMax2(struct RedBlackTree* tree, struct Node* oldNode, struct Node* newNode) {
- *newNode = *oldNode;
-
- if (newNode->right->right) {
- tree->current = newNode->right;
- newNode->right = context->heap;
-
- tree->parent = newNode;
-
- goto findMax2(tree, oldNode, newNode);
- }
-
- tree->current = newNode;
-
- goto delete2(tree,current);
-}
-
-
-__code deleteCase1(struct RedBlackTree* tree, struct Node* current) {
- if (tree->parent)
- goto deleteCase2(tree,current);
-
- goto delete3(tree, current);
-}
-
-
-
-__code deleteCase2(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
- struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
- struct Stack* nodeStack = tree->nodeStack;
-
- if ((sibling == NULL ? Black : sibling->color) == Red) {
- tree->parent->color = Red;
- sibling->color = Black;
-
- current == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
-
- struct Node* node = sibling;
-
- tree->current = tree->parent;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_deleteCase3;
-
- if (current == tree->parent->left) {
- goto nodeStack->push((union Data*)node,rotateLeft);
- } else {
- goto nodeStack->push((union Data*)node,rotateRight);
- }
-
- goto deleteCase3(tree,current);
- }
-}
-
-
-
-__code deleteCase3(struct RedBlackTree* tree, struct Node* current) {
- struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
-
- if (tree->parent->color == Black &&
- (sibling == NULL ? Black : sibling->color) == Black &&
- (sibling->left == NULL ? Black : sibling->left->color) == Black &&
- (sibling->right == NULL ? Black : sibling->right->color) == Black) {
- sibling->color = Red;
-
- tree->current = tree->parent;
- goto deleteCase1(current);
- }
-
- goto deleteCase4(current);
-}
-
-
-
-__code deleteCase4(struct RedBlackTree* tree,struct Node* current) {
- struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
-
- if (tree->parent->color == Red &&
- (sibling == NULL ? Black : sibling->color) == Black &&
- (sibling->left == NULL ? Black : sibling->left->color) == Black &&
- (sibling->right == NULL ? Black : sibling->right->color) == Black) {
- sibling->color = Red;
- tree->parent->color = Black;
-
- goto delete3(tree,current);
- }
-
- goto deleteCase5(tree,current);
-}
-
-
-
-__code deleteCase5(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
- struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
- struct Stack* nodeStack = tree->nodeStack;
- // sibling->parent = tree->parent;
-
- if (current == tree->parent->left &&
- (sibling == NULL ? Black : sibling->color) == Black &&
- (sibling->left == NULL ? Black : sibling->left->color) == Red &&
- (sibling->right == NULL ? Black : sibling->right->color) == Black) {
- sibling->color = Red;
- sibling->left->color = Black;
-
- // sibling == sibling->parent->left ? (sibling->parent->left = context->heap) : (sibling->parent->right = context->heap);
- sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
-
- struct Node* node = new Node();
- node = sibling->left;
-
- struct Node* tmp = node;
- *tmp = *sibling;
- tree->parent = current;
-
- tmp->left = context->heap;
-/* struct Node* node = new Node(); */
-/* node = *sibling->left; */
- tree->parent = tmp;
-
- tree->current = tmp;
-
-
- rotateTree->traverse = tree;
- rotateTree->next = C_deleteCase6;
-
- goto nodeStack->push((union Data*)node,rotateRight);
- } else if (current == tree->parent->right &&
- (sibling == NULL ? Black : sibling->color) == Black &&
- (sibling->left == NULL ? Black : sibling->left->color) == Black &&
- (sibling->right == NULL ? Black : sibling->right->color) == Red) {
- sibling->color = Red;
- sibling->right->color = Black;
-
- sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
-
- struct Node* node = new Node();
- node = sibling->right;
-
- struct Node* tmp = node;
- *tmp = *sibling;
- // tmp->parent = current;
-
- tmp->right = context->heap;
-/* struct Node* node = new Node(); */
-/* node = *sibling->right; */
- //node->parent = tmp;
-
- tree->current = tmp;
-
-
- rotateTree->traverse = tree;
- rotateTree->next = C_deleteCase6;
-
- goto nodeStack->push((union Data*)node,rotateLeft);
- }
-
- goto deleteCase6(tree,current);
-}
-
-
-__code deleteCase6(struct RedBlackTree* tree, struct Node* current, struct RotateTree* rotateTree) {
- struct Node* sibling = current == tree->parent->left ? tree->parent->right : tree->parent->left;
- struct Stack* nodeStack = tree->nodeStack;
- sibling == tree->parent->left ? (tree->parent->left = context->heap) : (tree->parent->right = context->heap);
-
- struct Node* tmp = sibling;
- // *tmp = *sibling;
- tree->parent = current;
-
- tmp->color = tree->parent->color;
- tree->parent->color = Black;
-
-
- if (current == tree->parent->left) {
- tmp->right->color = Black;
- tree->current = tree->parent;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_delete3;
-
- goto nodeStack->push((union Data*)tmp,rotateLeft);
- } else {
- tmp->left->color = Black;
- tree->current = tree->parent;
-
- rotateTree->traverse = tree;
- rotateTree->next = C_delete3;
-
- goto nodeStack->push((union Data*)tmp,rotateLeft);
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/RedBlackTreeReWright.cbc
--- a/src/parallel_execution/RedBlackTreeReWright.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,269 +0,0 @@
-#include
-
-#include "../context.h"
-#include "../compare.c"
-#interface "Tree.h"
-#interface "Stack.h"
-
-extern enum Relational compare(struct Node* node1, struct Node* node2);
-
-
-Tree* createRedBlackTree(struct Context* context) {
- struct Tree* tree = new Tree();
- struct RedBlackTree* rbtree = new RedBlackTree();
-
- tree->tree = (union Data*)rbtree;
- rbtree->root = NULL;
- rbtree->nodeStack = (union Data*)createSingleLinkedStack(context);
- tree->put = C_putRedBlackTree;
- // tree->get = C_getRedBlackTree;
- // tree->remove = C_removeRedBlackTree;
- // tree->clear = C_clearRedBlackTree;
- return tree;
-}
-
-void printNode(struct Node* node) {
- if (node == NULL) {
- printf("leaf");
- } else {
- printf("((%d,%d (",node->color, node->key);
- printNode(node->right);
- printf(") (");
- printNode(node->left);
- printf(")");
- }
-}
-
-void printTree(struct RedBlackTree* tree) {
- printf("\n");
- tree->current = tree->root;
- printNode(tree->current);
- printf(")\n");
-}
-
-__code putRedBlackTree(struct RedBlackTree* tree, struct Node* node, __code next(...)) {
- printf("C_putRedBlackTree\n");
- printf("value->%d,key->%d \n",node->value,node->key);
- tree->previous = tree->newNode;
- tree->newNode = node;
- tree->newNode->color = Red;
- tree->current = tree->root;
- goto insertRBTree(node, tree);
-}
-
-__code stackClear(struct RedBlackTree* tree, struct Stack* nodeStack, __code next(...)) {
- tree->current = 0;
- nodeStack->stack = tree->nodeStack;
- nodeStack->next = next;
- goto meta(context, tree->nodeStack->clear);
- }
-
-__code getRedBlackTree(struct RedBlackTree* tree, __code next(...)) {
- if (tree->root) {
- tree->current = tree->root;
- goto insertRBTree();
- // goto deleteRBTree();
- }
- goto next(...);
-}
-
-__code insertRBTree(struct Node* node, struct RedBlackTree* tree, struct Stack* stack, __code next(...)) {
- // first case tree->current = root;
- printf("C_insertRBTree\n");
- printf("value->%d,key->%d\n",node->value,node->key);
- printf("newNode value->%d,newNode key->%d\n",tree->newNode->value,tree->newNode->key);
-
- if (tree->root == NULL) {
- printf("insertRBTree_root eq NULL\n");
- tree->root = tree->newNode;
- tree->root->color = Black;
- printf("tree->root->key = %d, tree->root->color = %d \n",tree->root->key,tree->root->color);
- printTree(tree);
- goto next(tree,...);
- } else {
- goto searchInsertLocation(node, tree, stack);
- }
-}
-
-__code insertRBTree_stub(struct Context* context) {
- Node* node = Gearef(context, Tree)->node;
- RedBlackTree* tree = (RedBlackTree*)GearImpl(context, Tree, tree);
- Stack* stack = createSingleLinkedStack(context);
- enum Code next = Gearef(context, Tree)->next;
- goto insertRBTree(context, node, tree, stack, next);
-}
-
-__code searchInsertLocation(struct Node* node, struct RedBlackTree* tree) {
- // first case tree->current = root; PreCase remove root=NULL case.don't exist firstCase tree->current=NULL
- printf("C_searchInsertLocation\n");
- printf("nownode->key %d , previous->key %d \n",tree->newNode->key,tree->previous->key);
-
- tree->result = compare(tree->current, node);
- printf("tree->current->key = %d, node->key %d\n",tree->current->key,node->key);
- printf("compare (%d,%d)\n",tree->current,node);
-
- Stack* stack = tree->nodeStack;
-
- if (tree->current == NULL) {
- printf("goto insertLocationBackInsert stack->pop\n");
- goto stack->pop(insertLocationBackInsert);
- }
- if (tree->result == GT) {
- printf("GT searchInsertLocation\n");
- tree->current = tree->current->right;
- goto stack->push(tree->newNode,insertLocationBackInsert);
- } else if (tree->result == LT) {
- printf("LT searchInsertLocation\n");
- tree->current = tree->current->left;
- goto stack->push(tree->newNode, searchInsertLocation);
- } else if (tree->result == EQ) {
- printf("already member this node : __code searchInsertLocation()\n");
- goto meta(context, C_exit_code);
- } else {
- printf("$insert value tree : __code searchInsertLocation() \n");
- goto meta(context, C_exit_code);
- }
-}
-
-__code searchInsertLocation_stub(struct Context* context) {
- Node* node = Gearef(context, Tree)->node;
- RedBlackTree* tree = (RedBlackTree*)GearImpl(context, Tree, tree);
- Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
- goto searchInsertLocation(context, node, tree);
-}
-
-__code insertLocationBackInsert(struct RedBlackTree* tree, struct Node* node, struct Stack* stack) {
- printf("C_insertLocationBackInsert\n");
- struct Node* hoge = stack->data;
- printf("stackpopdata%d\n",stack->data);
- tree->current = tree->previous;
- // tree->current = nodeStack->data;
- // this CS is ones only backTrace, and insert node
- tree->result = compare(tree->previous,tree->newNode);
- printf("back,compare\n");
- if (tree->result == GT) {
- printf("GT\n");
- tree->current->right = tree->newNode;
- printTree(tree);
- goto insertBalance(tree, stack, node, next);
- } else if (tree->result == LT) {
- printf("LT\n");
- tree->current->left = tree->newNode;
- goto insertBalance(tree, stack, node, next);
- } else {
- printf("error : __code insertLocationBackTrace() \n");
- goto meta(context, C_exit_code);
- }
-}
-
-__code insertLocationBackInsert_stub(struct Context* context) {
- RedBlackTree* tree = (RedBlackTree*)GearImpl(context, Tree, tree);
- SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
- Node* node = Gearef(context, Tree)->node;
- Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
- goto insertLocationBackInsert(context, tree, node, stack);
-}
-
-__code insertBalance(struct RedBlackTree* tree, struct Node* nodeStack, struct Node* node, __code next(...)) {
- printf("C_insertBalance\n");
- struct Node* traceNode = tree->nodeStack->data;
- tree->current = traceNode;
- struct Stack* stack = tree->nodeStack;
-
- // exit insertion code
- if (tree->current == tree->root) {
- tree->current->color = Black;
- printTree(tree);
- //printTree
- goto next(tree,...);
- }
-
-
- //current color eq Red
- if (tree->current->color == Red)
- goto stack->pop(insertBalance);
-
- // current color eq Black
- if (tree->current->left->left || tree->current->left->right) {
- goto insertBalanceLeft(tree,nodeStack);
- } else if (tree->current->right->left || tree->current->right->right) {
- goto insertBalanceRight(tree,nodeStack);
- } else {
- goto stack->pop(insertBalance);
- }
-}
-
-__code insertBalanceLeft(struct RedBlackTree* tree, struct Node* nodeStack, struct Node* node) {
- printf("C_insertBalanceLeft\n");
- struct Stack* stack = tree->nodeStack;
-
- if (tree->current->color == Black && tree->current->left->color == Red && tree->current->left->left->color == Red) {
- struct Node* tmpCurrent = tree->current;
- struct Node* tmpLeft = tree->current->left;
- struct Node* tmpLeftLeft = tree->current->left->left;
-
- tree->current = tmpLeft;
- tree->current->right = tmpCurrent;
- tree->current->left = tmpLeftLeft;
- tree->current->right->left = tmpLeft->right;
- tree->current->color = Red;
- tree->current->left->color = Black;
- tree->current->right->color = Black;
- goto stack->pop(insertBalance);
-
- } else if(tree->current->color == Black && tree->current->left->color == Red && tree->current->left->right->color == Red) {
- struct Node* tmpCurrent = tree->current;
- struct Node* tmpLeft = tree->current->left;
- struct Node* tmpLeftRight = tree->current->left->right;
-
- tree->current = tmpLeft;
- tree->current->right = tmpCurrent;
- tree->current->left = tmpLeftRight;
- tree->current->right->left = tmpLeft->left;
- tree->current->color = Red;
- tree->current->left->color = Black;
- tree->current->right->color = Black;
- goto stack->pop(insertBalance);
-
- }
-}
-
-__code insertBalanceRight(struct RedBlackTree* tree, struct Node* nodeStack, struct Node* node) {
- printf("C_insertBalanceLeft\n");
- struct Stack* stack = tree->nodeStack;
-
- if (tree->current->color == Black && tree->current->right->color == Red && tree->current->right->right->color == Red) {
- struct Node* tmpCurrent = tree->current;
- struct Node* tmpRight = tree->current->right;
- struct Node* tmpRightRight = tree->current->right->right;
-
- tree->current = tmpRight;
- tree->current->left = tmpCurrent;
- tree->current->right = tmpRightRight;
- tree->current->left->right = tmpRight->left;
- tree->current->color = Red;
- tree->current->left->color = Black;
- tree->current->right->color = Black;
- goto stack->pop(insertBalance);
-
- } else if (tree->current->color == Black && tree->current->right->color == Red && tree->current->right->left->color == Red) {
-
- struct Node* tmpCurrent = tree->current;
- struct Node* tmpRight = tree->current->right;
- struct Node* tmpRightLeft = tree->current->right->left;
-
- tree->current = tmpRight;
- tree->current->right = tmpCurrent;
- tree->current->left = tmpRightLeft;
- tree->current->left->right = tmpRight->right;
- tree->current->color = Red;
- tree->current->left->color = Black;
- tree->current->right->color = Black;
- goto stack->pop(insertBalance);
-
- } else {
- printf("unkwon error : __code insertBalanceRight() \n");
- goto meta(context, C_exit_code);
- }
-}
-// insertCode end
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Semaphore.h
--- a/src/parallel_execution/Semaphore.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-typedef struct Semaphore{
- union Data* semaphore;
- __code p(Impl* semaphore, __code next(...));
- __code v(Impl* semaphore, __code next(...));
- __code next(...);
-} Semaphore;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/SemaphoreImpl.cbc
--- a/src/parallel_execution/SemaphoreImpl.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#include "../context.h"
-#interface "semaphore.h"
-
-Semaphore* createSemaphoreImpl(struct Context* context, int n) {
- struct Semaphore* semaphore = new Semaphore();
- struct SemaphoreImpl* semaphoreImpl = new SemaphoreImpl();
- semaphore->semaphore = (union Data*)semaphoreImpl;
- semaphoreImpl->value = n;
- pthread_mutex_init(&semaphoreImpl->mutex, NULL);
- pthread_cond_init(&semaphoreImpl->cond, NULL);
- semaphore->p = C_pOperationSemaphoreImpl;
- semaphore->v = C_vOperationSemaphoreImpl;
- return semaphore;
-}
-
-__code pOperationSemaphoreImpl(struct SemaphoreImpl* semaphore, __code next(...)) {
- pthread_mutex_lock(&semaphore->mutex);
- goto meta(context, C_pOperationSemaphoreImpl1);
-}
-
-__code pOperationSemaphoreImpl1(struct SemaphoreImpl* semaphore, __code next(...)) {
- if(semaphore->value == 0) {
- pthread_cond_wait(&semaphore->cond, &semaphore->mutex);
- goto meta(context, C_pOperationSemaphoreImpl1);
- }
- semaphore->value--;
- pthread_mutex_unlock(&semaphore->mutex);
- goto next(...);
-}
-
-__code vOperationSemaphoreImpl(struct SemaphoreImpl* semaphore, __code next(...)) {
- pthread_mutex_lock(&semaphore->mutex);
- semaphore->value++;
- pthread_cond_signal(&semaphore->cond);
- pthread_mutex_unlock(&semaphore->mutex);
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/SingleLinkedQueue.cbc
--- a/src/parallel_execution/SingleLinkedQueue.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#include "../context.h"
-#include
-#interface "Queue.h"
-
-Queue* createSingleLinkedQueue(struct Context* context) {
- struct Queue* queue = new Queue();
- struct SingleLinkedQueue* singleLinkedQueue = new SingleLinkedQueue();
- queue->queue = (union Data*)singleLinkedQueue;
- singleLinkedQueue->top = new Element();
- singleLinkedQueue->last = singleLinkedQueue->top;
- queue->take = C_takeSingleLinkedQueue;
- queue->put = C_putSingleLinkedQueue;
- queue->isEmpty = C_isEmptySingleLinkedQueue;
- queue->clear = C_clearSingleLinkedQueue;
- return queue;
-}
-
-void printQueue1(union Data* data) {
- struct Node* node = &data->Element.data->Node;
- if (node == NULL) {
- printf("NULL");
- } else {
- printf("key = %d ,", node->key);
- printQueue1((union Data*)data->Element.next);
- }
-}
-
-void printQueue(union Data* data) {
- printQueue1(data);
- printf("\n");
-}
-
-__code clearSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(...)) {
- queue->top = NULL;
- goto next(...);
-}
-
-__code putSingleLinkedQueue(struct SingleLinkedQueue* queue, union Data* data, __code next(...)) {
- Element* element = new Element();
- element->data = data;
- element->next = NULL;
- queue->last->next = element;
- queue->last = element;
- goto next(...);
-}
-
-__code takeSingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(union Data* data, ...)) {
- struct Element* top = queue->top;
- struct Element* nextElement = top->next;
- if (queue->top == queue->last) {
- data = NULL;
- } else {
- queue->top = nextElement;
- data = nextElement->data;
- }
- goto next(data, ...);
-}
-
-__code isEmptySingleLinkedQueue(struct SingleLinkedQueue* queue, __code next(...), __code whenEmpty(...)) {
- if (queue->top == queue->last)
- goto whenEmpty(...);
- else
- goto next(...);
-}
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/SingleLinkedStack.cbc
--- a/src/parallel_execution/SingleLinkedStack.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#include "../context.h"
-#interface "Stack.h"
-#include
-
-// typedef struct SingleLinkedStack {
-// struct Element* top;
-// } SingleLinkedStack;
-
-Stack* createSingleLinkedStack(struct Context* context) {
- struct Stack* stack = new Stack();
- struct SingleLinkedStack* singleLinkedStack = new SingleLinkedStack();
- stack->stack = (union Data*)singleLinkedStack;
- singleLinkedStack->top = NULL;
- stack->push = C_pushSingleLinkedStack;
- stack->pop = C_popSingleLinkedStack;
- stack->pop2 = C_pop2SingleLinkedStack;
- stack->get = C_getSingleLinkedStack;
- stack->get2 = C_get2SingleLinkedStack;
- stack->isEmpty = C_isEmptySingleLinkedStack;
- stack->clear = C_clearSingleLinkedStack;
- return stack;
-}
-
-void printStack1(union Data* data) {
- struct Node* node = &data->Element.data->Node;
- if (node == NULL) {
- printf("NULL");
- } else {
- printf("key = %d ,", node->key);
- printStack1((union Data*)data->Element.next);
- }
-}
-
-void printStack(union Data* data) {
- printStack1(data);
- printf("\n");
-}
-
-__code clearSingleLinkedStack(struct SingleLinkedStack* stack,__code next(...)) {
- stack->top = NULL;
- goto next(...);
-}
-
-__code pushSingleLinkedStack(struct SingleLinkedStack* stack, union Data* data, __code next(...)) {
- Element* element = new Element();
- element->next = stack->top;
- element->data = data;
- stack->top = element;
- goto next(...);
-}
-
-__code popSingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, ...)) {
- if (stack->top) {
- data = stack->top->data;
- stack->top = stack->top->next;
- } else {
- data = NULL;
- }
- goto next(data, ...);
-}
-
-__code pop2SingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, union Data* data1, ...)) {
- if (stack->top) {
- data = stack->top->data;
- stack->top = stack->top->next;
- } else {
- data = NULL;
- }
- if (stack->top) {
- data1 = stack->top->data;
- stack->top = stack->top->next;
- } else {
- data1 = NULL;
- }
- goto next(data, data1, ...);
-}
-
-
-__code getSingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, ...)) {
- if (stack->top)
- data = stack->top->data;
- else
- data = NULL;
- goto next(data, ...);
-}
-
-__code get2SingleLinkedStack(struct SingleLinkedStack* stack, __code next(union Data* data, union Data* data1, ...)) {
- if (stack->top) {
- data = stack->top->data;
- if (stack->top->next) {
- data1 = stack->top->next->data;
- } else {
- data1 = NULL;
- }
- } else {
- data = NULL;
- data1 = NULL;
- }
- goto next(data, data1, ...);
-}
-
-__code isEmptySingleLinkedStack(struct SingleLinkedStack* stack, __code next(...), __code whenEmpty(...)) {
- if (stack->top)
- goto next(...);
- else
- goto whenEmpty(...);
-}
-
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/SpinLock.cbc
--- a/src/parallel_execution/SpinLock.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#include "../context.h"
-#interface "Atomic.h"
-#interface "Lock.h"
-
-Lock* createSpinLock(struct Context* context) {
- struct Lock* lock = new Lock();
- struct SpinLock* spinLock = new SpinLock();
- spinLock->lock = NULL;
- spinLock->atomic = createAtomicReference(context);
- lock->lock = (union Data*)spinLock;
- lock->doLock = C_doLockSpinLock;
- lock->doUnlock = C_doUnlockSpinLock;
- return lock;
-}
-
-__code doLockSpinLock(struct SpinLock* lock, __code next(...)) {
- struct Atomic* atomic = lock->atomic;
- goto atomic->checkAndSet(&lock->lock, NULL, 1, doLockSpinLock1, doLockSpinLock);
-}
-
-__code doLockSpinLock1(struct SpinLock* lock, __code next(...)) {
- lock->lockContext = context;
- goto next(...);
-}
-
-__code doUnlockSpinLock(struct SpinLock* lock, __code next(...)) {
- if (lock->lockContext == context) {
- struct Atomic* atomic = lock->atomic;
- goto atomic->checkAndSet(&lock->lock, 1, NULL, next(...), doUnlockSpinLock);
- }
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Stack.h
--- a/src/parallel_execution/Stack.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-typedef struct Stack{
- union Data* stack;
- union Data* data;
- union Data* data1;
- /* Type* stack; */
- /* Type* data; */
- /* Type* data1; */
- __code whenEmpty(...);
- __code clear(Impl* stack,__code next(...));
- __code push(Impl* stack,Type* data, __code next(...));
- __code pop(Impl* stack, __code next(Type* data, ...));
- __code pop2(Impl* stack, __code next(Type* data, Type* data1, ...));
- __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
- __code get(Impl* stack, __code next(Type* data, ...));
- __code get2(Impl* stack, __code next(Type* data, Type* data1, ...));
- __code next(...);
-} Stack;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/SynchronizedQueue.cbc
--- a/src/parallel_execution/SynchronizedQueue.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-#include "../context.h"
-#interface "Queue.h"
-#interface "Atomic.h"
-
-#include
-
-/*
- * Non-blocking queue of Paper: Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms(https://www.research.ibm.com/people/m/michael/podc-1996.pdf).
- */
-
-Queue* createSynchronizedQueue(struct Context* context) {
- struct Queue* queue = new Queue();
- struct SynchronizedQueue* synchronizedQueue = new SynchronizedQueue();
- synchronizedQueue->top = new Element();
- synchronizedQueue->top->next = NULL;
- synchronizedQueue->last = synchronizedQueue->top;
- synchronizedQueue->atomic = createAtomicReference(context);
- queue->queue = (union Data*)synchronizedQueue;
- queue->take = C_takeSynchronizedQueue;
- queue->put = C_putSynchronizedQueue;
- queue->isEmpty = C_isEmptySynchronizedQueue;
- queue->clear = C_clearSynchronizedQueue;
- return queue;
-}
-
-__code clearSynchronizedQueue(struct SynchronizedQueue* queue, __code next(...)) {
- struct Element* top = queue->top;
- struct Atomic* atomic = queue->atomic;
- goto atomic->checkAndSet(&queue->top, top, NULL, next(...), clearSynchronizedQueue);
-}
-
-__code putSynchronizedQueue(struct SynchronizedQueue* queue, union Data* data, __code next(...)) {
- Element* element = new Element();
- element->data = data;
- element->next = NULL;
- Element* last = queue->last;
- Element* nextElement = last->next;
- if (last != queue->last) {
- goto putSynchronizedQueue();
- }
- if (nextElement == NULL) {
- struct Atomic* atomic = queue->atomic;
- goto atomic->checkAndSet(&last->next, nextElement, element, next(...), putSynchronizedQueue);
- } else {
- struct Atomic* atomic = queue->atomic;
- goto atomic->checkAndSet(&queue->last, last, nextElement, putSynchronizedQueue, putSynchronizedQueue);
- }
-}
-
-__code takeSynchronizedQueue(struct SynchronizedQueue* queue, __code next(union Data* data, ...)) {
- struct Element* top = queue->top;
- struct Element* last = queue->last;
- struct Element* nextElement = top->next;
- if (top != queue->top) {
- goto takeSynchronizedQueue();
- }
- if (top == last) {
- if (nextElement != NULL) {
- struct Atomic* atomic = queue->atomic;
- goto atomic->checkAndSet(&queue->last, last, nextElement, takeSynchronizedQueue, takeSynchronizedQueue);
- }
- } else {
- struct Atomic* atomic = queue->atomic;
- goto atomic->checkAndSet(&queue->top, top, nextElement, takeSynchronizedQueue1, takeSynchronizedQueue);
- }
- goto takeSynchronizedQueue();
-}
-
-__code takeSynchronizedQueue1(struct SynchronizedQueue* queue, __code next(union Data* data, ...), struct Element* nextElement) {
- data = nextElement->data;
- goto next(data, ...);
-}
-
-__code takeSynchronizedQueue1_stub(struct Context* context) {
- SynchronizedQueue* queue = (SynchronizedQueue*)GearImpl(context, Queue, queue);
- enum Code next = Gearef(context, Queue)->next;
- Data** O_data = &Gearef(context, Queue)->data;
- goto takeSynchronizedQueue1(context,
- queue,
- next,
- O_data,
- (struct Element*)Gearef(context, Atomic)->newData);
-}
-
-__code isEmptySynchronizedQueue(struct SynchronizedQueue* queue, __code next(...), __code whenEmpty(...)) {
- struct Element* top = queue->top;
- struct Element* last = queue->last;
- struct Element* nextElement = top->next;
- if (top != queue->top) {
- goto isEmptySynchronizedQueue();
- }
- if (top == last && nextElement == NULL) {
- goto whenEmpty(...);
- }
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/TaskIterator.cbc
--- a/src/parallel_execution/TaskIterator.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "../context.h"
-#interface "Iterator.h"
-#include
-
-createTaskIterator(struct Context, struct List list) {
- struct Iterator* iterator = new Iterator();
- struct TaskIterator* taskIterator = new TaskIterator();
- iterator->itearot = (union Data*)taskIterator;
- iterator->exec = C_execTaskIterator;
- iterator->barrier = C_barrierTaskIterator;
- taskIterator->taskList = list;
-}
-
-__code execTaskIterator(struct taskIterator* iterator, struct TaskManager* taskManager, struct Context* task, __code next(...)) {
- if (iterator->list->next == null) {
- goto next(...);
- }
- iterator->list = list->next;
- struct Context* task = (struct Context*)iterator->list->data;
- struct TaskManager taskManager = task->taskManager;
- taskManager->spawn(task, C_execTaskIterator);
-}
-
-__code barrierTaskIterator(struct MultiDimIterator* iterator, struct Context* task, __code next(...), __code whenWait(...)) {
- if (__sync_fetch_and_sub(&iterator->count, 1) == 1) {
- goto next(...);
- }
- goto whenWait(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/TaskManager.h
--- a/src/parallel_execution/TaskManager.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-typedef struct TaskManager{
- union Data* taskManager;
- struct Context* task;
- struct Element* taskList;
- __code spawn(Impl* taskManager, struct Context* task, __code next(...));
- __code spawnTasks(Impl* taskManagerImpl, struct Element* taskList, __code next1(...));
- __code setWaitTask(Impl* taskManagerImpl, struct Context* task, __code next(...));
- __code shutdown(Impl* taskManagerImpl, __code next(...));
- __code incrementTaskCount(Impl* taskManagerImpl, __code next(...));
- __code decrementTaskCount(Impl* taskManagerImpl, __code next(...));
- __code next(...);
- __code next1(...);
-} TaskManager;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/TaskManagerImpl.cbc
--- a/src/parallel_execution/TaskManagerImpl.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-#include "../context.h"
-#interface "TaskManager.h"
-#interface "Iterator.h"
-#interface "Queue.h"
-#interface "Worker.h"
-
-#include
-#include
-
-void createWorkers(struct Context* context, TaskManagerImpl* taskManager);
-
-TaskManager* createTaskManagerImpl(struct Context* context, int numCPU, int numGPU, int numIO) {
- struct TaskManager* taskManager = new TaskManager();
- taskManager->spawnTasks = C_spawnTasksTaskManagerImpl;
- taskManager->spawn = C_spawnTaskManagerImpl;
- taskManager->shutdown = C_shutdownTaskManagerImpl;
- taskManager->incrementTaskCount = C_incrementTaskCountTaskManagerImpl;
- taskManager->decrementTaskCount = C_decrementTaskCountTaskManagerImpl;
- taskManager->setWaitTask = C_setWaitTaskTaskManagerImpl;
- struct TaskManagerImpl* taskManagerImpl = new TaskManagerImpl();
- // 0...numIO-1 IOProcessor
- // numIO...numIO+numGPU-1 GPUProcessor
- // numIO+numGPU...numIO+numGPU+numCPU-1 CPUProcessor
- taskManagerImpl->io = 0;
- taskManagerImpl->gpu = numIO;
- taskManagerImpl->cpu = numIO+numGPU;
- taskManagerImpl->maxCPU = numIO+numGPU+numCPU;
- taskManagerImpl->numWorker = taskManagerImpl->maxCPU;
- taskManagerImpl->sendGPUWorkerIndex = taskManagerImpl->gpu;
- taskManagerImpl->sendCPUWorkerIndex = taskManagerImpl->cpu;
- taskManagerImpl->taskCount = 0;
- taskManagerImpl->loopCounter = 0;
- createWorkers(context, taskManagerImpl);
- taskManager->taskManager = (union Data*)taskManagerImpl;
- return taskManager;
-}
-
-void createWorkers(struct Context* context, TaskManagerImpl* taskManager) {
- int i = 0;
- taskManager->workers = (Worker**)ALLOCATE_PTR_ARRAY(context, Worker, taskManager->maxCPU);
- for (;igpu;i++) {
- Queue* queue = createSynchronizedQueue(context);
- taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue);
- }
- for (;icpu;i++) {
- Queue* queue = createSynchronizedQueue(context);
-#ifdef USE_CUDAWorker
- taskManager->workers[i] = (Worker*)createCUDAWorker(context, i, queue,0);
-#else
- taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue);
-#endif
- }
- for (;imaxCPU;i++) {
- Queue* queue = createSynchronizedQueue(context);
- taskManager->workers[i] = (Worker*)createCPUWorker(context, i, queue);
- }
-}
-
-__code spawnTasksTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Element* taskList, __code next1(...)) {
- taskManager->taskList = taskList;
- goto spawnTasksTaskManagerImpl1();
-}
-
-__code spawnTasksTaskManagerImpl1(struct TaskManagerImpl* taskManagerImpl, struct TaskManager* taskManager) {
- if (taskManagerImpl->taskList == NULL) {
- goto spawnTasksTaskManagerImpl2();
- }
- struct Context* task = (struct Context*)taskManagerImpl->taskList->data;
- taskManagerImpl->taskList = taskManagerImpl->taskList->next;
- goto taskManager->setWaitTask(task, spawnTasksTaskManagerImpl1);
-}
-
-__code spawnTasksTaskManagerImpl1_stub(struct Context* context) {
- TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
- TaskManager* taskManager = &Gearef(context, TaskManager)->taskManager->TaskManager;
- goto spawnTasksTaskManagerImpl1(context, taskManagerImpl, taskManager);
-}
-
-__code spawnTasksTaskManagerImpl2(struct TaskManagerImpl* taskManager, struct Element* taskList, __code next1(...)) {
- taskManager->taskList = taskList;
- goto spawnTasksTaskManagerImpl3();
-}
-
-__code spawnTasksTaskManagerImpl3(struct TaskManagerImpl* taskManagerImpl, __code next1(...), struct TaskManager* taskManager) {
- if (taskManagerImpl->taskList == NULL) {
- goto next1(...);
- }
- struct Context* task = (struct Context*)taskManagerImpl->taskList->data;
- taskManagerImpl->taskList = taskManagerImpl->taskList->next;
- goto taskManager->spawn(task, spawnTasksTaskManagerImpl3);
-}
-
-__code spawnTasksTaskManagerImpl3_stub(struct Context* context) {
- TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
- enum Code next1 = Gearef(context, TaskManager)->next1;
- TaskManager* taskManager = &Gearef(context, TaskManager)->taskManager->TaskManager;
- goto spawnTasksTaskManagerImpl3(context, taskManagerImpl, next1, taskManager);
-}
-
-__code setWaitTaskTaskManagerImpl(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
- int i = taskManager->loopCounter;
- if(task->idg+i < task->maxIdg) {
- struct Queue* queue = GET_WAIT_LIST(task->data[task->idg + i]);
- taskManager->loopCounter++;
- goto queue->put(task, setWaitTaskTaskManagerImpl);
- }
- taskManager->loopCounter = 0;
- goto incrementTaskCountTaskManagerImpl();
-}
-
-__code incrementTaskCountTaskManagerImpl(struct TaskManagerImpl* taskManager, __code next(...)) {
- __sync_fetch_and_add(&taskManager->taskCount, 1);
- goto next(...);
-}
-
-__code decrementTaskCountTaskManagerImpl(struct TaskManagerImpl* taskManager, __code next(...)) {
- __sync_fetch_and_sub(&taskManager->taskCount, 1);
- goto next(...);
-}
-
-__code spawnTaskManagerImpl(struct TaskManagerImpl* taskManagerImpl, struct Context* task, __code next(...), struct TaskManager* taskManager) {
- task->taskManager = taskManager;
- if (task->idgCount == 0) {
- // iterator task is normal task until spawned
- if(task->iterator != NULL && task->iterate == 0) {
- pthread_mutex_unlock(&taskManagerImpl->mutex);
- struct Iterator* iterator = task->iterator;
- goto iterator->exec(task, taskManagerImpl->cpu - taskManagerImpl->gpu, next(...));
- }
- goto taskSend();
- }
- pthread_mutex_unlock(&taskManagerImpl->mutex);
- goto next(...);
-}
-
-__code spawnTaskManagerImpl_stub(struct Context* context) {
- TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
- struct Context* task = Gearef(context, TaskManager)->task;
- TaskManager* taskManager = &Gearef(context, TaskManager)->taskManager->TaskManager;
- goto spawnTaskManagerImpl(context,
- taskManagerImpl,
- task,
- Gearef(context, TaskManager)->next,
- taskManager);
-}
-
-
-__code taskSend(struct TaskManagerImpl* taskManager, struct Context* task, __code next(...)) {
- // set workerId
- if (task->gpu) {
- task->workerId = taskManager->sendGPUWorkerIndex;
- if(++taskManager->sendGPUWorkerIndex >= taskManager->cpu) {
- taskManager->sendGPUWorkerIndex = taskManager->gpu;
- }
- } else {
- task->workerId = taskManager->sendCPUWorkerIndex;
- if(++taskManager->sendCPUWorkerIndex >= taskManager->maxCPU) {
- taskManager->sendCPUWorkerIndex = taskManager->cpu;
- }
- }
- pthread_mutex_unlock(&taskManager->mutex);
- struct Queue* queue = taskManager->workers[task->workerId]->tasks;
- goto queue->put(task, next(...));
-}
-
-__code shutdownTaskManagerImpl(struct TaskManagerImpl* taskManager, __code next(...)) {
- if (taskManager->taskCount != 0) {
- usleep(1000);
- goto shutdownTaskManagerImpl();
- }
- int i = taskManager->loopCounter;
- if (i < taskManager->numWorker) {
- struct Queue* tasks = taskManager->workers[i]->tasks;
- goto tasks->put(NULL, shutdownTaskManagerImpl1);
- }
-
- taskManager->loopCounter = 0;
- goto shutdownTaskManagerImpl2();
-}
-
-__code shutdownTaskManagerImpl1(struct TaskManagerImpl* taskManager, __code next(...)) {
- taskManager->loopCounter++;
- goto shutdownTaskManagerImpl();
-}
-
-__code shutdownTaskManagerImpl2(struct TaskManagerImpl* taskManager, __code next(...)) {
- int i = taskManager->loopCounter;
- if (i < taskManager->numWorker) {
- pthread_join(taskManager->workers[i]->thread, NULL);
- taskManager->loopCounter++;
- goto shutdownTaskManagerImpl2();
- }
- taskManager->loopCounter = 0;
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Timer.h
--- a/src/parallel_execution/Timer.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-typedef struct Timer{
- union Data* timer;
- __code start(Impl* timer, __code next(...));
- __code end(Impl* timer, __code next(...));
- __code next(...);
-} Queue;
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/TimerImpl.cbc
--- a/src/parallel_execution/TimerImpl.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#include
-#include
-
-#include "../context.h"
-#interface "Timer.h"
-
-Timer* createTimerImpl(struct Context* context) {
- struct Timer* timer = new Timer();
- struct TimerImpl* timerImpl = new TimerImpl();
- timer->timer = (union Data*)timerImpl;
- timer->start = C_startTimer;
- timer->end = C_endTimer;
- return timer;
-}
-
-__code startTimer(struct TimerImpl* timer, __code next(...)) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- timer->time = tv.tv_sec + (double)tv.tv_usec*1e-6;
-
- goto next(...);
-}
-
-__code endTimer(struct TimerImpl* timer, __code next(...)) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- printf("%0.6f\n", (tv.tv_sec+(double)tv.tv_usec*1e-6) - timer->time);
- goto next(...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Todo
--- a/src/parallel_execution/Todo Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-Tue Aug 1 19:32:55 JST 2017
-
- DataGear の待ち合わせ
- DataGear の Commit
-
- これらは、stubとgoto meta の部分で行う
-
- どれに対して行うかを実行時あるいはコンパイル時に指定する必要がある
-
- 一つの解決策は、 typedefのときにannotution してあげる
- もう一つの解決策は, Data Gear の allocation 時に指定する
- Code Gearのプロトタイプのなかで指定する事も考えられる
-
- par goto時に渡す continuation で同期をとっても良い, このときにはこのcontinuation を作成するinterfaceを作る必要がある
-
- 実行時に指定してしまうと、毎回フラグのチェックが必要になる。
- これを abstract model checking を事前に行うことで, static なコードに置き換える事はできる
-
- 例題としては, chat、dining philosophers, map reduce
-
-Fri Apr 14 18:44:09 JST 2017
- struct B {
- A a;
- .....
- }
- struct A {
- __code init(..., __code next(A a, ...));
- }
- par goto A->init(a);
- // meta level
- task->code = C_init_A;
- task->data[idg] = ...;
- task->data[idg + 1] = ...;
- task->data[odg] = ...;
- task->next = C_writeToa;
- goto meta(context, context->TaskManager->spawn)
-
- // lambda version?
- par goto A->init(\A -> a = A)
-
- // meta level
- par goto A->init(next = \A -> a = A)
-
-Wed Mar 1 18:25:36 JST 2017
-
- parallel_executtion/test/ を .cbc に書き直す
- rb_tree の stub をできるだけ取り外す
- synchornizedQueue の meta部分を分離する
- synchronizedQueue のバグをとる
- GPU のバグとり
- cbc++...?
-
-Sat Jan 28 16:10:28 JST 2017
-
- stackからpopした後、呼び出される continuation は出力を受けとる。
- 出力を受けとる stub を生成する必要がある。
- なので、CodeGear が、そのような interface で定義されたものかどうかを調べる必要がある。
- Stackのnext(やisEmpty)に代入された時点でわかる。なので、あまり自明な見つける方法がない。
- 引数の異なるnextは異なる名前を持つべきか? 持たなくてもできるが...
-
- goto next(data, ...); 引数で渡された continuation に移動
- goto nodeStack->push(newNode, replaceNode1); Interface の呼び出し。(ここで replaceNode1 が stack の戻り値を受けることがわかる。
- goto replaceNode(traverse, traverse->current, newNode); 普通のgoto
- goto rotateTree->next(...); DataGearに格納された continuation
-
- などをチェックする必要がある。これらの型チェックは CbC level では行われない。(CbCはmeta levelだから)
-
- 戻り値の部分は interface に記述させるという手もあるな。
-
-
-Sun Jan 22 20:11:28 JST 2017
-
- TaskManagerから必要なCPUWorkerを生成する
- WorkerはcreateWorker時に新しくthreadを作る
-
- TaskManager->createTaskで新しいContextを生成する
- この時点でWorkerを番号で指定する
- このContextにGearefで値を設定していく
- 待ち合わせ用のDSを設定する
- taskManager->spawnでWorkerにcontextを送る
-
-Fri Jan 13 17:47:40 JST 2017
-
- Task は contextを直接使うことにする
- DS には, まっているcontextをListを作る
- context に実行中断中のCS の番号をいれるフィールドを用意する
- 待っているDS のcount
- createTaskの手順
- 新しくcontextを作る
- allocate 用のheap も用意
- もとのcontextを全部copyする or 必要なものだけcopyする
- 待ち合わせのDS群を指定する
- 終わったあとの行き先を指定する(default は task_exit)
- exception の行き先も必要な指定する
- 待っているDSが全部揃っていたら active Queueに入れる
- task の実行
- taskの実行後、 goto meta する直前で code gear commit を呼んで, Reader list を消化する
- 複数から参照されるDSは一旦localに書き出して, その後atomic に書き出す
- 複数から参照されるDSは何かしら宣言が必要
- つまり DS には 一つ一つ owner がいる
-
-Mon Nov 28 17:39:39 JST 2016
-
- Task,TaskManager,Workerのインターフェースの実装を作成する
- Taskを一旦Treeに入れずに直接Queueに入れる
-
- Task
- CodeGen
- IDataSeg
- IDataSeg
- ...
- idsCount
- nextTask(can be C_exit)
- ODataSeg?
-
- TaskManager
- createWorker
- spawn (any,cpu,GPU)
- taskSend
- activeQueue
- shutdown
- deadlockDetectid
-
- SynchronizedQueue * Workerの数だけ
-
- Worker
- execute
- taskRecive
- shutdown
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Tree.h
--- a/src/parallel_execution/Tree.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-typedef struct Tree{
- /* future Code */
- /* Type* tree; */
- /* Type* node; */
- union Data* tree;
- struct Node* node;
- __code put(Impl* tree,Type* node, __code next(...));
- // __code get(Impl* tree, __code next(...));
- __code remove(Impl* tree,Type* node, __code next(...));
- // __code clearRedBlackTree();
- __code next(...);
-} Tree;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/Worker.h
--- a/src/parallel_execution/Worker.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-typedef struct Worker{
- union Data* worker;
- struct Queue* tasks;
- struct Context* task;
- __code taskReceive(Impl* worker, struct Queue* tasks);
- __code shutdown(Impl* worker);
- __code next(...);
-} Worker;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/compare.c
--- a/src/parallel_execution/compare.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#include "context.h"
-
-enum Relational compare(struct Node* node1, struct Node* node2) {
- int key1 = node1->key;
- int key2 = node2->key;
- if (key1 == key2) {
- return EQ;
- } else if (key1 < key2) {
- return GT;
- } else {
- return LT;
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/context.h
--- a/src/parallel_execution/context.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,447 +0,0 @@
-/* Context definition for llrb example */
-#ifndef CONTEXT_H
-#define CONTEXT_H
-#include
-#include
-#ifdef USE_CUDAWorker
-#include
-#include
-#include
-#include "helper_cuda.h"
-#endif
-
-#define ALLOCATE_SIZE 20000000
-#define NEW(type) (type*)(calloc(1, sizeof(type)))
-#define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
-
-#define ALLOC_DATA(context, dseg) ({\
- Meta* meta = (Meta*)context->heap;\
- meta->type = D_##dseg;\
- meta->size = sizeof(dseg);\
- meta->len = 1;\
- context->heap += sizeof(Meta);\
- context->data[D_##dseg] = context->heap; context->heap += sizeof(dseg); (dseg *)context->data[D_##dseg]; })
-
-#define ALLOC_DATA_TYPE(context, dseg, t) ({\
- Meta* meta = (Meta*)context->heap;\
- meta->type = D_##t;\
- meta->size = sizeof(t);\
- meta->len = 1;\
- context->heap += sizeof(Meta);\
- context->data[D_##dseg] = context->heap; context->heap += sizeof(t); (t *)context->data[D_##dseg]; })
-
-#define ALLOCATE(context, t) ({ \
- Meta* meta = (Meta*)context->heap;\
- context->heap += sizeof(Meta);\
- union Data* data = context->heap; \
- context->heap += sizeof(t); \
- meta->type = D_##t; \
- meta->size = sizeof(t); \
- meta->len = 1;\
- data; })
-
-#define ALLOCATE_ARRAY(context, t, length) ({ \
- Meta* meta = (Meta*)context->heap;\
- context->heap += sizeof(Meta);\
- union Data* data = context->heap; \
- context->heap += sizeof(t)*length; \
- meta->type = D_##t; \
- meta->size = sizeof(t)*length; \
- meta->len = length; \
- data; })
-
-#define ALLOCATE_PTR_ARRAY(context, dseg, length) ({\
- Meta* meta = (Meta*)context->heap;\
- context->heap += sizeof(Meta);\
- union Data* data = context->heap; \
- context->heap += sizeof(dseg *)*length; \
- meta->type = D_##dseg; \
- meta->size = sizeof(dseg *)*length; \
- meta->len = length; \
- data; })
-
-#define ALLOCATE_DATA_GEAR(context, t) ({ \
- union Data* data = ALLOCATE(context, t); \
- Meta* meta = GET_META(data); \
- meta->wait = createSynchronizedQueue(context); \
- data; })
-
-#define ALLOC(context, t) (&ALLOCATE(context, t)->t)
-
-#define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
-#define GET_TYPE(dseg) (GET_META(dseg)->type)
-#define GET_SIZE(dseg) (GET_META(dseg)->size)
-#define GET_LEN(dseg) (GET_META(dseg)->len)
-#define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
-
-#define Gearef(context, t) (&(context)->data[D_##t]->t)
-
-// (SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack
-
-#define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name)
-
-#include "c/enumCode.h"
-
-enum Relational {
- EQ,
- GT,
- LT,
-};
-
-#include "c/enumData.h"
-
-struct Context {
- enum Code next;
- struct Worker* worker;
- struct TaskManager* taskManager;
- int codeNum;
- __code (**code) (struct Context*);
- void* heapStart;
- void* heap;
- long heapLimit;
- int dataNum;
- int idgCount; //number of waiting dataGear
- int idg;
- int maxIdg;
- int odg;
- int maxOdg;
- int workerId;
- int gpu; // GPU task
- struct Context* task;
- struct Element* taskList;
-#ifdef USE_CUDAWorker
- int num_exec;
- CUmodule module;
- CUfunction function;
-#endif
- union Data **data;
-
- /* multi dimension parameter */
- int iterate;
- struct Iterator* iterator;
-};
-
-typedef int Int;
-#ifndef USE_CUDAWorker
-typedef unsigned long long CUdeviceptr;
-#endif
-union Data {
- struct Meta {
- enum DataType type;
- long size;
- long len;
- struct Queue* wait; // tasks waiting this dataGear
- } Meta;
- struct Context Context;
- struct Timer {
- union Data* timer;
- enum Code start;
- enum Code end;
- enum Code next;
- } Timer;
- struct TimerImpl {
- double time;
- } TimerImpl;
- struct LoopCounter {
- int i;
- } LoopCounter;
- struct TaskManager {
- union Data* taskManager;
- enum Code spawn; // start NEW context on the worker
- enum Code spawnTasks; // start NEW tasks on the worker
- enum Code shutdown;
- enum Code incrementTaskCount;
- enum Code decrementTaskCount;
- enum Code next;
- enum Code next1;
- enum Code setWaitTask;
- struct Context* task;
- struct Element* taskList;
- union Data* data;
- } TaskManager;
- struct TaskManagerImpl {
- enum Code next;
- int numWorker;
- int sendCPUWorkerIndex;
- int sendGPUWorkerIndex;
- int taskCount;
- pthread_mutex_t mutex;
- struct Queue* activeQueue;
- struct Worker** workers;
- struct Element* taskList;
- int loopCounter;
- int cpu;
- int gpu;
- int io;
- int maxCPU;
- } TaskManagerImpl;
- struct Worker {
- union Data* worker;
- enum Code taskReceive;
- enum Code shutdown;
- enum Code next;
- struct Queue* tasks;
- pthread_t thread;
- struct TaskManager* taskManager;
- struct Context* task;
- } Worker;
- struct CPUWorker {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- struct Context* context;
- int id;
- int loopCounter;
- } CPUWorker;
-#ifdef USE_CUDAWorker
- struct CUDAWorker {
- CUdevice device;
- CUcontext cuCtx;
- struct Context* context;
- int id;
- int loopCounter;
- int deviceNum;
- struct Queue* tasks;
- int runFlag;
- enum Code next;
- int numStream;
- struct Executor* executor;
- CUstream *stream;
- } CUDAWorker;
-#else
- struct CUDAWorker {
- } CUDAWorker;
-#endif
- struct Main {
- enum Code code;
- enum Code next;
- struct Queue* args;
- } Main;
- // Queue Interface
- struct Queue {
- union Data* queue;
- union Data* data;
- enum Code whenEmpty;
- enum Code clear;
- enum Code put;
- enum Code take;
- enum Code isEmpty;
- enum Code next;
- } Queue;
- struct SingleLinkedQueue {
- struct Element* top;
- struct Element* last;
- } SingleLinkedQueue;
- struct SynchronizedQueue {
- struct Element* top;
- struct Element* last;
- struct Atomic* atomic;
- } SynchronizedQueue;
- // Stack Interface
- struct Stack {
- union Data* stack;
- union Data* data;
- union Data* data1;
- enum Code whenEmpty;
- enum Code clear;
- enum Code push;
- enum Code pop;
- enum Code pop2;
- enum Code isEmpty;
- enum Code get;
- enum Code get2;
- enum Code next;
- } Stack;
- // Stack implementations
- struct SingleLinkedStack {
- struct Element* top;
- } SingleLinkedStack;
- struct ArrayStack {
- int size;
- int limit;
- struct Element* array;
- } ArrayStack;
- // Stack implementation end
- struct Element {
- union Data* data;
- struct Element* next;
- } Element;
- struct Array {
- int prefix;
- Int* array;
- } Array;
- struct Tree {
- union Data* tree;
- struct Node* node;
- enum Code put;
- enum Code get;
- enum Code remove;
- enum Code clear;
- enum Code next;
- } Tree;
- struct RedBlackTree {
- struct Node* root;
- struct Node* current; // reading node of original tree
- struct Node* previous; // parent of reading node of original tree
- struct Node* newNode; // writing node of new tree
- struct Node* parent;
- struct Node* grandparent;
- struct Stack* nodeStack;
- enum Code findNodeNext;
- int result;
- } RedBlackTree;
- struct RotateTree {
- enum Code next;
- struct RedBlackTree* traverse;
- struct Tree* tree;
- } RotateTree;
- struct Node {
- int key; // comparable data segment
- union Data* value;
- struct Node* left;
- struct Node* right;
- // need to balancing
- enum Color {
- Red,
- Black,
- // Red eq 0,Black eq 1. enum name convert intager.
- } color;
- } Node;
- struct Atomic {
- union Data* atomic;
- union Data** ptr;
- union Data* oldData;
- union Data* newData;
- enum Code checkAndSet;
- enum Code next;
- enum Code fail;
- } Atomic;
- struct AtomicReference {
- } AtomicReference;
- struct Semaphore {
- union Data* semaphore;
- enum Code p;
- enum Code v;
- enum Code next;
- } Semaphore;
- struct SemaphoreImpl {
- int value;
- struct Lock* lock;
- struct Queue* waitThreadQueue;
- } SemaphoreImpl;
- struct Allocate {
- enum Code next;
- long size;
- } Allocate;
- struct Integer {
- int value;
- } Integer;
- struct SortArray {
- struct Integer *array; //Array arrayじゃできない?
- int loopCounter;
- int block;
- int first;
- int prefix;
- } SortArray;
- struct Iterator {
- union Data* iterator;
- struct Context* task;
- int numGPU;
- enum Code exec;
- enum Code barrier;
- enum Code whenWait;
- enum Code next;
- } Iterator;
- struct MultiDimIterator {
- int x;
- int y;
- int z;
- int count;
- int counterX;
- int counterY;
- int counterZ;
- } MultiDimIterator;
- struct MultiDim {
- int x;
- int y;
- int z;
- } MultiDim;
- struct Executor {
- union Data* executor;
- struct Context* task;
- enum Code read;
- enum Code exec;
- enum Code write;
- enum Code next;
- } Executor;
-#ifdef USE_CUDAWorker
- struct CUDAExecutor {
- CUdeviceptr** kernelParams;
- struct CUDABuffer* buffer;
- int maxThreadPerBlock;
- } CUDAExecutor;
- struct CUDABuffer {
- int inputLen;
- int outputLen;
- union Data** inputData;
- union Data** outputData;
- } CUDABuffer;
- CUdeviceptr CUdeviceptr;
-#else
- struct CUDAExecutor {
- } CUDAExecutor;
- struct CUDABuffer {
- } CUDABuffer;
- CUdeviceptr CUdeviceptr;
-#endif
- Int Int;
- struct Memory {
- union Data* adr;
- int length;
- union Data* body;
- int hash;
- } Memory;
- struct Buffer {
- union Data* buffer;
- union Data* data;
- enum Code put;
- enum Code take;
- enum Code next;
- } Buffer;
- struct BoundedBuffer {
- struct Element* top;
- struct Element* last;
- struct Semaphore* fullCount;
- struct Semaphore* emptyCount;
- struct Semaphore* lock;
- } BoundedBuffer;
- struct Lock {
- union Data* lock;
- enum Code doLock;
- enum Code doUnlock;
- enum Code next;
- } Lock;
- struct LockImpl {
- Int* lock;
- struct Queue* waitThreadQueue;
- struct Atomic* atomic;
- struct Context* lockContext;
- } LockImpl;
- struct SpinLock {
- volatile Int* lock;
- struct Atomic* atomic;
- struct Context* lockContext;
- } SpinLock;
-}; // union Data end this is necessary for context generator
-typedef union Data Data;
-
-#include "c/typedefData.h"
-
-#include "c/extern.h"
-
-extern __code start_code(struct Context* context);
-extern __code exit_code(struct Context* context);
-extern __code meta(struct Context* context, enum Code next);
-extern __code par_meta(struct Context* context, enum Code spawns, enum Code next);
-extern void initContext(struct Context* context);
-
-#endif
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/cuda.c
--- a/src/parallel_execution/cuda.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-#include
-#include
-#include
-#include
-
-// includes, project
-#include
-#include
-#include
-#include "helper_cuda.h"
-#include "pthread.h"
-
-#include "context.h"
-
-/*
-struct Context {
- int next;
- struct Worker* worker;
- struct TaskManager* taskManager;
- int codeNum;
- void (**code) (struct Context*);
- void* heapStart;
- void* heap;
- long heapLimit;
- int dataNum;
- int idgCount; //number of waiting dataGear
- int idg;
- int maxIdg;
- int odg;
- int maxOdg;
- int workerId;
- struct Context* task;
- struct Queue* tasks;
- int num_exec;
- CUmodule module;
- CUfunction function;
- union Data **data;
-
- // multi dimension parameter
- int iterate;
- struct Iterator* iterator;
-};
-
-struct CUDAWorker {
- CUdevice device;
- CUcontext cuCtx;
- pthread_t thread;
- struct Context* context;
- int id;
- struct Queue* tasks;
- int runFlag;
- int next;
- int numStream;
- CUstream *stream;
-} CUDAWorker;
-
-struct LoopCounter {
- int i;
-} LoopCounter;
-
-struct Array {
- int size;
- int index;
- int prefix;
- int* array;
-} Array;
-*/
-
-void cudaInit(struct CUDAWorker *cudaWorker,int phase, int deviceNum) {
- // initialize and load kernel
- cudaWorker->numStream = 1; // number of stream
- // cudaWorker->stream = NEWN(cudaWorker->numStream, CUstream );
- if (phase==0)
- checkCudaErrors(cuInit(0));
- if (phase==0)
- checkCudaErrors(cuDeviceGet(&cudaWorker->device, deviceNum));
- if (phase==0)
- checkCudaErrors(cuCtxCreate(&cudaWorker->cuCtx, CU_CTX_SCHED_SPIN, cudaWorker->device));
- // if (cudaWorker->num_stream) {
- // for (int i=0;inum_stream;i++)
- // checkCudaErrors(cuStreamCreate(&cudaWorker->stream[i],0));
- // }
- printf("cuda Init: Done\n");
-}
-
-void cudaLoadFunction(struct Context* context, char* filename, char* function) {
- checkCudaErrors(cuModuleLoad(&context->module, filename));
- checkCudaErrors(cuModuleGetFunction(&context->function, context->module, function));
-}
-
-void cudaShutdown(struct CUDAWorker *worker) {
- // for (int i=0;inum_stream;i++)
- // checkCudaErrors(cuStreamDestroy(worker->stream[i]));
- checkCudaErrors(cuCtxDestroy(worker->cuCtx));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/CUDAbitonicSwap.cu
--- a/src/parallel_execution/examples/bitonicSort/CUDAbitonicSwap.cu Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-extern "C" {
- struct Integer {
- int value;
- };
- struct SortArray {
- struct Integer *array;
- int loopCounter;
- int block;
- int first;
- int prefix;
- };
- __global__ void bitonicSwap(struct Integer* array, struct SortArray* sortArray) {
- int block = sortArray->block;
- int first = sortArray->first;
- int prefix = sortArray->prefix;
- int i = 0;
-C_bitonicSwap:
- if (i < prefix) {
- int index = i + (blockIdx.x * blockDim.x + threadIdx.x) * prefix;
- int position = index/block;
- int index1 = index+block*position;
- int index2 = (first == 1)? ((block<<1)*(position+1))-(index1%block)-1 : index1+block;
- if (array[index2].value < array[index1].value) {
- struct Integer tmp = array[index1];
- array[index1] = array[index2];
- array[index2] = tmp;
- }
- i++;
- goto C_bitonicSwap;
- }
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/SortArray.cbc
--- a/src/parallel_execution/examples/bitonicSort/SortArray.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-typedef struct SortArray{
- SortArray *sortArray;
- Integer **array;
- int loop_counter;
- int loop_counter2;
- int loop_counter3;
- int sort_finish;
- __code print(struct SortArray* sortArray, __code next(...));
- __code make_array(struct SortArray* sortArray, __code next(...));
- __code bitonic_sort(struct SortArray* sortArray, __code next(...));
- __code kernel(struct SortArray* sortArray, __code next(...));
- __code kernel2(struct SortArray* sortArray, __code next(...));
- __code swap(struct SortArray* sortArray, __code next(...));
-} SortArray;
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/bitonicSort.cbc
--- a/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "../../../context.h"
-#interface "TaskManager.h"
-
-int cpu_num = 1;
-int length = 1024;
-int split = 8;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-void *start_taskManager(struct Context *context) {
- goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
- return 0;
-}
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto code1();
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct LoopCounter* loopCounter) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- printf("length/task:\t%d\n", length/split);
- /* puts("queue"); */
- /* print_queue(context->data[ActiveQueue]->queue.first); */
- /* puts("tree"); */
- /* print_tree(context->data[Tree]->tree.root); */
- /* puts("result"); */
-
- goto createTask1();
-}
-
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- struct SortArray* outputSortArray = new SortArray();
- struct SortArray* inputSortArray = outputSortArray;
- struct Timer* timer = createTimerImpl(context);
-
- par goto makeArray(outputSortArray, timer, __exit);
-
- for (int i=2; i <= length; i=2*i) {
- int first = 1;
- for (int j=i>>1; j > 0; j=j>>1) {
- outputSortArray = new SortArray();
- inputSortArray->prefix = length/2/split;
- inputSortArray->block = j;
- inputSortArray->first = first;
- par goto bitonicSwap(inputSortArray, outputSortArray, iterate(split), __exit);
- first = 0;
- inputSortArray = outputSortArray;
- }
- }
-
- par goto printArray(inputSortArray, timer, __exit);
-
- goto code2();
-}
-
-__code code2(struct TaskManager* taskManager) {
- goto taskManager->shutdown(exit_code);
-}
-
-__code code2_stub(struct Context* context) {
- goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-s") == 0)
- split = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-int main(int argc, char** argv) {
- init(argc, argv);
- goto initDataGears();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/bitonicSwap.cbc
--- a/src/parallel_execution/examples/bitonicSort/bitonicSwap.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#include "../../../context.h"
-#include
-
-#ifdef USE_CUDAWorker
-extern void cudaLoadFunction(struct Context* context, char* filename, char* function);
-#endif
-
-__code bitonicSwap(struct SortArray* inputArray, struct MultiDim* multiDim, __code next(struct SortArray* output, ...), struct LoopCounter* loopCounter) {
- struct SortArray* output = *O_output;
- int block = inputArray->block;
- int first = inputArray->first;
- if (loopCounter->i < inputArray->prefix) {
- int index = loopCounter->i + multiDim->x * inputArray->prefix;
- int position = index/block;
- int index1 = index+block*position;
- int index2 = (first == 1)? ((block<<1)*(position+1))-(index1%block)-1 : index1+block;
- struct Integer* array = inputArray->array;
- if (array[index2].value < array[index1].value) {
- struct Integer tmp = array[index1];
- array[index1] = array[index2];
- array[index2] = tmp;
- }
- loopCounter->i++;
- goto meta(context, C_bitonicSwap);
- }
- loopCounter->i = 0;
- output->array = inputArray->array;
- *O_output = output;
- goto meta(context, next);
-}
-
-__code bitonicSwap_stub(struct Context* context) {
-#ifdef USE_CUDAWorker
- if (context->gpu) {
- SortArray* inputSortArray = &context->data[context->idg]->SortArray;
- SortArray* outputSortArray = &context->data[context->odg]->SortArray;
- CUDABuffer* buffer = &ALLOCATE(context, CUDABuffer)->CUDABuffer;
- buffer->inputData = (union Data**)ALLOCATE_PTR_ARRAY(context, SortArray, 2);
- buffer->inputData[0] = (union Data*)inputSortArray->array;
- buffer->inputData[1] = (union Data*)inputSortArray;
- buffer->outputData = NULL;
- buffer->inputLen = 2;
- buffer->outputLen = 0;
- //continuationにそってGPUworkerに戻る
- outputSortArray->array = inputSortArray->array;
- Executor* executor = context->worker->worker->CUDAWorker.executor;
- executor->executor->CUDAExecutor.buffer = buffer;
- cudaLoadFunction(context, "c/examples/bitonicSort/CUDAbitonicSwap.ptx", "bitonicSwap");
- Gearef(context, Executor)->executor = (union Data*)executor;
- Gearef(context, Executor)->task = context;
- Gearef(context, Executor)->next = context->next;
- goto meta(context, executor->read);
- }
-#endif
- SortArray** O_output = (struct SortArray **)&context->data[context->odg];
- goto bitonicSwap(context,
- &context->data[context->idg]->SortArray,
- &context->data[context->idg+1]->MultiDim,
- context->next,
- O_output,
- Gearef(context, LoopCounter));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/makeArray.cbc
--- a/src/parallel_execution/examples/bitonicSort/makeArray.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include "../../../context.h"
-#include
-#interface "Timer.h"
-
-extern int length;
-__code makeArray(__code next(struct SortArray* output, struct Timer* output1, ...)){
- struct SortArray* output = *O_output;
- struct Timer* output1 = *O_output1;
- if (output->loopCounter == 0){
- output->array = (Integer*)ALLOCATE_ARRAY(context, Integer, length);
- srand((unsigned) time(NULL));
- }
- if (output->loopCounter == GET_LEN(output->array)){
- printf("created Array\n");
- output->loopCounter = 0;
- *O_output = output;
- *O_output1 = output1;
- goto output1->start(next(...));
- }
- output->array[output->loopCounter].value = rand() % 1000;
- //printf("%d\n", output->array[output->loopCounter]->value);
- output->loopCounter++;
- *O_output = output;
- *O_output1 = output1;
- goto meta(context, C_makeArray);
-}
-
-__code makeArray_stub(struct Context* context) {
- SortArray** O_output = (struct SortArray**)&context->data[context->odg];
- Timer** O_output1 = (struct Timer**)&context->data[context->odg+1];
- goto makeArray(context,
- context->next,
- O_output,
- O_output1);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/printArray.cbc
--- a/src/parallel_execution/examples/bitonicSort/printArray.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include "../../../context.h"
-#interface "Timer.h"
-#include
-
-__code printArray(struct SortArray* inputArray, struct Timer* inputTimer, __code next(...)){
- goto inputTimer->end(printArray1);
-}
-
-__code printArray_stub(struct Context* context) {
- goto printArray(context,
- &context->data[context->idg]->SortArray,
- &context->data[context->idg+1]->Timer,
- context->next);
-}
-
-__code printArray1(struct SortArray* inputArray, __code next(...)){
- //printf("%d\n", inputArray->array[inputArray->loopCounter].value);
- inputArray->loopCounter++;
- if (inputArray->loopCounter == GET_LEN(inputArray->array)){
- printf("sort completed\n");
- inputArray->loopCounter = 0;
- goto meta(context, next);
- }
- if (inputArray->array[inputArray->loopCounter-1].value > inputArray->array[inputArray->loopCounter].value) {
- printf("wrong result\n");
- goto meta(context, next);
- }
- goto meta(context, C_printArray1);
-}
-
-__code printArray1_stub(struct Context* context) {
- goto printArray1(context,
- &context->data[context->idg]->SortArray,
- context->next);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/bitonicSort/sort.cbc
--- a/src/parallel_execution/examples/bitonicSort/sort.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-#include
-#include
-#include "../../../context.h"
-#define LOGN 5
-#define MAX 1 << LOGN
-
-int main(int argc, char const* argv[]) {
- struct Context* main_context = NEW(struct Context);
- initContext(main_context);
- main_context->next = C_sort_start;
- goto start_code(main_context);
-}
-
-__code sort_start(struct SortArray* sortArray){
- sortArray->sortArray = new SortArray();
- sortArray->sortArray->array = (Integer**)ALLOCATE_PTR_ARRAY(context, Integer, MAX);//ALLOC_ARRAYはDSの配列なのでintではできない
- sortArray->sortArray->loop_counter = 0;
- sortArray->sortArray->loop_counter2 = 0;
- sortArray->sortArray->loop_counter3 = 0;
- srand((unsigned) time(NULL));
- goto meta(context, C_make_array);
-}
-
-__code make_array(struct SortArray* sortArray){//乱数生成
- if (sortArray->sortArray->loop_counter == MAX){//ループの終了→配列表示へ
- sortArray->sortArray->loop_counter = 0;
- goto meta(context, C_print);
- }
- struct Integer* integer = new Integer();
- integer->value = rand() % 1000;
- sortArray->sortArray->array[sortArray->sortArray->loop_counter] = integer;
- sortArray->sortArray->loop_counter++;
- goto meta(context, C_make_array);
-}
-
-__code print(struct SortArray* sortArray){//配列表示
- if (sortArray->sortArray->loop_counter == MAX){//ループの終了→ソートへ
- printf("\n");
- if(sortArray->sortArray->sort_finish == 1){//ソート終わってたら終了
- goto meta(context, C_exit_code);
- }
- sortArray->sortArray->loop_counter = 0;
- sortArray->sortArray->loop_counter2 = 0;
- goto meta(context, C_bitonic_sort);
- }
-
- printf("%d, ", sortArray->sortArray->array[sortArray->sortArray->loop_counter]->value);
- sortArray->sortArray->loop_counter++;
- goto meta(context, C_print);
-}
-
-__code bitonic_sort(struct SortArray* sortArray){//ソートの繰り返し
- if (sortArray->sortArray->loop_counter >= LOGN){//ループの終了→配列表示へ
- sortArray->sortArray->loop_counter = 0;
- sortArray->sortArray->sort_finish = 1;
- goto meta(context, C_print);
- }
- goto meta(context, C_kernel);
-}
-
-__code kernel(struct SortArray* sortArray){//繰り返し2
- if (sortArray->sortArray->loop_counter2 > sortArray->sortArray->loop_counter){//ループの終了→上のループへ
- sortArray->sortArray->loop_counter++;
- sortArray->sortArray->loop_counter2 = 0;
- goto meta(context, C_bitonic_sort);
- }
-
- goto meta(context, C_kernel2);
-}
-
-__code kernel2(struct SortArray* sortArray){//ソートの中身
- int i = sortArray->sortArray->loop_counter3;
-
- if (i >= GET_LEN(sortArray->sortArray->array)){//ループの終了→上のループへ
- sortArray->sortArray->loop_counter2++;
- sortArray->sortArray->loop_counter3 = 0;
- goto meta(context, C_kernel);
- }
-
- goto meta(context, C_swap);
-}
-
-__code swap(struct SortArray* sortArray){//配列の要素を入れ替える
- int i = sortArray->sortArray->loop_counter3;
- int d = 1 << (sortArray->sortArray->loop_counter - sortArray->sortArray->loop_counter2);
- int up = ((i >> sortArray->sortArray->loop_counter) & 2) == 0;
-
- if ((i & d) == 0 && (sortArray->sortArray->array[i]->value > sortArray->sortArray->array[i | d]->value) == up) {
- struct Integer *tmp = sortArray->sortArray->array[i];
- sortArray->sortArray->array[i] = sortArray->sortArray->array[i | d];
- sortArray->sortArray->array[i | d] = tmp;
- }
- sortArray->sortArray->loop_counter3++;
- goto meta(context, C_kernel2);//上位のループへ
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/BoundedBuffer.cbc
--- a/src/parallel_execution/examples/boundedBuffer/BoundedBuffer.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#include "../../../context.h"
-#interface "Buffer.h"
-#interface "Semaphore.h"
-
-Buffer* createBoundedBuffer(struct Context* context, int size) {
- struct Buffer* buffer = new Buffer();
- struct BoundedBuffer* boundedBuffer = new BoundedBuffer();
- boundedBuffer->top = new Element();
- boundedBuffer->top->next = NULL;
- boundedBuffer->last = boundedBuffer->top;
- boundedBuffer->fullCount = createSemaphoreImpl(context, 0);
- boundedBuffer->emptyCount = createSemaphoreImpl(context, size);
- boundedBuffer->lock = createSemaphoreImpl(context, 1); // binary semaphore
- buffer->buffer = (union Data*)boundedBuffer;
- buffer->take = C_takeBoundedBuffer;
- buffer->put = C_putBoundedBuffer;
- return buffer;
-}
-
-__code putBoundedBuffer(struct BoundedBuffer* buffer, union Data* data, __code next(...)) {
- struct Semaphore* semaphore = buffer->emptyCount;
- goto semaphore->p(putBoundedBuffer1);
-}
-
-__code putBoundedBuffer1(struct BoundedBuffer* buffer, union Data* data, __code next(...)) {
- struct Semaphore* semaphore = buffer->lock;
- goto semaphore->p(putBoundedBuffer2);
-}
-
-__code putBoundedBuffer2(struct BoundedBuffer* buffer, union Data* data, __code next(...)) {
- struct Element* element = new Element();
- element->data = data;
- element->next = NULL;
- struct Element* last = buffer->last;
- last->next = element;
- buffer->last = element;
- struct Semaphore* semaphore = buffer->lock;
- goto semaphore->v(putBoundedBuffer3);
-}
-
-__code putBoundedBuffer3(struct BoundedBuffer* buffer, union Data* data, __code next(...)) {
- struct Semaphore* semaphore = buffer->fullCount;
- goto semaphore->v(putBoundedBuffer4);
-}
-
-__code putBoundedBuffer4(struct BoundedBuffer* buffer, union Data* data, __code next(...)) {
- goto next(...);
-}
-__code takeBoundedBuffer(struct BoundedBuffer* buffer, __code next(union Data* data, ...)) {
- struct Semaphore* semaphore = buffer->fullCount;
- goto semaphore->p(takeBoundedBuffer1);
-}
-
-__code takeBoundedBuffer1(struct BoundedBuffer* buffer, __code next(union Data* data, ...)) {
- struct Semaphore* semaphore = buffer->lock;
- goto semaphore->p(takeBoundedBuffer2);
-}
-
-__code takeBoundedBuffer2(struct BoundedBuffer* buffer, __code next(union Data* data, ...)) {
- struct Element* top = buffer->top;
- struct Element* nextElement = top->next;
- data = nextElement->data;
- *O_data =data;
- buffer->top = nextElement;
- struct Semaphore* semaphore = buffer->lock;
- goto semaphore->v(takeBoundedBuffer3);
-}
-
-__code takeBoundedBuffer3(struct BoundedBuffer* buffer, __code next(union Data* data, ...)) {
- struct Semaphore* semaphore = buffer->emptyCount;
- goto semaphore->v(takeBoundedBuffer4);
-}
-
-__code takeBoundedBuffer4(struct BoundedBuffer* buffer, __code next(union Data* data, ...)) {
- goto next(data, ...);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc
--- a/src/parallel_execution/examples/boundedBuffer/SemaphoreImpl.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#include "../../../context.h"
-#interface "Semaphore.h"
-#interface "Queue.h"
-#interface "TaskManager.h"
-#interface "Lock.h"
-
-Semaphore* createSemaphoreImpl(struct Context* context, int n) {
- struct Semaphore* semaphore = new Semaphore();
- struct SemaphoreImpl* semaphoreImpl = new SemaphoreImpl();
- semaphore->semaphore = (union Data*)semaphoreImpl;
- semaphoreImpl->value = n;
- semaphoreImpl->waitThreadQueue = createSingleLinkedQueue(context);
- semaphoreImpl->lock = createSpinLock(context);
- semaphore->p = C_pOperationSemaphoreImpl;
- semaphore->v = C_vOperationSemaphoreImpl;
- return semaphore;
-}
-
-__code pOperationSemaphoreImpl(struct SemaphoreImpl* semaphore, __code next(...)) {
- struct Lock* lock = semaphore->lock;
- goto lock->doLock(pOperationSemaphoreImpl1);
-}
-
-__code pOperationSemaphoreImpl1(struct SemaphoreImpl* semaphore, __code next(...)) {
- if(semaphore->value == 0) {
- context->next= C_pOperationSemaphoreImpl;
- struct Queue* queue = semaphore->waitThreadQueue;
- goto queue->put(context, pOperationSemaphoreImpl2); // put this context(thread, process)
- }
- semaphore->value--;
- struct Lock* lock = semaphore->lock;
- goto lock->doUnlock(next(...));
-}
-
-__code pOperationSemaphoreImpl2(struct SemaphoreImpl* semaphore, __code next(...)) {
- struct Lock* lock = semaphore->lock;
- goto lock->doUnlock(pOperationSemaphoreImpl3);
-}
-
-__code pOperationSemaphoreImpl3(struct SemaphoreImpl* semaphore, struct Worker* worker, __code next(...)) {
- goto worker->taskReceive(); // goto shceduler
-}
-
-__code pOperationSemaphoreImpl3_stub(struct Context* context) {
- // switch worker context
- struct Context* workerContext = context->worker->worker->CPUWorker.context;
- SemaphoreImpl* semaphoreImpl = (SemaphoreImpl*)GearImpl(context, Semaphore, semaphore);
- goto pOperationSemaphoreImpl3(workerContext,
- semaphoreImpl,
- context->worker,
- Gearef(context, Semaphore)->next);
-}
-
-__code vOperationSemaphoreImpl(struct SemaphoreImpl* semaphore, __code next(...)) {
- struct Lock* lock = semaphore->lock;
- goto lock->doLock(vOperationSemaphoreImpl1);
-}
-
-__code vOperationSemaphoreImpl1(struct SemaphoreImpl* semaphore, __code next(...)) {
- semaphore->value++;
- struct Queue* queue = semaphore->waitThreadQueue;
- goto queue->isEmpty(vOperationSemaphoreImpl2, vOperationSemaphoreImpl4);
-}
-
-__code vOperationSemaphoreImpl2(struct SemaphoreImpl* semaphore, __code next(...)) {
- struct Queue* queue = semaphore->waitThreadQueue;
- goto queue->take(vOperationSemaphoreImpl3);
-}
-
-__code vOperationSemaphoreImpl3(struct SemaphoreImpl* semaphore, struct Context* waitTask, __code next(...)) {
- struct TaskManager* taskManager = waitTask->taskManager;
- goto taskManager->spawn(waitTask, vOperationSemaphoreImpl4); //notify
-}
-
-__code vOperationSemaphoreImpl3_stub(struct Context* context) {
- SemaphoreImpl* semaphoreImpl = (SemaphoreImpl*)GearImpl(context, Semaphore, semaphore);
- struct Context* waitTask = &Gearef(context, Queue)->data->Context;
- goto vOperationSemaphoreImpl3(context,
- semaphoreImpl,
- waitTask,
- Gearef(context, Semaphore)->next);
-}
-
-__code vOperationSemaphoreImpl4(struct SemaphoreImpl* semaphore, __code next(...)) {
- struct Lock* lock = semaphore->lock;
- goto lock->doUnlock(next(...));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/consumer.cbc
--- a/src/parallel_execution/examples/boundedBuffer/consumer.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#include "../../../context.h"
-#include
-#interface "Buffer.h"
-
-__code consumer(struct Buffer* buffer, Int length, __code next(...), struct LoopCounter* loopCounter) {
- int i = loopCounter->i;
- if (i < length) {
- loopCounter->i++;
- goto buffer->take(consumer1);
- }
- goto next(...);
-}
-
-__code consumer_stub(struct Context* context) {
- goto consumer(context,
- &context->data[context->idg]->Buffer,
- context->data[context->idg+1]->Int,
- context->next,
- Gearef(context, LoopCounter));
-}
-
-__code consumer1(struct Buffer* buffer, Int length, __code next(...), struct Node* node) {
- printf("getData %d\n", node->value->Int);
- goto consumer();
-}
-
-__code consumer1_stub(struct Context* context) {
- goto consumer1(context,
- &context->data[context->idg]->Buffer,
- context->data[context->idg+1]->Int,
- context->next,
- &Gearef(context, Buffer)->data->Node);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/initBuffer.cbc
--- a/src/parallel_execution/examples/boundedBuffer/initBuffer.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#include "../../../context.h"
-
-__code initBuffer(__code next(struct Buffer* output, Int* output1, ...)) {
- struct Buffer* output = *O_output;
- Int* output1 = *O_output1;
- goto next(output, output1, ...);
-}
-
-__code initBuffer_stub(struct Context* context) {
- struct Buffer** O_output = (struct Buffer**)&context->data[context->odg];
- Int** O_output1 = (Int**)&context->data[context->odg+1];
- goto initBuffer(context,
- context->next,
- O_output,
- O_output1);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/main.cbc
--- a/src/parallel_execution/examples/boundedBuffer/main.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "../../../context.h"
-#interface "TaskManager.h"
-
-int cpu_num = 1;
-int length = 100;
-int buffer_size = 10;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-void *start_taskManager(struct Context *context) {
- goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
- return 0;
-}
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto code1();
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct Timer* timer) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- goto createTask1();
-}
-
-__code code2(struct TaskManager* taskManager) {
- goto taskManager->shutdown(exit_code);
-}
-
-__code code2_stub(struct Context* context) {
- goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
-}
-
-__code createTask1(struct TaskManager* taskManager) {
- struct Buffer* buffer = createBoundedBuffer(context, buffer_size);
- Int* len = new Int();
- *len = length;
- par goto producer(buffer, len, __exit);
- par goto producer(buffer, len, __exit);
- par goto consumer(buffer, len, __exit);
- par goto consumer(buffer, len, __exit);
- par goto initBuffer(buffer, len, __exit);
- goto code2();
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-bufferSize") == 0)
- buffer_size = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-int main(int argc, char** argv) {
- init(argc, argv);
- goto initDataGears();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/boundedBuffer/producer.cbc
--- a/src/parallel_execution/examples/boundedBuffer/producer.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#include "../../../context.h"
-#interface "Buffer.h"
-
-__code producer(struct Buffer* buffer, Int length, __code next(...), struct LoopCounter* loopCounter) {
- int i = loopCounter->i;
- if (i < length) {
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = i;
- loopCounter->i++;
- goto buffer->put(node, producer);
- }
- goto next(...);
-}
-
-__code producer_stub(struct Context* context) {
- goto producer(context,
- &context->data[context->idg]->Buffer,
- context->data[context->idg+1]->Int,
- context->next,
- Gearef(context, LoopCounter));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/calc/add.cbc
--- a/src/parallel_execution/examples/calc/add.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#include "../../../context.h"
-#include
-__code add(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
- struct Integer* output = *O_output;
- output->value = input1->value + input2->value;
- printf("%d + %d = %d\n", input1->value, input2->value, output->value);
- *O_output = output;
- goto meta(context, next);
-}
-
-__code add_stub(struct Context* context) {
- Integer** O_output = (struct Integer **)&context->data[context->odg];
- goto add(context,
- &context->data[context->idg]->Integer,
- &context->data[context->idg + 1]->Integer,
- context->next,
- O_output);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/calc/calc.cbc
--- a/src/parallel_execution/examples/calc/calc.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "../../../context.h"
-#interface "TaskManager.h"
-
-int cpu_num = 1;
-int length = 100;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-void *start_taskManager(struct Context *context) {
- goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
- return 0;
-}
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto meta(context, C_code1);
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct Timer* timer) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- /* puts("queue"); */
- /* print_queue(context->data[ActiveQueue]->queue.first); */
- /* puts("tree"); */
- /* print_tree(context->data[Tree]->tree.root); */
- /* puts("result"); */
-
- //time->next = C_code2;
- goto meta(context, C_createTask1);
- //goto meta(context, C_start_time);
-}
-
-__code code1_stub(struct Context* context) {
- goto code1(context, Gearef(context, Timer));
-}
-
-
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- int i = loopCounter->i;
-
- if (i < length) {
- loopCounter->i++;
- goto meta(context, C_createTask2);
- }
-
- loopCounter->i = 0;
- taskManager->next = C_exit_code;
- goto meta(context, taskManager->taskManager->TaskManager.shutdown);
-}
-
-__code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- Integer* integer1 = new Integer();
- Integer* integer2 = new Integer();
- Integer* integer3 = new Integer();
- par goto mult(integer1, integer2, integer3, __exit);
-
- Integer* integer4 = new Integer();
- Integer* integer5 = new Integer();
- par goto add(integer4, integer5, integer1, __exit);
-
- par goto initIntegerDataGears(integer2, integer4, integer5, __exit);
-
- goto createTask1();
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-int main(int argc, char** argv) {
- init(argc, argv);
- goto initDataGears();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/calc/initIntegerDataGears.cbc
--- a/src/parallel_execution/examples/calc/initIntegerDataGears.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-#include "../../../context.h"
-#include
-__code initIntegerDataGears(__code next(struct Integer* output1, struct Integer* output2, struct Integer* output3, ...)) {
- struct Integer* output1 = *O_output1;
- struct Integer* output2 = *O_output2;
- struct Integer* output3 = *O_output3;
- output1->value = 1;
- output2->value = 2;
- output3->value = 3;
- *O_output1 = output1;
- *O_output2 = output2;
- *O_output3 = output3;
- goto meta(context, next);
-}
-
-__code initIntegerDataGears_stub(struct Context* context) {
- Integer** O_output1 = (struct Integer **)&context->data[context->odg];
- Integer** O_output2 = (struct Integer **)&context->data[context->odg+1];
- Integer** O_output3 = (struct Integer **)&context->data[context->odg+2];
- goto initIntegerDataGears(context,
- context->next,
- O_output1,
- O_output2,
- O_output3);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/calc/mult.cbc
--- a/src/parallel_execution/examples/calc/mult.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-#include "../../../context.h"
-#include
-__code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
- struct Integer* output = *O_output;
- output->value = input1->value * input2->value;
- printf("%d * %d = %d\n", input1->value, input2->value, output->value);
- *O_output = output;
- goto meta(context, next);
-}
-
-__code mult_stub(struct Context* context) {
- Integer** O_output = (struct Integer **)&context->data[context->odg];
- goto mult(context,
- &context->data[context->idg]->Integer,
- &context->data[context->idg + 1]->Integer,
- context->next,
- O_output);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/twice/CUDAtwice.cu
--- a/src/parallel_execution/examples/twice/CUDAtwice.cu Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-extern "C" {
- struct Array {
- int prefix;
- int* array;
- } Array;
-
- __global__ void twice(int* array, struct Array* inputArray) {
- int i = 0;
- int prefix = inputArray->prefix;
-C_twice:
- if (i < prefix) {
- array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix] = array[i+(blockIdx.x*blockDim.x+threadIdx.x)*prefix]*2;
- i++;
- goto C_twice;
- }
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/twice/createArray.cbc
--- a/src/parallel_execution/examples/twice/createArray.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-#include
-#include "../../../context.h"
-#interface "Timer.h"
-
-extern int length;
-extern int split;
-
-__code createArray(__code next(struct Array* output, struct Timer* output1, ...), struct LoopCounter* loopCounter) {
- struct Array* output = *O_output;
- struct Timer* output1 = *O_output1;
- int i = loopCounter->i;
- if (i == 0){
- output->array = (Int*)ALLOCATE_ARRAY(context, Int, length);
- output->prefix = length/split;
- }
- if (i == GET_LEN(output->array)){
- printf("created Array\n");
- loopCounter->i = 0;
- *O_output = output;
- *O_output1 = output1;
- goto output1->start(next(...));
- }
- output->array[i] = i;
- loopCounter->i++;
- *O_output = output;
- *O_output1 = output1;
- goto meta(context, C_createArray);
-}
-
-__code createArray_stub(struct Context* context) {
- Array** O_output = (struct Array **)&context->data[context->odg];
- Timer** O_output1 = (struct Timer**)&context->data[context->odg+1];
- goto createArray(context,
- context->next,
- O_output,
- O_output1,
- Gearef(context, LoopCounter));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/twice/main.cbc
--- a/src/parallel_execution/examples/twice/main.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "../../../context.h"
-#interface "TaskManager.h"
-
-int cpu_num = 1;
-int length = 102400;
-int split = 8;
-int* array_ptr;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-void *start_taskManager(struct Context *context) {
- goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
- return 0;
-}
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto code1();
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct LoopCounter* loopCounter) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- printf("length/task:\t%d\n", length/split);
- /* puts("queue"); */
- /* print_queue(context->data[ActiveQueue]->queue.first); */
- /* puts("tree"); */
- /* print_tree(context->data[Tree]->tree.root); */
- /* puts("result"); */
- goto createTask1();
-}
-
-
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- Array* array1 = new Array();
- Array* array2 = new Array();
- Timer* timer = createTimerImpl(context);
-
- par goto createArray(array1, timer, __exit);
- par goto twice(array1, array2, iterate(split), __exit);
- par goto printArray(array2, timer, __exit);
- goto code2();
-}
-
-__code code2(struct TaskManager* taskManager) {
- goto taskManager->shutdown(exit_code);
-}
-
-__code code2_stub(struct Context* context) {
- goto code2(context, &Gearef(context, TaskManager)->taskManager->TaskManager);
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-s") == 0)
- split = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-int main(int argc, char** argv) {
- init(argc, argv);
- goto initDataGears();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/twice/printArray.cbc
--- a/src/parallel_execution/examples/twice/printArray.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#include "../../../context.h"
-#interface "Timer.h"
-#include
-
-__code printArray(struct Array* array, struct Timer* inputTimer, __code next(...)){
- goto inputTimer->end(printArray1);
-}
-
-__code printArray_stub(struct Context* context) {
- goto printArray(context,
- &context->data[context->idg]->Array,
- &context->data[context->idg+1]->Timer,
- context->next);
-}
-
-__code printArray1(struct Array* array, __code next(...), struct LoopCounter* loopCounter){
- int i = loopCounter->i;
- //printf("%d\n", array->array[i]);
- if(i < GET_LEN(array->array)) {
- if (array->array[i] == i*2) {
- loopCounter->i++;
- goto meta(context, C_printArray1);
- } else {
- printf("wrong result\n");
- }
- }
- loopCounter->i = 0;
- goto meta(context, next);
-}
-
-__code printArray1_stub(struct Context* context) {
- goto printArray1(context,
- &context->data[context->idg]->Array,
- context->next,
- Gearef(context, LoopCounter));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/examples/twice/twice.cbc
--- a/src/parallel_execution/examples/twice/twice.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#include
-
-#include "../../../context.h"
-
-#ifdef USE_CUDAWorker
-extern void cudaLoadFunction(struct Context* context, char* filename, char* function);
-#endif
-
-__code twice(struct Array* array, struct MultiDim* multiDim, __code next(struct Array* output, ...), struct LoopCounter* loopCounter) {
- struct Array* output = *O_output;
- int i = loopCounter->i;
- int index = multiDim->x;
- if (i < array->prefix) {
- array->array[i+index*array->prefix] = array->array[i+index*array->prefix]*2;
- loopCounter->i++;
-
- goto meta(context, C_twice);
- }
-
- loopCounter->i = 0;
- output->array = array->array;
- goto meta(context, context->next);
-}
-
-__code twice_stub(struct Context* context) {
-#ifdef USE_CUDAWorker
- if (context->gpu) {
- Array* inputArray = &context->data[context->idg]->Array;
- Array* outputArray = &context->data[context->odg]->Array;
- CUDABuffer* buffer = &ALLOCATE(context, CUDABuffer)->CUDABuffer;
- buffer->inputData = (union Data**)ALLOCATE_PTR_ARRAY(context, Array, 2);
- buffer->inputData[0] = (union Data*)inputArray->array;
- buffer->inputData[1] = (union Data*)inputArray;
- buffer->outputData = NULL;
- buffer->inputLen = 2;
- buffer->outputLen = 0;
- Executor* executor = context->worker->worker->CUDAWorker.executor;
- executor->executor->CUDAExecutor.buffer = buffer;
- cudaLoadFunction(context, "c/examples/twice/CUDAtwice.ptx", "twice");
- outputArray->array = inputArray->array;
- Gearef(context, Executor)->executor = (union Data*)executor;
- Gearef(context, Executor)->task = context;
- Gearef(context, Executor)->next = context->next;
- goto meta(context, executor->read);
- }
-#endif
- Array** O_output = (struct Array **)&context->data[context->odg];
- goto twice(context,
- &context->data[context->idg]->Array,
- &context->data[context->idg+1]->MultiDim,
- context->next,
- O_output,
- Gearef(context, LoopCounter));
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/generate_context.pl
--- a/src/parallel_execution/generate_context.pl Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,225 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Std;
-use strict;
-
-#
-# generrate Gears OS context heaader and initializer from CbC sources
-#
-# CodeGear
-#
-# get stub information from # *.c
-# __code taskManager_stub(struct Context* context) {
-#
-# generate CodeGear indexn in context.h
-# C_taskManager,
-#
-# generate CodeGear stub reference in context.h
-# extern __code taskManager_stub(struct Context*);
-#
-# generate CodeGear stub reference in $name-context.h for each module
-# context->code[C_taskManager] = taskManager_stub;
-#
-# DataGear
-#
-# get DataGear information from context.h
-# struct Worker {
-# int id;
-# struct Context* contexts;
-# enum Code execute;
-# enum Code taskSend;
-# enum Code taskRecive;
-# enum Code shutdown;
-# struct Queue* tasks;
-# } Worker;
-#
-# generate typedefs and DataGear index in context.h
-# typedef struct Worker Worker;
-# D_Worker,
-#
-# generate DataGear allocator in context.h
-# ALLOC_DATA(context, Worker);
-#
-
-my $ddir = "c";
-
-our($opt_o,$opt_d,$opt_h);
-getopts('o:d:h');
-
-my $name = $opt_o?$opt_o:"gears";
-
-if ($opt_d) {
- $ddir = $opt_d;
-}
-
-if ( ! -d $ddir) {
- mkdir $ddir;
-}
-
-if ($opt_h) {
- print "$0 [-d distdir] [-h]\n";
- exit;
-}
-
-my %codeGear;
-my %dataGear;
-my %constructor;
-
-# gather module Information for code table initialization
-for (@ARGV) {
- next if (/context.c/);
- &getStubInfo($_);
-}
-
-my (%mCodeGear) = (%codeGear);
-
-# anyway we gather all Gears Information
-while (<*.c test/*.c>) {
- next if (/context.c/);
- &getStubInfo($_);
-}
-
-&generateContext();
-
-sub getStubInfo {
- my ($filename) = @_;
- open my $fd,"<",$filename or die("can't open $filename $!");
- while (<$fd>) {
- if (/^__code (\w+)_stub\(struct *Context *\* *context\)/) {
- $codeGear{$1} = $filename;
- } elsif (/^(\w+)(\*)+ *create(\w+)\(([^]]*)\)/) {
- my $interface = $1;
- my $implementation = $3;
- my $constructorArgs = $4;
- $constructor{$implementation} = [$interface, $constructorArgs];
- }
- }
-
- open my $cx,"<","context.h" or die("can't open context.h $!");
- my $inUnionData = 0;
- while (<$cx>) {
- if (! $inUnionData) {
- if ( /^union Data/) {
- $inUnionData = 1;
- }
- next;
- }
- last if (/union Data end/);
- if (/struct (\w+) \{/) {
- $dataGear{$1} = 'struct';
- } elsif (/^\s{4}(\w+) (\w+);/) { # primitive type
- $dataGear{$1} = 'primitive';
- }
- $dataGear{"Context"} = "struct";
- }
-}
-
-sub generateContext {
- $codeGear{"start_code"} = "$ddir/$name-context.c";
- $codeGear{"exit_code"} = "$ddir/$name-context.c";
- $mCodeGear{"start_code"} = "$ddir/$name-context.c";
- $mCodeGear{"exit_code"} = "$ddir/$name-context.c";
- open my $fd,">","$ddir/extern.h" or die("can't open $ddir/extern.h $!");
- for my $code ( sort keys %codeGear ) {
- print $fd "extern __code ${code}_stub(struct Context*);\n";
- }
- for my $impl ( sort keys %constructor ) {
- my ($interface, $constructorArgs) = @{$constructor{$impl}};
- print $fd "extern ${interface}* create${impl}($constructorArgs);\n";
- }
- print $fd "\n";
-
- open my $fd,">","$ddir/enumCode.h" or die("can't open $ddir/enumCode.h $!");
- print $fd "enum Code {\n";
- for my $code ( sort keys %codeGear ) {
- print $fd " C_${code},\n";
- }
- print $fd "};\n";
-
- my $code_init = '';
- for my $code ( sort keys %mCodeGear ) {
- $code_init .= " context->code[C_${code}] = ${code}_stub;\n";
- }
-
- my $data_num = keys(%dataGear);
- $data_num++;
-my $context_c = << "EOFEOF";
-#include
-
-#include "../context.h"
-
-void initContext(struct Context* context) {
- context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE;
- context->code = (__code(**) (struct Context*)) NEWN(ALLOCATE_SIZE, void*);
- context->data = NEWN(ALLOCATE_SIZE, union Data*);
- context->heapStart = NEWN(context->heapLimit, char);
- context->heap = context->heapStart;
- // context->codeNum = Exit;
-
-$code_init
-
-#include "dataGearInit.c"
- context->dataNum = $data_num;
-}
-EOFEOF
-
- open my $fd,">","$ddir/$name-context.c" or die("can't open $ddir/$name-context.c $!");
- print $fd $context_c;
-
-my $meta_call = <<"EOFEOF";
-__code meta(struct Context* context, enum Code next) {
- // printf("meta %d\\n",next);
- if (context->task == NULL) {
- goto (context->code[next])(context);
- }
- context->task = NULL;
- context->taskList = NULL;
- goto (context->code[Gearef(context, TaskManager)->taskManager->TaskManager.spawnTasks])(context);
-}
-
-__code start_code(struct Context* context) {
- goto meta(context, context->next);
-}
-
-__code start_code_stub(struct Context* context) {
- goto start_code(context);
-}
-
-__code exit_code(struct Context* context) {
- free(context->code);
- free(context->data);
- free(context->heapStart);
- goto exit(0);
-}
-
-__code exit_code_stub(struct Context* context) {
- goto exit_code(context);
-}
-
-// end context_c
-EOFEOF
-
-print $fd $meta_call;
-
-open my $fd,">","$ddir/enumData.h" or die("can't open $ddir/enumData.h $!");
-print $fd "enum DataType {\n";
-print $fd " D_Code,\n";
-for my $data ( sort keys %dataGear ) {
- print $fd " D_${data},\n";
-}
-print $fd "};\n\n";
-
-open my $fd,">","$ddir/typedefData.h" or die("can't open $ddir/typedefData.h $!");
-for my $data ( sort keys %dataGear ) {
- if ($dataGear{$data} eq 'struct') {
- print $fd "typedef struct ${data} ${data};\n";
- }
-}
-
-open my $fd,">","$ddir/dataGearInit.c" or die("can't open $ddir/dataGearInit.c $!");
-for my $data ( sort keys %dataGear ) {
- print $fd " ALLOC_DATA(context, ${data});\n";
-}
-}
-
-# end
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/generate_stub.pl
--- a/src/parallel_execution/generate_stub.pl Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,581 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use Getopt::Std;
-use File::Path qw(make_path);
-
-# interface.h
-# typedef struct Worker {
-# int id;
-# struct Context* contexts;
-# enum Code execute;
-# enum Code taskSend;
-# enum Code taskRecive;
-# enum Code shutdown;
-# struct Queue* tasks;
-# } Worker;
-
-our($opt_o,$opt_d,$opt_h);
-getopts('o:d:h');
-
-my $dir = ".";
-if ($opt_d) {
- $dir = $opt_d;
- if (! -d $dir) {
- make_path $dir;
- }
-}
-
-for my $fn (@ARGV) {
- next if ($fn !~ /\.cbc$/);
- &getDataGear($fn);
- &generateDataGear($fn);
-}
-
-my %var;
-my %code;
-my %dataGearVar;
-my %outputVar; # output var initializer
-my %outputArgs; # continuation's output variables
-my %dataGear;
-my %dataGearName;
-my %generic;
-my %dataGearVarType;
-my %codeGear;
-my $implementation;
-my $interface;
-
-# interface definision
-#
-# typedef struct Stack{
-# Type* stack;
-# Type* data;
-# Type* data1;
-# __code whenEmpty(...);
-# __code clear(Impl* stack,__code next(...));
-# __code push(Impl* stack,Type* data, __code next(...));
-# __code pop(Impl* stack, __code next(Type*, ...));
-# __code pop2(Impl* stack, Type** data, Type** data1, __code next(Type**, Type**, ...));
-# __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
-# __code get(Impl* stack, Type** data, __code next(...));
-# __code get2(Impl* stack,..., __code next(...));
-# __code next(...);
-# } Stack;
-#
-# calling example
-#
-# goto nodeStack->push((union Data*)node, stackTest3);
-#
-# generated meta level code
-#
-# Gearef(context, Stack)->stack = (union Data*)nodeStack;
-# Gearef(context, Stack)->data = (union Data*)node;
-# Gearef(context, Stack)->next = C_stackTest3;
-# goto meta(context, nodeStack->push);
-
-sub getDataGear {
- my ($filename) = @_;
- my ($codeGearName, $name, $inTypedef);
- open my $fd,"<",$filename or die("can't open $filename $!");
- while (<$fd>) {
- if (! $inTypedef) {
- if (/^typedef struct (\w+)\s*<(.*)>/) {
- $inTypedef = 1;
- $name = $1;
- $dataGear{$name} = $_;
- $var{$name} = {};
- $code{$name} = {};
- $generic{$name} = \split(/,/,$2);
- } elsif (/^typedef struct (\w+)/) {
- $inTypedef = 1;
- $name = $1;
- $dataGear{$name} = $_;
- $var{$name} = {};
- $code{$name} = {};
- $generic{$name} = [];
- } elsif (/^(\w+)(\*)+ create(\w+)\(/) {
- if (defined $interface) {
- die "duplicate interface $interface\n";
- }
- $interface = $1;
- $implementation = $3;
- if ( -f "$interface.cbc") {
- &getDataGear("$interface.cbc");
- }
- } elsif(/^(.*)par goto (\w+)\((.*)\)/) {
- my $codeGearName = $2;
- if ($filename =~ /^(.*)\/(.*)/) {
- $codeGearName = "$1/$codeGearName";
- }
- if ( -f "$codeGearName.cbc") {
- &getCodeGear("$codeGearName.cbc");
- }
- } elsif(/^#interface "(.*)"/) {
- # use interface
- my $interfaceHeader = $1;
- next if ($interfaceHeader =~ /context.h/);
- if (-f $interfaceHeader) {
- &getDataGear("$interfaceHeader");
- &getCodeGear("$interfaceHeader");
- }
- }
- next;
- }
- # gather type name and type
- $dataGear{$name} .= $_;
- if (/^\s*(.*)\s+(\w+);$/ ) {
- my $ttype = $1;
- my $tname = $2;
- if ($ttype =~ /^(union|struct)?\s*(\w+)/) {
- $ttype = $2;
- }
- $var{$name}->{$tname} = $ttype;
- }
- if (/^}/) {
- $inTypedef = 0;
- }
- }
-
-}
-
-sub getCodeGear {
- my ($filename) = @_;
- open my $fd,"<",$filename or die("can't open $filename $!");
- my ($name,$impln);
- while (<$fd>) {
- if (/^(\w+)(\*)+ create(\w+)\(/) {
- $name = $1;
- $impln = $3;
- } elsif(/^typedef struct (.*)<.*>\s*{/) {
- $name = $1;
- }
- if (defined $name) {
- if (/^\s*\_\_code (\w+)\((.*)\);/) {
- my $args = $2;
- my $method = $1;
- $code{$name}->{$method} = [];
- while($args) {
- # replace comma
- $args =~ s/(^\s*,\s*)//;
- # continuation case
- if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) {
- my $next = $2;
- my @args = split(/,/,$3);
- push(@{$code{$name}->{$method}},"\_\_code $next");
- } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s+(\w+)//) {
- my $structType = $1;
- my $typeName = $2;
- my $ptrType = $3;
- my $varName = $4;
- my $typeField = lcfirst($typeName);
- push(@{$code{$name}->{$method}},"$typeName$ptrType $varName");
- } elsif ($args =~ s/(.*,)//) {
- } else {
- last;
- }
- }
- }
- } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) {
- my $codeGearName = $1;
- my $args = $2;
- my $inputCount = 0;
- my $outputCount = 0;
- my $inputIncFlag = 1;
- while($args) {
- if ($args =~ s/(^\s*,\s*)//) {
- }
- if ($args =~ s/^(\s)*\_\_code\s+(\w+)\((.*?)\)//) {
- $inputIncFlag = 0;
- $outputCount = split(/,/,$3);
- $outputCount--;
- } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)?+\s(\w+)//) {
- if($inputIncFlag) {
- $inputCount++;
- }
- } elsif ($args =~ s/(.*,)//) {
- } else {
- last;
- }
- }
- $codeGear{$codeGearName}->{"input"} = $inputCount;
- $codeGear{$codeGearName}->{"output"} = $outputCount;
- }
- }
-}
-
-sub generateStub {
- my($fd,$prevCodeGearName,$dataGearName) = @_;
- print $fd "__code ", $prevCodeGearName ,"_stub(struct Context* context) {\n";
- print $fd $dataGearName;
- print $fd "\n} \n\n";
- return 1;
-}
-
-sub generateStubArgs {
- my($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,$output) = @_;
- my $varname1 = $output?"O_$varName":$varName;
- for my $n ( @{$dataGearVar{$codeGearName}} ) {
- # we already have it
- return 0 if ( $n eq $varname1);
- }
- push @{$dataGearVar{$codeGearName}}, $varname1;
- push @{$dataGearVarType{$codeGearName}}, $typeName;
- if ($typeName eq $implementation) {
- # get implementation
- $dataGearName{$codeGearName} .= "\t$typeName* $varName = ($typeName*)GearImpl(context, $interface, $varName);\n";
- } else {
- for my $ivar (keys %{$var{$interface}}) {
- # input data gear field
- if ($varName eq $ivar) {
- if ($typeName eq $var{$interface}->{$ivar}) {
- if ($output) {
- $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef(context, $interface)->$varName;\n";
- $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName = *O_$varName;\n";
- return 1;
- }
-
- $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
- return 1;
- }
- }
- }
- for my $cName (keys %{$code{$interface}}) {
- if ($varName eq $cName) {
- # continuation field
- $dataGearName{$codeGearName} .= "\tenum Code $varName = Gearef(context, $interface)->$varName;\n";
- return 1;
- }
- }
- # global or local variable case
- if ($typeName eq "Code") {
- $dataGearName{$codeGearName} .= "\tenum $typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
- return 1;
- }
- $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $typeName);\n";
- return 1;
- }
-}
-
-sub generateDataGear {
- my ($filename) = @_;
- open my $in,"<",$filename or die("can't open $filename $!");
-
- my $fn;
- if ($opt_o) {
- $fn = $opt_o;
- } else {
- my $fn1 = $filename;
- $fn1 =~ s/\.cbc/.c/;
- my $i = 1;
- $fn = "$dir/$fn1";
- while ( -f $fn) {
- $fn = "$dir/$fn1.$i";
- $i++;
- }
- }
- if ( $fn =~ m=(.*)/[^/]+$= ) {
- if (! -d $1) {
- make_path $1;
- }
- }
- open my $fd,">",$fn or die("can't write $fn $!");
-
- my $prevCodeGearName;
- my $inTypedef = 0;
- my $inStub = 0;
- my $inParGoto = 0;
- my $inMain = 0 ;
- my %stub;
- my $codeGearName;
- my %localVarType;
-
- while (<$in>) {
- if (! $inTypedef && ! $inStub && ! $inMain) {
- if (/^typedef struct (\w+) \{/) {
- $inTypedef = 1;
- } elsif (/^int main\((.*)\) \{/) {
- $inMain = 1;
- } elsif(/^#interface "(.*)"/) {
- my $interfaceHeader = $1;
- # #interface not write
- next unless ($interfaceHeader =~ /context.h/);
- } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) {
- %localVarType = {};
- $codeGearName = $1;
- my $args = $2;
- my $tail = $3;
- if ($codeGearName =~ /_stub$/) {
- # don't touch already existing stub
- $inStub = 1;
- $stub{$codeGearName} = 1;
- print $fd $_;
- next;
- }
- if (defined $prevCodeGearName) {
- # stub is generated just before next CodeGear
- if (defined $stub{$prevCodeGearName."_stub"}) {
- undef $prevCodeGearName;
- } else {
- &generateStub($fd,$prevCodeGearName,$dataGearName{$prevCodeGearName});
- $stub{$prevCodeGearName."_stub"} = 1;
- }
- }
- # analyzing CodeGear argument
- # these arguments are extract from current context's arugment DataGear Interface
- # and passed to the CodeGear
- # struct Implementaion needs special handling
- # __code next(...) ---> enum Code next
- $prevCodeGearName = $codeGearName;
- $dataGearVar{$codeGearName} = [];
- $outputVar{$codeGearName} = "";
- $outputArgs{$codeGearName} = {};
- my $newArgs = "struct Context *context,";
- if ($args=~/^struct Context\s*\*\s*context/) {
- $newArgs = "";
- }
- while($args) {
- if ($args =~ s/(^\s*,\s*)//) {
- $newArgs .= $1;
- }
- # continuation case
- if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) {
- my $next = $2;
- my @args = split(/,/,$3);
- if (&generateStubArgs($codeGearName, $next, "Code", "", $next, $interface,0) ) {
- $newArgs .= "enum Code $next";
- }
- # analyze continuation arguments
- # output arguments are defined in the Interface take the pointer of these
- # output arguments are put into the Interface DataGear just before the goto
- for my $arg (@args) {
- $arg =~ s/^\s*//;
- last if ($arg =~ /\.\.\./);
- $arg =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//;
- my $structType = $1;
- my $typeName = $2;
- my $ptrType = $3;
- my $varName = $4;
- my $typeField = lcfirst($typeName);
- push(@{$outputArgs{$codeGearName}->{$next}}, $varName);
- if (&generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,1)) {
- $newArgs .= ",$structType $typeName **O_$varName";
- }
- }
- } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s(\w+)//) {
- my $structType = $1;
- my $typeName = $2;
- my $ptrType = $3;
- my $varName = $4;
- my $typeField = lcfirst($typeName);
- $newArgs .= $&; # assuming no duplicate
- &generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,0);
- } elsif ($args =~ s/(.*,)//) {
- $newArgs .= $1;
- } else {
- $newArgs .= $args;
- last;
- }
- }
- # generate goto statement from stub to the CodeGear in the buffer
- $dataGearName{$codeGearName} .= "\tgoto $codeGearName(context";
- for my $arg ( @{$dataGearVar{$codeGearName}}) {
- $dataGearName{$codeGearName} .= ", $arg";
- }
- $dataGearName{$codeGearName} .= ");";
- # generate CodeGear header with new arguments
- print $fd "__code $codeGearName($newArgs)$tail\n";
- if ($outputVar{$codeGearName} ne "") {
- # output data var can be use before write
- # it should be initialze by gearef
- print $fd $outputVar{$codeGearName};
- }
- next;
- } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) {
- # handling goto statement
- # convert it to the meta call form with two arugments, that is context and enum Code
- my $prev = $1;
- my $next = $2;
- my $method = $3;
- my @args = split(/,/,$4);
- my @types = @{$dataGearVarType{$codeGearName}};
- my $ntype;
- my $ftype;
- for my $v (@{$dataGearVar{$codeGearName}}) {
- my $t = shift @types;
- if ($v eq $next) {
- $ntype = $t;
- $ftype = lcfirst($ntype);
- }
- }
- if (!defined $ntype) {
- $ntype = $localVarType{$next};
- $ftype = lcfirst($ntype);
- }
- print $fd "\tGearef(context, $ntype)->$ftype = (union Data*) $next;\n";
- # Put interface argument
- my $prot = $code{$ntype}->{$method};
- my $i = 1;
- for my $arg (@args) {
- my $pType;
- my $pName;
- my $p = @$prot[$i];
- next if ($p eq $arg);
- $p =~ s/^(.*)\s(\w+)//;
- $pType = $1;
- $pName = $2;
- $arg =~ s/^(\s)*(\w+)/$2/;
- if ($pType =~ s/\_\_code$//) {
- if ($arg =~ /(\w+)\(.*\)/) {
- print $fd "\tGearef(context, $ntype)->$pName = $1;\n";
- } else {
- print $fd "\tGearef(context, $ntype)->$pName = C_$arg;\n";
- }
- } elsif ($pType =~ /Data\**$/){
- print $fd "\tGearef(context, $ntype)->$pName = (union $pType) $arg;\n";
- } else {
- print $fd "\tGearef(context, $ntype)->$pName = $arg;\n";
- }
- $i++;
- }
- print $fd "${prev}goto meta(context, $next->$method);\n";
- next;
- } elsif(/^(.*)par goto (\w+)\((.*)\);/) {
- # handling par goto statement
- # convert it to the parallel
- my $prev = $1;
- my $codeGearName = $2;
- my $args = $3;
- my $inputCount = $codeGear{$codeGearName}->{'input'};
- my $outputCount = $codeGear{$codeGearName}->{'output'};
- my @iterateCounts;
- # parse examples 'par goto(.., iterate(10), exit);'
- if ($args =~ /iterate\((.*)?\),/) {
- @iterateCounts = split(/,/,$1);;
- $inputCount--;
- }
- # replace iterate keyword
- $args =~ s/iterate\((.*)?\),//;
- my @dataGears = split(/,\s*/, $args);
- my $nextCodeGear = pop(@dataGears);
- if (! $inParGoto) {
- $inParGoto = 1;
- print $fd "${prev}struct Element* element;\n";
- }
- my $initTask = << "EOFEOF";
- ${prev}context->task = NEW(struct Context);
- ${prev}initContext(context->task);
- ${prev}context->task->next = C_$codeGearName;
- ${prev}context->task->idgCount = $inputCount;
- ${prev}context->task->idg = context->task->dataNum;
- ${prev}context->task->maxIdg = context->task->idg + $inputCount;
- ${prev}context->task->odg = context->task->maxIdg;
- ${prev}context->task->maxOdg = context->task->odg + $outputCount;
-EOFEOF
- print $fd $initTask;
- if (@iterateCounts) {
- print $fd "${prev}context->task->iterate = 0;\n";
- my $len = @iterateCounts;
- if ($len == 1) {
- print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], 1, 1);\n";
- } elsif ($len == 2) {
- print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], 1);\n";
- } elsif ($len == 3) {
- print $fd "${prev}context->task->iterator = createMultiDimIterator(context, $iterateCounts[0], $iterateCounts[1], $iterateCounts[2]);\n";
- }
- }
- for my $dataGear (@dataGears) {
- print $fd "${prev}GET_META($dataGear)->wait = createSynchronizedQueue(context);\n";
- }
- for my $i (0..$inputCount-1) {
- print $fd "${prev}context->task->data[context->task->idg+$i] = (union Data*)@dataGears[$i];\n";
- }
- for my $i (0..$outputCount-1) {
- print $fd "${prev}context->task->data[context->task->odg+$i] = (union Data*)@dataGears[$inputCount+$i];\n";
- }
- my $putTask = << "EOFEOF";
- ${prev}element = &ALLOCATE(context, Element)->Element;
- ${prev}element->data = (union Data*)context->task;
- ${prev}element->next = context->taskList;
- ${prev}context->taskList = element;
-EOFEOF
- print $fd $putTask;
- next;
- } elsif (/^(.*)goto (\w+)\((.*)\);/) {
- # handling goto statement
- # convert it to the meta call form with two arugments, that is context and enum Code
- my $prev = $1;
- my $next = $2;
- my @args = split(/, /,$3);
- my $v = 0;
- for my $n ( @{$dataGearVar{$codeGearName}} ) {
- # continuation arguments
- $v = 1 if ( $n eq $next);
- }
- if ($v || defined $code{$interface}->{$next}) {
- # write continuation's arguments into the interface arguments
- # we may need a commit for a shared DataGear
- for my $arg ( @{$outputArgs{$codeGearName}->{$next}} ) {
- my $v = shift(@args);
- print $fd "\t*O_$arg = $v;\n";
- }
- if ($inParGoto) {
- print $fd "${prev}Gearef(context, TaskManager)->taskList = context->taskList;\n";
- print $fd "${prev}Gearef(context, TaskManager)->next1 = C_$next;\n";
- print $fd "${prev}goto meta(context, C_$next);\n";
- } else {
- print $fd "${prev}goto meta(context, $next);\n";
- }
- next;
- }
- if ($inParGoto) {
- print $fd "${prev}Gearef(context, TaskManager)->taskList = context->taskList;\n";
- print $fd "${prev}Gearef(context, TaskManager)->next1 = C_$next;\n";
- print $fd "${prev}goto meta(context, C_$next);\n";
- next;
- } elsif ($next eq "meta") {
- print $fd $_;
- next;
- } else {
- print $fd "${prev}goto meta(context, C_$next);\n";
- next;
- }
- } elsif(/^.*(struct|union)?\s(\w+)\*\s(\w+)\s?[=;]/) {
- my $type = $2;
- my $varName = $3;
- $localVarType{$varName} = $type;
- s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new
- } elsif(/^}/) {
- $inParGoto = 0;
- } else {
- s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new
- }
- # gather type name and type
- } elsif ($inMain) {
- if (/^(.*)goto start_code\(main_context\);/) {
- print $fd $_;
- next;
- } elsif (/^(.*)goto (\w+)\((.*)\);/) {
- my $prev = $1;
- my $next = $2;
- print $fd "${prev}struct Context* main_context = NEW(struct Context);\n";
- print $fd "${prev}initContext(main_context);\n";
- print $fd "${prev}main_context->next = C_$next;\n";
- print $fd "${prev}goto start_code(main_context);\n";
- next;
- }
- }
- if (/^}/) {
- $inStub = 0;
- $inTypedef = 0;
- $inMain = 0;
- }
- print $fd $_;
- }
- if (defined $prevCodeGearName) {
- if (!defined $stub{$prevCodeGearName."_stub"}) {
- $stub{$prevCodeGearName."_stub"} = &generateStub($fd,$prevCodeGearName,$dataGearName{$codeGearName});
- }
- }
-}
-
-# end
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/helper_cuda.h
--- a/src/parallel_execution/helper_cuda.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1088 +0,0 @@
-/**
- * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
- *
- * Please refer to the NVIDIA end user license agreement (EULA) associated
- * with this source code for terms and conditions that govern your use of
- * this software. Any use, reproduction, disclosure, or distribution of
- * this software and related documentation outside the terms of the EULA
- * is strictly prohibited.
- *
- */
-
-////////////////////////////////////////////////////////////////////////////////
-// These are CUDA Helper functions for initialization and error checking
-
-#ifndef HELPER_CUDA_H
-#define HELPER_CUDA_H
-
-#pragma once
-
-#include
-#include
-#include
-
-#include "helper_string.h"
-
-#ifndef EXIT_WAIVED
-#define EXIT_WAIVED 2
-#endif
-
-// Note, it is required that your SDK sample to include the proper header files, please
-// refer the CUDA examples for examples of the needed CUDA headers, which may change depending
-// on which CUDA functions are used.
-
-// CUDA Runtime error messages
-#ifndef __DRIVER_TYPES_H__
-static const char *_cudaGetErrorEnum(cudaError_t error)
-{
- switch (error)
- {
- case cudaSuccess:
- return "cudaSuccess";
-
- case cudaErrorMissingConfiguration:
- return "cudaErrorMissingConfiguration";
-
- case cudaErrorMemoryAllocation:
- return "cudaErrorMemoryAllocation";
-
- case cudaErrorInitializationError:
- return "cudaErrorInitializationError";
-
- case cudaErrorLaunchFailure:
- return "cudaErrorLaunchFailure";
-
- case cudaErrorPriorLaunchFailure:
- return "cudaErrorPriorLaunchFailure";
-
- case cudaErrorLaunchTimeout:
- return "cudaErrorLaunchTimeout";
-
- case cudaErrorLaunchOutOfResources:
- return "cudaErrorLaunchOutOfResources";
-
- case cudaErrorInvalidDeviceFunction:
- return "cudaErrorInvalidDeviceFunction";
-
- case cudaErrorInvalidConfiguration:
- return "cudaErrorInvalidConfiguration";
-
- case cudaErrorInvalidDevice:
- return "cudaErrorInvalidDevice";
-
- case cudaErrorInvalidValue:
- return "cudaErrorInvalidValue";
-
- case cudaErrorInvalidPitchValue:
- return "cudaErrorInvalidPitchValue";
-
- case cudaErrorInvalidSymbol:
- return "cudaErrorInvalidSymbol";
-
- case cudaErrorMapBufferObjectFailed:
- return "cudaErrorMapBufferObjectFailed";
-
- case cudaErrorUnmapBufferObjectFailed:
- return "cudaErrorUnmapBufferObjectFailed";
-
- case cudaErrorInvalidHostPointer:
- return "cudaErrorInvalidHostPointer";
-
- case cudaErrorInvalidDevicePointer:
- return "cudaErrorInvalidDevicePointer";
-
- case cudaErrorInvalidTexture:
- return "cudaErrorInvalidTexture";
-
- case cudaErrorInvalidTextureBinding:
- return "cudaErrorInvalidTextureBinding";
-
- case cudaErrorInvalidChannelDescriptor:
- return "cudaErrorInvalidChannelDescriptor";
-
- case cudaErrorInvalidMemcpyDirection:
- return "cudaErrorInvalidMemcpyDirection";
-
- case cudaErrorAddressOfConstant:
- return "cudaErrorAddressOfConstant";
-
- case cudaErrorTextureFetchFailed:
- return "cudaErrorTextureFetchFailed";
-
- case cudaErrorTextureNotBound:
- return "cudaErrorTextureNotBound";
-
- case cudaErrorSynchronizationError:
- return "cudaErrorSynchronizationError";
-
- case cudaErrorInvalidFilterSetting:
- return "cudaErrorInvalidFilterSetting";
-
- case cudaErrorInvalidNormSetting:
- return "cudaErrorInvalidNormSetting";
-
- case cudaErrorMixedDeviceExecution:
- return "cudaErrorMixedDeviceExecution";
-
- case cudaErrorCudartUnloading:
- return "cudaErrorCudartUnloading";
-
- case cudaErrorUnknown:
- return "cudaErrorUnknown";
-
- case cudaErrorNotYetImplemented:
- return "cudaErrorNotYetImplemented";
-
- case cudaErrorMemoryValueTooLarge:
- return "cudaErrorMemoryValueTooLarge";
-
- case cudaErrorInvalidResourceHandle:
- return "cudaErrorInvalidResourceHandle";
-
- case cudaErrorNotReady:
- return "cudaErrorNotReady";
-
- case cudaErrorInsufficientDriver:
- return "cudaErrorInsufficientDriver";
-
- case cudaErrorSetOnActiveProcess:
- return "cudaErrorSetOnActiveProcess";
-
- case cudaErrorInvalidSurface:
- return "cudaErrorInvalidSurface";
-
- case cudaErrorNoDevice:
- return "cudaErrorNoDevice";
-
- case cudaErrorECCUncorrectable:
- return "cudaErrorECCUncorrectable";
-
- case cudaErrorSharedObjectSymbolNotFound:
- return "cudaErrorSharedObjectSymbolNotFound";
-
- case cudaErrorSharedObjectInitFailed:
- return "cudaErrorSharedObjectInitFailed";
-
- case cudaErrorUnsupportedLimit:
- return "cudaErrorUnsupportedLimit";
-
- case cudaErrorDuplicateVariableName:
- return "cudaErrorDuplicateVariableName";
-
- case cudaErrorDuplicateTextureName:
- return "cudaErrorDuplicateTextureName";
-
- case cudaErrorDuplicateSurfaceName:
- return "cudaErrorDuplicateSurfaceName";
-
- case cudaErrorDevicesUnavailable:
- return "cudaErrorDevicesUnavailable";
-
- case cudaErrorInvalidKernelImage:
- return "cudaErrorInvalidKernelImage";
-
- case cudaErrorNoKernelImageForDevice:
- return "cudaErrorNoKernelImageForDevice";
-
- case cudaErrorIncompatibleDriverContext:
- return "cudaErrorIncompatibleDriverContext";
-
- case cudaErrorPeerAccessAlreadyEnabled:
- return "cudaErrorPeerAccessAlreadyEnabled";
-
- case cudaErrorPeerAccessNotEnabled:
- return "cudaErrorPeerAccessNotEnabled";
-
- case cudaErrorDeviceAlreadyInUse:
- return "cudaErrorDeviceAlreadyInUse";
-
- case cudaErrorProfilerDisabled:
- return "cudaErrorProfilerDisabled";
-
- case cudaErrorProfilerNotInitialized:
- return "cudaErrorProfilerNotInitialized";
-
- case cudaErrorProfilerAlreadyStarted:
- return "cudaErrorProfilerAlreadyStarted";
-
- case cudaErrorProfilerAlreadyStopped:
- return "cudaErrorProfilerAlreadyStopped";
-
- /* Since CUDA 4.0*/
- case cudaErrorAssert:
- return "cudaErrorAssert";
-
- case cudaErrorTooManyPeers:
- return "cudaErrorTooManyPeers";
-
- case cudaErrorHostMemoryAlreadyRegistered:
- return "cudaErrorHostMemoryAlreadyRegistered";
-
- case cudaErrorHostMemoryNotRegistered:
- return "cudaErrorHostMemoryNotRegistered";
-
- /* Since CUDA 5.0 */
- case cudaErrorOperatingSystem:
- return "cudaErrorOperatingSystem";
-
- case cudaErrorPeerAccessUnsupported:
- return "cudaErrorPeerAccessUnsupported";
-
- case cudaErrorLaunchMaxDepthExceeded:
- return "cudaErrorLaunchMaxDepthExceeded";
-
- case cudaErrorLaunchFileScopedTex:
- return "cudaErrorLaunchFileScopedTex";
-
- case cudaErrorLaunchFileScopedSurf:
- return "cudaErrorLaunchFileScopedSurf";
-
- case cudaErrorSyncDepthExceeded:
- return "cudaErrorSyncDepthExceeded";
-
- case cudaErrorLaunchPendingCountExceeded:
- return "cudaErrorLaunchPendingCountExceeded";
-
- case cudaErrorNotPermitted:
- return "cudaErrorNotPermitted";
-
- case cudaErrorNotSupported:
- return "cudaErrorNotSupported";
-
- /* Since CUDA 6.0 */
- case cudaErrorHardwareStackError:
- return "cudaErrorHardwareStackError";
-
- case cudaErrorIllegalInstruction:
- return "cudaErrorIllegalInstruction";
-
- case cudaErrorMisalignedAddress:
- return "cudaErrorMisalignedAddress";
-
- case cudaErrorInvalidAddressSpace:
- return "cudaErrorInvalidAddressSpace";
-
- case cudaErrorInvalidPc:
- return "cudaErrorInvalidPc";
-
- case cudaErrorIllegalAddress:
- return "cudaErrorIllegalAddress";
-
- /* Since CUDA 6.5*/
- case cudaErrorInvalidPtx:
- return "cudaErrorInvalidPtx";
-
- case cudaErrorInvalidGraphicsContext:
- return "cudaErrorInvalidGraphicsContext";
-
- case cudaErrorStartupFailure:
- return "cudaErrorStartupFailure";
-
- case cudaErrorApiFailureBase:
- return "cudaErrorApiFailureBase";
-
- /* Since CUDA 8.0*/
- case cudaErrorNvlinkUncorrectable :
- return "cudaErrorNvlinkUncorrectable";
- }
-
- return "";
-}
-#else
-// CUDA Driver API errors
-static const char *_cudaGetErrorEnum(CUresult error)
-{
- switch (error)
- {
- case CUDA_SUCCESS:
- return "CUDA_SUCCESS";
-
- case CUDA_ERROR_INVALID_VALUE:
- return "CUDA_ERROR_INVALID_VALUE";
-
- case CUDA_ERROR_OUT_OF_MEMORY:
- return "CUDA_ERROR_OUT_OF_MEMORY";
-
- case CUDA_ERROR_NOT_INITIALIZED:
- return "CUDA_ERROR_NOT_INITIALIZED";
-
- case CUDA_ERROR_DEINITIALIZED:
- return "CUDA_ERROR_DEINITIALIZED";
-
- case CUDA_ERROR_PROFILER_DISABLED:
- return "CUDA_ERROR_PROFILER_DISABLED";
-
- case CUDA_ERROR_PROFILER_NOT_INITIALIZED:
- return "CUDA_ERROR_PROFILER_NOT_INITIALIZED";
-
- case CUDA_ERROR_PROFILER_ALREADY_STARTED:
- return "CUDA_ERROR_PROFILER_ALREADY_STARTED";
-
- case CUDA_ERROR_PROFILER_ALREADY_STOPPED:
- return "CUDA_ERROR_PROFILER_ALREADY_STOPPED";
-
- case CUDA_ERROR_NO_DEVICE:
- return "CUDA_ERROR_NO_DEVICE";
-
- case CUDA_ERROR_INVALID_DEVICE:
- return "CUDA_ERROR_INVALID_DEVICE";
-
- case CUDA_ERROR_INVALID_IMAGE:
- return "CUDA_ERROR_INVALID_IMAGE";
-
- case CUDA_ERROR_INVALID_CONTEXT:
- return "CUDA_ERROR_INVALID_CONTEXT";
-
- case CUDA_ERROR_CONTEXT_ALREADY_CURRENT:
- return "CUDA_ERROR_CONTEXT_ALREADY_CURRENT";
-
- case CUDA_ERROR_MAP_FAILED:
- return "CUDA_ERROR_MAP_FAILED";
-
- case CUDA_ERROR_UNMAP_FAILED:
- return "CUDA_ERROR_UNMAP_FAILED";
-
- case CUDA_ERROR_ARRAY_IS_MAPPED:
- return "CUDA_ERROR_ARRAY_IS_MAPPED";
-
- case CUDA_ERROR_ALREADY_MAPPED:
- return "CUDA_ERROR_ALREADY_MAPPED";
-
- case CUDA_ERROR_NO_BINARY_FOR_GPU:
- return "CUDA_ERROR_NO_BINARY_FOR_GPU";
-
- case CUDA_ERROR_ALREADY_ACQUIRED:
- return "CUDA_ERROR_ALREADY_ACQUIRED";
-
- case CUDA_ERROR_NOT_MAPPED:
- return "CUDA_ERROR_NOT_MAPPED";
-
- case CUDA_ERROR_NOT_MAPPED_AS_ARRAY:
- return "CUDA_ERROR_NOT_MAPPED_AS_ARRAY";
-
- case CUDA_ERROR_NOT_MAPPED_AS_POINTER:
- return "CUDA_ERROR_NOT_MAPPED_AS_POINTER";
-
- case CUDA_ERROR_ECC_UNCORRECTABLE:
- return "CUDA_ERROR_ECC_UNCORRECTABLE";
-
- case CUDA_ERROR_UNSUPPORTED_LIMIT:
- return "CUDA_ERROR_UNSUPPORTED_LIMIT";
-
- case CUDA_ERROR_CONTEXT_ALREADY_IN_USE:
- return "CUDA_ERROR_CONTEXT_ALREADY_IN_USE";
-
- case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED:
- return "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED";
-
- case CUDA_ERROR_INVALID_PTX:
- return "CUDA_ERROR_INVALID_PTX";
-
- case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT:
- return "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT";
-
- case CUDA_ERROR_NVLINK_UNCORRECTABLE:
- return "CUDA_ERROR_NVLINK_UNCORRECTABLE";
-
- case CUDA_ERROR_INVALID_SOURCE:
- return "CUDA_ERROR_INVALID_SOURCE";
-
- case CUDA_ERROR_FILE_NOT_FOUND:
- return "CUDA_ERROR_FILE_NOT_FOUND";
-
- case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND:
- return "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND";
-
- case CUDA_ERROR_SHARED_OBJECT_INIT_FAILED:
- return "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED";
-
- case CUDA_ERROR_OPERATING_SYSTEM:
- return "CUDA_ERROR_OPERATING_SYSTEM";
-
- case CUDA_ERROR_INVALID_HANDLE:
- return "CUDA_ERROR_INVALID_HANDLE";
-
- case CUDA_ERROR_NOT_FOUND:
- return "CUDA_ERROR_NOT_FOUND";
-
- case CUDA_ERROR_NOT_READY:
- return "CUDA_ERROR_NOT_READY";
-
- case CUDA_ERROR_ILLEGAL_ADDRESS:
- return "CUDA_ERROR_ILLEGAL_ADDRESS";
-
- case CUDA_ERROR_LAUNCH_FAILED:
- return "CUDA_ERROR_LAUNCH_FAILED";
-
- case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES:
- return "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES";
-
- case CUDA_ERROR_LAUNCH_TIMEOUT:
- return "CUDA_ERROR_LAUNCH_TIMEOUT";
-
- case CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING:
- return "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING";
-
- case CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED:
- return "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED";
-
- case CUDA_ERROR_PEER_ACCESS_NOT_ENABLED:
- return "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED";
-
- case CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE:
- return "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE";
-
- case CUDA_ERROR_CONTEXT_IS_DESTROYED:
- return "CUDA_ERROR_CONTEXT_IS_DESTROYED";
-
- case CUDA_ERROR_ASSERT:
- return "CUDA_ERROR_ASSERT";
-
- case CUDA_ERROR_TOO_MANY_PEERS:
- return "CUDA_ERROR_TOO_MANY_PEERS";
-
- case CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED:
- return "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED";
-
- case CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED:
- return "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED";
-
- case CUDA_ERROR_HARDWARE_STACK_ERROR:
- return "CUDA_ERROR_HARDWARE_STACK_ERROR";
-
- case CUDA_ERROR_ILLEGAL_INSTRUCTION:
- return "CUDA_ERROR_ILLEGAL_INSTRUCTION";
-
- case CUDA_ERROR_MISALIGNED_ADDRESS:
- return "CUDA_ERROR_MISALIGNED_ADDRESS";
-
- case CUDA_ERROR_INVALID_ADDRESS_SPACE:
- return "CUDA_ERROR_INVALID_ADDRESS_SPACE";
-
- case CUDA_ERROR_INVALID_PC:
- return "CUDA_ERROR_INVALID_PC";
-
- case CUDA_ERROR_NOT_PERMITTED:
- return "CUDA_ERROR_NOT_PERMITTED";
-
- case CUDA_ERROR_NOT_SUPPORTED:
- return "CUDA_ERROR_NOT_SUPPORTED";
-
- case CUDA_ERROR_UNKNOWN:
- return "CUDA_ERROR_UNKNOWN";
- }
-
- return "";
-}
-#endif
-
-#ifdef CUBLAS_API_H_
-// cuBLAS API errors
-static const char *_cudaGetErrorEnum(cublasStatus_t error)
-{
- switch (error)
- {
- case CUBLAS_STATUS_SUCCESS:
- return "CUBLAS_STATUS_SUCCESS";
-
- case CUBLAS_STATUS_NOT_INITIALIZED:
- return "CUBLAS_STATUS_NOT_INITIALIZED";
-
- case CUBLAS_STATUS_ALLOC_FAILED:
- return "CUBLAS_STATUS_ALLOC_FAILED";
-
- case CUBLAS_STATUS_INVALID_VALUE:
- return "CUBLAS_STATUS_INVALID_VALUE";
-
- case CUBLAS_STATUS_ARCH_MISMATCH:
- return "CUBLAS_STATUS_ARCH_MISMATCH";
-
- case CUBLAS_STATUS_MAPPING_ERROR:
- return "CUBLAS_STATUS_MAPPING_ERROR";
-
- case CUBLAS_STATUS_EXECUTION_FAILED:
- return "CUBLAS_STATUS_EXECUTION_FAILED";
-
- case CUBLAS_STATUS_INTERNAL_ERROR:
- return "CUBLAS_STATUS_INTERNAL_ERROR";
-
- case CUBLAS_STATUS_NOT_SUPPORTED:
- return "CUBLAS_STATUS_NOT_SUPPORTED";
-
- case CUBLAS_STATUS_LICENSE_ERROR:
- return "CUBLAS_STATUS_LICENSE_ERROR";
- }
-
- return "";
-}
-#endif
-
-#ifdef _CUFFT_H_
-// cuFFT API errors
-static const char *_cudaGetErrorEnum(cufftResult error)
-{
- switch (error)
- {
- case CUFFT_SUCCESS:
- return "CUFFT_SUCCESS";
-
- case CUFFT_INVALID_PLAN:
- return "CUFFT_INVALID_PLAN";
-
- case CUFFT_ALLOC_FAILED:
- return "CUFFT_ALLOC_FAILED";
-
- case CUFFT_INVALID_TYPE:
- return "CUFFT_INVALID_TYPE";
-
- case CUFFT_INVALID_VALUE:
- return "CUFFT_INVALID_VALUE";
-
- case CUFFT_INTERNAL_ERROR:
- return "CUFFT_INTERNAL_ERROR";
-
- case CUFFT_EXEC_FAILED:
- return "CUFFT_EXEC_FAILED";
-
- case CUFFT_SETUP_FAILED:
- return "CUFFT_SETUP_FAILED";
-
- case CUFFT_INVALID_SIZE:
- return "CUFFT_INVALID_SIZE";
-
- case CUFFT_UNALIGNED_DATA:
- return "CUFFT_UNALIGNED_DATA";
-
- case CUFFT_INCOMPLETE_PARAMETER_LIST:
- return "CUFFT_INCOMPLETE_PARAMETER_LIST";
-
- case CUFFT_INVALID_DEVICE:
- return "CUFFT_INVALID_DEVICE";
-
- case CUFFT_PARSE_ERROR:
- return "CUFFT_PARSE_ERROR";
-
- case CUFFT_NO_WORKSPACE:
- return "CUFFT_NO_WORKSPACE";
-
- case CUFFT_NOT_IMPLEMENTED:
- return "CUFFT_NOT_IMPLEMENTED";
-
- case CUFFT_LICENSE_ERROR:
- return "CUFFT_LICENSE_ERROR";
-
- case CUFFT_NOT_SUPPORTED:
- return "CUFFT_NOT_SUPPORTED";
- }
-
- return "";
-}
-#endif
-
-
-#ifdef CUSPARSEAPI
-// cuSPARSE API errors
-static const char *_cudaGetErrorEnum(cusparseStatus_t error)
-{
- switch (error)
- {
- case CUSPARSE_STATUS_SUCCESS:
- return "CUSPARSE_STATUS_SUCCESS";
-
- case CUSPARSE_STATUS_NOT_INITIALIZED:
- return "CUSPARSE_STATUS_NOT_INITIALIZED";
-
- case CUSPARSE_STATUS_ALLOC_FAILED:
- return "CUSPARSE_STATUS_ALLOC_FAILED";
-
- case CUSPARSE_STATUS_INVALID_VALUE:
- return "CUSPARSE_STATUS_INVALID_VALUE";
-
- case CUSPARSE_STATUS_ARCH_MISMATCH:
- return "CUSPARSE_STATUS_ARCH_MISMATCH";
-
- case CUSPARSE_STATUS_MAPPING_ERROR:
- return "CUSPARSE_STATUS_MAPPING_ERROR";
-
- case CUSPARSE_STATUS_EXECUTION_FAILED:
- return "CUSPARSE_STATUS_EXECUTION_FAILED";
-
- case CUSPARSE_STATUS_INTERNAL_ERROR:
- return "CUSPARSE_STATUS_INTERNAL_ERROR";
-
- case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
- return "CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
- }
-
- return "";
-}
-#endif
-
-#ifdef CUSOLVER_COMMON_H_
-//cuSOLVER API errors
-static const char *_cudaGetErrorEnum(cusolverStatus_t error)
-{
- switch(error)
- {
- case CUSOLVER_STATUS_SUCCESS:
- return "CUSOLVER_STATUS_SUCCESS";
- case CUSOLVER_STATUS_NOT_INITIALIZED:
- return "CUSOLVER_STATUS_NOT_INITIALIZED";
- case CUSOLVER_STATUS_ALLOC_FAILED:
- return "CUSOLVER_STATUS_ALLOC_FAILED";
- case CUSOLVER_STATUS_INVALID_VALUE:
- return "CUSOLVER_STATUS_INVALID_VALUE";
- case CUSOLVER_STATUS_ARCH_MISMATCH:
- return "CUSOLVER_STATUS_ARCH_MISMATCH";
- case CUSOLVER_STATUS_MAPPING_ERROR:
- return "CUSOLVER_STATUS_MAPPING_ERROR";
- case CUSOLVER_STATUS_EXECUTION_FAILED:
- return "CUSOLVER_STATUS_EXECUTION_FAILED";
- case CUSOLVER_STATUS_INTERNAL_ERROR:
- return "CUSOLVER_STATUS_INTERNAL_ERROR";
- case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
- return "CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
- case CUSOLVER_STATUS_NOT_SUPPORTED :
- return "CUSOLVER_STATUS_NOT_SUPPORTED ";
- case CUSOLVER_STATUS_ZERO_PIVOT:
- return "CUSOLVER_STATUS_ZERO_PIVOT";
- case CUSOLVER_STATUS_INVALID_LICENSE:
- return "CUSOLVER_STATUS_INVALID_LICENSE";
- }
-
- return "";
-
-}
-#endif
-
-#ifdef CURAND_H_
-// cuRAND API errors
-static const char *_cudaGetErrorEnum(curandStatus_t error)
-{
- switch (error)
- {
- case CURAND_STATUS_SUCCESS:
- return "CURAND_STATUS_SUCCESS";
-
- case CURAND_STATUS_VERSION_MISMATCH:
- return "CURAND_STATUS_VERSION_MISMATCH";
-
- case CURAND_STATUS_NOT_INITIALIZED:
- return "CURAND_STATUS_NOT_INITIALIZED";
-
- case CURAND_STATUS_ALLOCATION_FAILED:
- return "CURAND_STATUS_ALLOCATION_FAILED";
-
- case CURAND_STATUS_TYPE_ERROR:
- return "CURAND_STATUS_TYPE_ERROR";
-
- case CURAND_STATUS_OUT_OF_RANGE:
- return "CURAND_STATUS_OUT_OF_RANGE";
-
- case CURAND_STATUS_LENGTH_NOT_MULTIPLE:
- return "CURAND_STATUS_LENGTH_NOT_MULTIPLE";
-
- case CURAND_STATUS_DOUBLE_PRECISION_REQUIRED:
- return "CURAND_STATUS_DOUBLE_PRECISION_REQUIRED";
-
- case CURAND_STATUS_LAUNCH_FAILURE:
- return "CURAND_STATUS_LAUNCH_FAILURE";
-
- case CURAND_STATUS_PREEXISTING_FAILURE:
- return "CURAND_STATUS_PREEXISTING_FAILURE";
-
- case CURAND_STATUS_INITIALIZATION_FAILED:
- return "CURAND_STATUS_INITIALIZATION_FAILED";
-
- case CURAND_STATUS_ARCH_MISMATCH:
- return "CURAND_STATUS_ARCH_MISMATCH";
-
- case CURAND_STATUS_INTERNAL_ERROR:
- return "CURAND_STATUS_INTERNAL_ERROR";
- }
-
- return "";
-}
-#endif
-
-#ifdef NV_NPPIDEFS_H
-// NPP API errors
-static const char *_cudaGetErrorEnum(NppStatus error)
-{
- switch (error)
- {
- case NPP_NOT_SUPPORTED_MODE_ERROR:
- return "NPP_NOT_SUPPORTED_MODE_ERROR";
-
- case NPP_ROUND_MODE_NOT_SUPPORTED_ERROR:
- return "NPP_ROUND_MODE_NOT_SUPPORTED_ERROR";
-
- case NPP_RESIZE_NO_OPERATION_ERROR:
- return "NPP_RESIZE_NO_OPERATION_ERROR";
-
- case NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY:
- return "NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY";
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
-
- case NPP_BAD_ARG_ERROR:
- return "NPP_BAD_ARGUMENT_ERROR";
-
- case NPP_COEFF_ERROR:
- return "NPP_COEFFICIENT_ERROR";
-
- case NPP_RECT_ERROR:
- return "NPP_RECTANGLE_ERROR";
-
- case NPP_QUAD_ERROR:
- return "NPP_QUADRANGLE_ERROR";
-
- case NPP_MEM_ALLOC_ERR:
- return "NPP_MEMORY_ALLOCATION_ERROR";
-
- case NPP_HISTO_NUMBER_OF_LEVELS_ERROR:
- return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_INVALID_INPUT:
- return "NPP_INVALID_INPUT";
-
- case NPP_POINTER_ERROR:
- return "NPP_POINTER_ERROR";
-
- case NPP_WARNING:
- return "NPP_WARNING";
-
- case NPP_ODD_ROI_WARNING:
- return "NPP_ODD_ROI_WARNING";
-#else
-
- // These are for CUDA 5.5 or higher
- case NPP_BAD_ARGUMENT_ERROR:
- return "NPP_BAD_ARGUMENT_ERROR";
-
- case NPP_COEFFICIENT_ERROR:
- return "NPP_COEFFICIENT_ERROR";
-
- case NPP_RECTANGLE_ERROR:
- return "NPP_RECTANGLE_ERROR";
-
- case NPP_QUADRANGLE_ERROR:
- return "NPP_QUADRANGLE_ERROR";
-
- case NPP_MEMORY_ALLOCATION_ERR:
- return "NPP_MEMORY_ALLOCATION_ERROR";
-
- case NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR:
- return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_INVALID_HOST_POINTER_ERROR:
- return "NPP_INVALID_HOST_POINTER_ERROR";
-
- case NPP_INVALID_DEVICE_POINTER_ERROR:
- return "NPP_INVALID_DEVICE_POINTER_ERROR";
-#endif
-
- case NPP_LUT_NUMBER_OF_LEVELS_ERROR:
- return "NPP_LUT_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_TEXTURE_BIND_ERROR:
- return "NPP_TEXTURE_BIND_ERROR";
-
- case NPP_WRONG_INTERSECTION_ROI_ERROR:
- return "NPP_WRONG_INTERSECTION_ROI_ERROR";
-
- case NPP_NOT_EVEN_STEP_ERROR:
- return "NPP_NOT_EVEN_STEP_ERROR";
-
- case NPP_INTERPOLATION_ERROR:
- return "NPP_INTERPOLATION_ERROR";
-
- case NPP_RESIZE_FACTOR_ERROR:
- return "NPP_RESIZE_FACTOR_ERROR";
-
- case NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR:
- return "NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR";
-
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
-
- case NPP_MEMFREE_ERR:
- return "NPP_MEMFREE_ERR";
-
- case NPP_MEMSET_ERR:
- return "NPP_MEMSET_ERR";
-
- case NPP_MEMCPY_ERR:
- return "NPP_MEMCPY_ERROR";
-
- case NPP_MIRROR_FLIP_ERR:
- return "NPP_MIRROR_FLIP_ERR";
-#else
-
- case NPP_MEMFREE_ERROR:
- return "NPP_MEMFREE_ERROR";
-
- case NPP_MEMSET_ERROR:
- return "NPP_MEMSET_ERROR";
-
- case NPP_MEMCPY_ERROR:
- return "NPP_MEMCPY_ERROR";
-
- case NPP_MIRROR_FLIP_ERROR:
- return "NPP_MIRROR_FLIP_ERROR";
-#endif
-
- case NPP_ALIGNMENT_ERROR:
- return "NPP_ALIGNMENT_ERROR";
-
- case NPP_STEP_ERROR:
- return "NPP_STEP_ERROR";
-
- case NPP_SIZE_ERROR:
- return "NPP_SIZE_ERROR";
-
- case NPP_NULL_POINTER_ERROR:
- return "NPP_NULL_POINTER_ERROR";
-
- case NPP_CUDA_KERNEL_EXECUTION_ERROR:
- return "NPP_CUDA_KERNEL_EXECUTION_ERROR";
-
- case NPP_NOT_IMPLEMENTED_ERROR:
- return "NPP_NOT_IMPLEMENTED_ERROR";
-
- case NPP_ERROR:
- return "NPP_ERROR";
-
- case NPP_SUCCESS:
- return "NPP_SUCCESS";
-
- case NPP_WRONG_INTERSECTION_QUAD_WARNING:
- return "NPP_WRONG_INTERSECTION_QUAD_WARNING";
-
- case NPP_MISALIGNED_DST_ROI_WARNING:
- return "NPP_MISALIGNED_DST_ROI_WARNING";
-
- case NPP_AFFINE_QUAD_INCORRECT_WARNING:
- return "NPP_AFFINE_QUAD_INCORRECT_WARNING";
-
- case NPP_DOUBLE_SIZE_WARNING:
- return "NPP_DOUBLE_SIZE_WARNING";
-
- case NPP_WRONG_INTERSECTION_ROI_WARNING:
- return "NPP_WRONG_INTERSECTION_ROI_WARNING";
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x6000
- /* These are 6.0 or higher */
- case NPP_LUT_PALETTE_BITSIZE_ERROR:
- return "NPP_LUT_PALETTE_BITSIZE_ERROR";
-
- case NPP_ZC_MODE_NOT_SUPPORTED_ERROR:
- return "NPP_ZC_MODE_NOT_SUPPORTED_ERROR";
-
- case NPP_QUALITY_INDEX_ERROR:
- return "NPP_QUALITY_INDEX_ERROR";
-
- case NPP_CHANNEL_ORDER_ERROR:
- return "NPP_CHANNEL_ORDER_ERROR";
-
- case NPP_ZERO_MASK_VALUE_ERROR:
- return "NPP_ZERO_MASK_VALUE_ERROR";
-
- case NPP_NUMBER_OF_CHANNELS_ERROR:
- return "NPP_NUMBER_OF_CHANNELS_ERROR";
-
- case NPP_COI_ERROR:
- return "NPP_COI_ERROR";
-
- case NPP_DIVISOR_ERROR:
- return "NPP_DIVISOR_ERROR";
-
- case NPP_CHANNEL_ERROR:
- return "NPP_CHANNEL_ERROR";
-
- case NPP_STRIDE_ERROR:
- return "NPP_STRIDE_ERROR";
-
- case NPP_ANCHOR_ERROR:
- return "NPP_ANCHOR_ERROR";
-
- case NPP_MASK_SIZE_ERROR:
- return "NPP_MASK_SIZE_ERROR";
-
- case NPP_MOMENT_00_ZERO_ERROR:
- return "NPP_MOMENT_00_ZERO_ERROR";
-
- case NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR:
- return "NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR";
-
- case NPP_THRESHOLD_ERROR:
- return "NPP_THRESHOLD_ERROR";
-
- case NPP_CONTEXT_MATCH_ERROR:
- return "NPP_CONTEXT_MATCH_ERROR";
-
- case NPP_FFT_FLAG_ERROR:
- return "NPP_FFT_FLAG_ERROR";
-
- case NPP_FFT_ORDER_ERROR:
- return "NPP_FFT_ORDER_ERROR";
-
- case NPP_SCALE_RANGE_ERROR:
- return "NPP_SCALE_RANGE_ERROR";
-
- case NPP_DATA_TYPE_ERROR:
- return "NPP_DATA_TYPE_ERROR";
-
- case NPP_OUT_OFF_RANGE_ERROR:
- return "NPP_OUT_OFF_RANGE_ERROR";
-
- case NPP_DIVIDE_BY_ZERO_ERROR:
- return "NPP_DIVIDE_BY_ZERO_ERROR";
-
- case NPP_RANGE_ERROR:
- return "NPP_RANGE_ERROR";
-
- case NPP_NO_MEMORY_ERROR:
- return "NPP_NO_MEMORY_ERROR";
-
- case NPP_ERROR_RESERVED:
- return "NPP_ERROR_RESERVED";
-
- case NPP_NO_OPERATION_WARNING:
- return "NPP_NO_OPERATION_WARNING";
-
- case NPP_DIVIDE_BY_ZERO_WARNING:
- return "NPP_DIVIDE_BY_ZERO_WARNING";
-#endif
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x7000
- /* These are 7.0 or higher */
- case NPP_OVERFLOW_ERROR:
- return "NPP_OVERFLOW_ERROR";
-
- case NPP_CORRUPTED_DATA_ERROR:
- return "NPP_CORRUPTED_DATA_ERROR";
-#endif
- }
-
- return "";
-}
-#endif
-
-#ifdef __DRIVER_TYPES_H__
-#ifndef DEVICE_RESET
-#define DEVICE_RESET cudaDeviceReset();
-#endif
-#else
-#ifndef DEVICE_RESET
-#define DEVICE_RESET
-#endif
-#endif
-
-#ifdef __DRIVER_TYPES_H__
-static inline void check(CUresult result, char const *const func, const char *const file, int const line)
-{
- if (result)
- {
- fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n",
- file, line, (unsigned int)(result), _cudaGetErrorEnum(result), func);
- DEVICE_RESET
- // Make sure we call CUDA Device Reset before exiting
- exit(EXIT_FAILURE);
- }
-}
-#else
-static inline void check(cudaError_t result, char const *const func, const char *const file, int const line)
-{
- if (result)
- {
- fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n",
- file, line, (unsigned int)(result), _cudaGetErrorEnum(result), func);
- DEVICE_RESET
- // Make sure we call CUDA Device Reset before exiting
- exit(EXIT_FAILURE);
- }
-}
-#endif
-
-#ifdef __DRIVER_TYPES_H__
-// This will output the proper CUDA error strings in the event that a CUDA host call returns an error
-#define checkCudaErrors(val) check ( (val), #val, __FILE__, __LINE__ )
-
-// This will output the proper error string when calling cudaGetLastError
-#define getLastCudaError(msg) __getLastCudaError (msg, __FILE__, __LINE__)
-
-inline void __getLastCudaError(const char *errorMessage, const char *file, const int line)
-{
- cudaError_t err = cudaGetLastError();
-
- if (cudaSuccess != err)
- {
- fprintf(stderr, "%s(%i) : getLastCudaError() CUDA error : %s : (%d) %s.\n",
- file, line, errorMessage, (int)err, cudaGetErrorString(err));
- DEVICE_RESET
- exit(EXIT_FAILURE);
- }
-}
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (a > b ? a : b)
-#endif
-
-// Float To Int conversion
-inline int ftoi(float value)
-{
- return (value >= 0 ? (int)(value + 0.5) : (int)(value - 0.5));
-}
-
-// Beginning of GPU Architecture definitions
-inline int _ConvertSMVer2Cores(int major, int minor)
-{
- // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
- typedef struct sSMtoCores
- {
- int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM minor version
- int Cores;
- } sSMtoCores;
-
- sSMtoCores nGpuArchCoresPerSM[] =
- {
- { 0x20, 32 }, // Fermi Generation (SM 2.0) GF100 class
- { 0x21, 48 }, // Fermi Generation (SM 2.1) GF10x class
- { 0x30, 192}, // Kepler Generation (SM 3.0) GK10x class
- { 0x32, 192}, // Kepler Generation (SM 3.2) GK10x class
- { 0x35, 192}, // Kepler Generation (SM 3.5) GK11x class
- { 0x37, 192}, // Kepler Generation (SM 3.7) GK21x class
- { 0x50, 128}, // Maxwell Generation (SM 5.0) GM10x class
- { 0x52, 128}, // Maxwell Generation (SM 5.2) GM20x class
- { 0x53, 128}, // Maxwell Generation (SM 5.3) GM20x class
- { 0x60, 64 }, // Pascal Generation (SM 6.0) GP100 class
- { 0x61, 128}, // Pascal Generation (SM 6.1) GP10x class
- { 0x62, 128}, // Pascal Generation (SM 6.2) GP10x class
- { -1, -1 }
- };
-
- int index = 0;
-
- while (nGpuArchCoresPerSM[index].SM != -1)
- {
- if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor))
- {
- return nGpuArchCoresPerSM[index].Cores;
- }
-
- index++;
- }
-
- // If we don't find the values, we default use the previous one to run properly
- printf("MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n", major, minor, nGpuArchCoresPerSM[index-1].Cores);
- return nGpuArchCoresPerSM[index-1].Cores;
-}
-// end of GPU Architecture definitions
-
-
-// end of CUDA Helper Functions
-
-
-#endif
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/helper_string.h
--- a/src/parallel_execution/helper_string.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,264 +0,0 @@
-/**
- * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
- *
- * Please refer to the NVIDIA end user license agreement (EULA) associated
- * with this source code for terms and conditions that govern your use of
- * this software. Any use, reproduction, disclosure, or distribution of
- * this software and related documentation outside the terms of the EULA
- * is strictly prohibited.
- *
- */
-
-// These are helper functions for the SDK samples (string parsing, timers, etc)
-#ifndef STRING_HELPER_H
-#define STRING_HELPER_H
-
-#include
-#include
-#include
-
-#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-#ifndef STRCASECMP
-#define STRCASECMP _stricmp
-#endif
-#ifndef STRNCASECMP
-#define STRNCASECMP _strnicmp
-#endif
-#ifndef STRCPY
-#define STRCPY(sFilePath, nLength, sPath) strcpy_s(sFilePath, nLength, sPath)
-#endif
-
-#ifndef FOPEN
-#define FOPEN(fHandle,filename,mode) fopen_s(&fHandle, filename, mode)
-#endif
-#ifndef FOPEN_FAIL
-#define FOPEN_FAIL(result) (result != 0)
-#endif
-#ifndef SSCANF
-#define SSCANF sscanf_s
-#endif
-#ifndef SPRINTF
-#define SPRINTF sprintf_s
-#endif
-#else // Linux Includes
-#include
-#include
-
-#ifndef STRCASECMP
-#define STRCASECMP strcasecmp
-#endif
-#ifndef STRNCASECMP
-#define STRNCASECMP strncasecmp
-#endif
-#ifndef STRCPY
-#define STRCPY(sFilePath, nLength, sPath) strcpy(sFilePath, sPath)
-#endif
-
-#ifndef FOPEN
-#define FOPEN(fHandle,filename,mode) (fHandle = fopen(filename, mode))
-#endif
-#ifndef FOPEN_FAIL
-#define FOPEN_FAIL(result) (result == NULL)
-#endif
-#ifndef SSCANF
-#define SSCANF sscanf
-#endif
-#ifndef SPRINTF
-#define SPRINTF sprintf
-#endif
-#endif
-
-#ifndef EXIT_WAIVED
-#define EXIT_WAIVED 2
-#endif
-
-#ifndef bool
-typedef int bool;
-#define false 0
-#define true 1
-#endif
-
-// CUDA Utility Helper Functions
-inline int stringRemoveDelimiter(char delimiter, const char *string)
-{
- int string_start = 0;
-
- while (string[string_start] == delimiter)
- {
- string_start++;
- }
-
- if (string_start >= (int)strlen(string)-1)
- {
- return 0;
- }
-
- return string_start;
-}
-
-inline int getFileExtension(char *filename, char **extension)
-{
- int string_length = (int)strlen(filename);
-
- while (filename[string_length--] != '.')
- {
- if (string_length == 0)
- break;
- }
-
- if (string_length > 0) string_length += 2;
-
- if (string_length == 0)
- *extension = NULL;
- else
- *extension = &filename[string_length];
-
- return string_length;
-}
-
-
-inline bool checkCmdLineFlag(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
-
- const char *equal_pos = strchr(string_argv, '=');
- int argv_length = (int)(equal_pos == 0 ? strlen(string_argv) : equal_pos - string_argv);
-
- int length = (int)strlen(string_ref);
-
- if (length == argv_length && !STRNCASECMP(string_argv, string_ref, length))
- {
- bFound = true;
- continue;
- }
- }
- }
-
- return bFound;
-}
-
-
-inline int getCmdLineArgumentInt(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
- int value = -1;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- if (length+1 <= (int)strlen(string_argv))
- {
- int auto_inc = (string_argv[length] == '=') ? 1 : 0;
- value = atoi(&string_argv[length + auto_inc]);
- }
- else
- {
- value = 0;
- }
-
- bFound = true;
- continue;
- }
- }
- }
-
- if (bFound)
- {
- return value;
- }
- else
- {
- return 0;
- }
-}
-
-inline float getCmdLineArgumentFloat(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
- float value = -1;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- if (length+1 <= (int)strlen(string_argv))
- {
- int auto_inc = (string_argv[length] == '=') ? 1 : 0;
- value = (float)atof(&string_argv[length + auto_inc]);
- }
- else
- {
- value = 0.f;
- }
-
- bFound = true;
- continue;
- }
- }
- }
-
- if (bFound)
- {
- return value;
- }
- else
- {
- return 0;
- }
-}
-
-inline bool getCmdLineArgumentString(const int argc, const char **argv,
- const char *string_ref, char **string_retval)
-{
- bool bFound = false;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- char *string_argv = (char *)&argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- *string_retval = &string_argv[length+1];
- bFound = true;
- continue;
- }
- }
- }
-
- if (!bFound)
- {
- *string_retval = NULL;
- }
-
- return bFound;
-}
-
-
-#endif
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/main.cbc
--- a/src/parallel_execution/main.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-#include
-#include
-#include
-#include
-
-#include "../context.h"
-
-int cpu_num = 1;
-int length = 102400;
-int split = 8;
-int* array_ptr;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-void *start_taskManager(struct Context *context) {
- goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
- return 0;
-}
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto meta(context, C_code1);
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct Time* time) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- printf("length/task:\t%d\n", length/split);
- /* puts("queue"); */
- /* print_queue(context->data[ActiveQueue]->queue.first); */
- /* puts("tree"); */
- /* print_tree(context->data[Tree]->tree.root); */
- /* puts("result"); */
- time->time = (union Data*)createTimeImpl(context);
- time->next = C_createTask1;
- goto meta(context, time->time->Time.start);
-}
-
-__code code2(struct Time* time, struct TaskManager* taskManager) {
- time->next = C_code3;
- taskManager->next = time->time->Time.end;
- goto meta(context, taskManager->taskManager->TaskManager.shutdown);
-}
-
-__code code3(struct LoopCounter* loopCounter) {
- int i = loopCounter->i;
-
- if (i < length) {
- //printf("%d\n", array_ptr[i]);
- if (array_ptr[i] == (i*2)) {
- loopCounter->i++;
- goto meta(context, C_code3);
- } else
- puts("wrong result");
-
- }
-
- goto meta(context, C_exit_code);
-}
-
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- Array* array = new Array();
-
- par goto createArray(array, __exit);
-
- par goto twice(array, iterate(split), __exit);
- goto code2();
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-s") == 0)
- split = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-
-int main(int argc, char** argv) {
- init(argc, argv);
-
- array_ptr = NEWN(length, int);
-
- for(int i=0; inext = C_initDataGears;
-
- goto start_code(main_context);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/stack.agda
--- a/src/parallel_execution/stack.agda Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,255 +0,0 @@
-open import Level renaming (suc to succ ; zero to Zero )
-module stack where
-
-open import Relation.Binary.PropositionalEquality
-open import Relation.Binary.Core
-open import Data.Nat
-
-ex : 1 + 2 ≡ 3
-ex = refl
-
-data Bool {n : Level } : Set n where
- True : Bool
- False : Bool
-
-record _∧_ {n : Level } (a : Set n) (b : Set n): Set n where
- field
- pi1 : a
- pi2 : b
-
-data Maybe {n : Level } (a : Set n) : Set n where
- Nothing : Maybe a
- Just : a -> Maybe a
-
-record StackMethods {n m : Level } (a : Set n ) {t : Set m }(stackImpl : Set n ) : Set (m Level.⊔ n) where
- field
- push : stackImpl -> a -> (stackImpl -> t) -> t
- pop : stackImpl -> (stackImpl -> Maybe a -> t) -> t
- pop2 : stackImpl -> (stackImpl -> Maybe a -> Maybe a -> t) -> t
- get : stackImpl -> (stackImpl -> Maybe a -> t) -> t
- get2 : stackImpl -> (stackImpl -> Maybe a -> Maybe a -> t) -> t
-open StackMethods
-
-record Stack {n m : Level } (a : Set n ) {t : Set m } (si : Set n ) : Set (m Level.⊔ n) where
- field
- stack : si
- stackMethods : StackMethods {n} {m} a {t} si
- pushStack : a -> (Stack a si -> t) -> t
- pushStack d next = push (stackMethods ) (stack ) d (\s1 -> next (record {stack = s1 ; stackMethods = stackMethods } ))
- popStack : (Stack a si -> Maybe a -> t) -> t
- popStack next = pop (stackMethods ) (stack ) (\s1 d1 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 )
- pop2Stack : (Stack a si -> Maybe a -> Maybe a -> t) -> t
- pop2Stack next = pop2 (stackMethods ) (stack ) (\s1 d1 d2 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2)
- getStack : (Stack a si -> Maybe a -> t) -> t
- getStack next = get (stackMethods ) (stack ) (\s1 d1 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 )
- get2Stack : (Stack a si -> Maybe a -> Maybe a -> t) -> t
- get2Stack next = get2 (stackMethods ) (stack ) (\s1 d1 d2 -> next (record {stack = s1 ; stackMethods = stackMethods }) d1 d2)
-
-open Stack
-
-data Element {n : Level } (a : Set n) : Set n where
- cons : a -> Maybe (Element a) -> Element a
-
-datum : {n : Level } {a : Set n} -> Element a -> a
-datum (cons a _) = a
-
-next : {n : Level } {a : Set n} -> Element a -> Maybe (Element a)
-next (cons _ n) = n
-
-
-{-
--- cannot define recrusive record definition. so use linked list with maybe.
-record Element {l : Level} (a : Set n l) : Set n (suc l) where
- field
- datum : a -- `data` is reserved by Agda.
- next : Maybe (Element a)
--}
-
-
-
-record SingleLinkedStack {n : Level } (a : Set n) : Set n where
- field
- top : Maybe (Element a)
-open SingleLinkedStack
-
-pushSingleLinkedStack : {n m : Level } {t : Set m } {Data : Set n} -> SingleLinkedStack Data -> Data -> (Code : SingleLinkedStack Data -> t) -> t
-pushSingleLinkedStack stack datum next = next stack1
- where
- element = cons datum (top stack)
- stack1 = record {top = Just element}
-
-
-popSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> t) -> t
-popSingleLinkedStack stack cs with (top stack)
-... | Nothing = cs stack Nothing
-... | Just d = cs stack1 (Just data1)
- where
- data1 = datum d
- stack1 = record { top = (next d) }
-
-pop2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> (Maybe a) -> t) -> t
-pop2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack)
-... | Nothing = cs stack Nothing Nothing
-... | Just d = pop2SingleLinkedStack' {n} {m} stack cs
- where
- pop2SingleLinkedStack' : {n m : Level } {t : Set m } -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> (Maybe a) -> t) -> t
- pop2SingleLinkedStack' stack cs with (next d)
- ... | Nothing = cs stack Nothing Nothing
- ... | Just d1 = cs (record {top = (next d1)}) (Just (datum d)) (Just (datum d1))
-
-
-getSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> t) -> t
-getSingleLinkedStack stack cs with (top stack)
-... | Nothing = cs stack Nothing
-... | Just d = cs stack (Just data1)
- where
- data1 = datum d
-
-get2SingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> (Maybe a) -> t) -> t
-get2SingleLinkedStack {n} {m} {t} {a} stack cs with (top stack)
-... | Nothing = cs stack Nothing Nothing
-... | Just d = get2SingleLinkedStack' {n} {m} stack cs
- where
- get2SingleLinkedStack' : {n m : Level} {t : Set m } -> SingleLinkedStack a -> (Code : SingleLinkedStack a -> (Maybe a) -> (Maybe a) -> t) -> t
- get2SingleLinkedStack' stack cs with (next d)
- ... | Nothing = cs stack Nothing Nothing
- ... | Just d1 = cs stack (Just (datum d)) (Just (datum d1))
-
-
-
-emptySingleLinkedStack : {n : Level } {a : Set n} -> SingleLinkedStack a
-emptySingleLinkedStack = record {top = Nothing}
-
------
--- Basic stack implementations are specifications of a Stack
---
-singleLinkedStackSpec : {n m : Level } {t : Set m } {a : Set n} -> StackMethods {n} {m} a {t} (SingleLinkedStack a)
-singleLinkedStackSpec = record {
- push = pushSingleLinkedStack
- ; pop = popSingleLinkedStack
- ; pop2 = pop2SingleLinkedStack
- ; get = getSingleLinkedStack
- ; get2 = get2SingleLinkedStack
- }
-
-createSingleLinkedStack : {n m : Level } {t : Set m } {a : Set n} -> Stack {n} {m} a {t} (SingleLinkedStack a)
-createSingleLinkedStack = record {
- stack = emptySingleLinkedStack ;
- stackMethods = singleLinkedStackSpec
- }
-
-----
---
--- proof of properties ( concrete cases )
---
-
-test01 : {n : Level } {a : Set n} -> SingleLinkedStack a -> Maybe a -> Bool {n}
-test01 stack _ with (top stack)
-... | (Just _) = True
-... | Nothing = False
-
-
-test02 : {n : Level } {a : Set n} -> SingleLinkedStack a -> Bool
-test02 stack = popSingleLinkedStack stack test01
-
-test03 : {n : Level } {a : Set n} -> a -> Bool
-test03 v = pushSingleLinkedStack emptySingleLinkedStack v test02
-
--- after a push and a pop, the stack is empty
-lemma : {n : Level} {A : Set n} {a : A} -> test03 a ≡ False
-lemma = refl
-
-testStack01 : {n m : Level } {a : Set n} -> a -> Bool {m}
-testStack01 v = pushStack createSingleLinkedStack v (
- \s -> popStack s (\s1 d1 -> True))
-
--- after push 1 and 2, pop2 get 1 and 2
-
-testStack02 : {m : Level } -> ( Stack ℕ (SingleLinkedStack ℕ) -> Bool {m} ) -> Bool {m}
-testStack02 cs = pushStack createSingleLinkedStack 1 (
- \s -> pushStack s 2 cs)
-
-
-testStack031 : (d1 d2 : ℕ ) -> Bool {Zero}
-testStack031 2 1 = True
-testStack031 _ _ = False
-
-testStack032 : (d1 d2 : Maybe ℕ) -> Bool {Zero}
-testStack032 (Just d1) (Just d2) = testStack031 d1 d2
-testStack032 _ _ = False
-
-testStack03 : {m : Level } -> Stack ℕ (SingleLinkedStack ℕ) -> ((Maybe ℕ) -> (Maybe ℕ) -> Bool {m} ) -> Bool {m}
-testStack03 s cs = pop2Stack s (
- \s d1 d2 -> cs d1 d2 )
-
-testStack04 : Bool
-testStack04 = testStack02 (\s -> testStack03 s testStack032)
-
-testStack05 : testStack04 ≡ True
-testStack05 = refl
-
-------
---
--- proof of properties with indefinite state of stack
---
--- this should be proved by properties of the stack inteface, not only by the implementation,
--- and the implementation have to provides the properties.
---
--- we cannot write "s ≡ s3", since level of the Set does not fit , but use stack s ≡ stack s3 is ok.
--- anyway some implementations may result s != s3
---
-
-stackInSomeState : {l m : Level } {D : Set l} {t : Set m } (s : SingleLinkedStack D ) -> Stack {l} {m} D {t} ( SingleLinkedStack D )
-stackInSomeState s = record { stack = s ; stackMethods = singleLinkedStackSpec }
-
-push->push->pop2 : {l : Level } {D : Set l} (x y : D ) (s : SingleLinkedStack D ) ->
- pushStack ( stackInSomeState s ) x ( \s1 -> pushStack s1 y ( \s2 -> pop2Stack s2 ( \s3 y1 x1 -> (Just x ≡ x1 ) ∧ (Just y ≡ y1 ) ) ))
-push->push->pop2 {l} {D} x y s = record { pi1 = refl ; pi2 = refl }
-
-
-id : {n : Level} {A : Set n} -> A -> A
-id a = a
-
--- push a, n times
-
-n-push : {n : Level} {A : Set n} {a : A} -> ℕ -> SingleLinkedStack A -> SingleLinkedStack A
-n-push zero s = s
-n-push {l} {A} {a} (suc n) s = pushSingleLinkedStack (n-push {l} {A} {a} n s) a (\s -> s )
-
-n-pop : {n : Level}{A : Set n} {a : A} -> ℕ -> SingleLinkedStack A -> SingleLinkedStack A
-n-pop zero s = s
-n-pop {_} {A} {a} (suc n) s = popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ -> s )
-
-open ≡-Reasoning
-
-push-pop-equiv : {n : Level} {A : Set n} {a : A} (s : SingleLinkedStack A) -> (popSingleLinkedStack (pushSingleLinkedStack s a (\s -> s)) (\s _ -> s) ) ≡ s
-push-pop-equiv s = refl
-
-push-and-n-pop : {n : Level} {A : Set n} {a : A} (n : ℕ) (s : SingleLinkedStack A) -> n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id) ≡ n-pop {_} {A} {a} n s
-push-and-n-pop zero s = refl
-push-and-n-pop {_} {A} {a} (suc n) s = begin
- n-pop {_} {A} {a} (suc (suc n)) (pushSingleLinkedStack s a id)
- ≡⟨ refl ⟩
- popSingleLinkedStack (n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack s a id)) (\s _ -> s)
- ≡⟨ cong (\s -> popSingleLinkedStack s (\s _ -> s )) (push-and-n-pop n s) ⟩
- popSingleLinkedStack (n-pop {_} {A} {a} n s) (\s _ -> s)
- ≡⟨ refl ⟩
- n-pop {_} {A} {a} (suc n) s
- ∎
-
-
-n-push-pop-equiv : {n : Level} {A : Set n} {a : A} (n : ℕ) (s : SingleLinkedStack A) -> (n-pop {_} {A} {a} n (n-push {_} {A} {a} n s)) ≡ s
-n-push-pop-equiv zero s = refl
-n-push-pop-equiv {_} {A} {a} (suc n) s = begin
- n-pop {_} {A} {a} (suc n) (n-push (suc n) s)
- ≡⟨ refl ⟩
- n-pop {_} {A} {a} (suc n) (pushSingleLinkedStack (n-push n s) a (\s -> s))
- ≡⟨ push-and-n-pop n (n-push n s) ⟩
- n-pop {_} {A} {a} n (n-push n s)
- ≡⟨ n-push-pop-equiv n s ⟩
- s
- ∎
-
-
-n-push-pop-equiv-empty : {n : Level} {A : Set n} {a : A} -> (n : ℕ) -> n-pop {_} {A} {a} n (n-push {_} {A} {a} n emptySingleLinkedStack) ≡ emptySingleLinkedStack
-n-push-pop-equiv-empty n = n-push-pop-equiv n emptySingleLinkedStack
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/cbc_stack_test.c
--- a/src/parallel_execution/test/cbc_stack_test.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#include "../context.h"
-#include
-
-__code stack_test1(struct Context* context, struct Task* task, struct Stack* stack) {
- task->code = C_stack_test1;
- stack->next = C_stack_test2;
- stack->data = (union Data*)task;
- goto meta(context, stack->stack->Stack.push);
-}
-
-__code stack_test1_stub(struct Context* context) {
- Task* task = &ALLOCATE(context, Task)->Task;
- struct Stack* stack = &(createSingleLinkedStack(context)->Stack);
- assert(stack->stack->SingleLinkedStack.top == NULL);
- context->data[D_Stack]->Stack.stack = (union Data*)stack;
- goto stack_test1(context,
- task,
- &context->data[D_Stack]->Stack);
-}
-
-__code stack_test2(struct Context* context, struct Task* task, struct Stack* stack) {
- task->code = C_stack_test2;
- stack->next = C_stack_test3;
- stack->data = (union Data*)task;
- goto meta(context, stack->stack->Stack.push);
-}
-
-__code stack_test2_stub(struct Context* context) {
- assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1);
- Task* task = &ALLOCATE(context, Task)->Task;
- goto stack_test2(context,
- task,
- &context->data[D_Stack]->Stack);
-}
-
-__code stack_test3(struct Context* context, struct Stack* stack) {
- stack->next = C_stack_test4;
- goto meta(context, stack->stack->Stack.pop);
-}
-
-__code stack_test3_stub(struct Context* context) {
- assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test2);
- goto stack_test3(context,
- &context->data[D_Stack]->Stack);
-}
-
-__code stack_test4(struct Context* context) {
- goto meta(context, C_exit_code);
-}
-
-__code stack_test4_stub(struct Context* context) {
- assert(context->data[D_Stack]->Stack.data->Task.code == C_stack_test2);
- assert(context->data[D_Stack]->Stack.stack->Stack.stack->SingleLinkedStack.top->data->Task.code == C_stack_test1);
- goto stack_test4(context);
-}
-
-int main(int argc, char const* argv[]) {
- struct Context* main_context = NEW(struct Context);
- initContext(main_context);
- main_context->next = C_stack_test1;
- goto start_code(main_context);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/multiDimIterator_test.cbc
--- a/src/parallel_execution/test/multiDimIterator_test.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-#include
-#include
-#include
-#include
-#interface "Iterator.h"
-
-#include "../../context.h"
-
-int cpu_num = 1;
-int length = 1;
-int gpu_num = 0;
-int CPU_ANY = -1;
-int CPU_CUDA = -1;
-
-__code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- // loopCounter->tree = createRedBlackTree(context);
- loopCounter->i = 0;
- taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
- goto meta(context, C_code1);
-}
-
-__code initDataGears_stub(struct Context* context) {
- struct TaskManager* taskManager = Gearef(context, TaskManager);
- taskManager->taskManager = 0;
- struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
- goto initDataGears(context, loopCounter, taskManager);
-}
-
-__code code1(struct LoopCounter* loopCounter) {
- printf("cpus:\t\t%d\n", cpu_num);
- printf("gpus:\t\t%d\n", gpu_num);
- printf("length:\t\t%d\n", length);
- /* puts("queue"); */
- /* print_queue(context->data[ActiveQueue]->queue.first); */
- /* puts("tree"); */
- /* print_tree(context->data[Tree]->tree.root); */
- /* puts("result"); */
-
- goto createTask1();
-}
-
-__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
- int i = loopCounter->i;
-
- if (i < length) {
- loopCounter->i++;
- goto meta(context, C_createTask2);
- }
-
- loopCounter->i = 0;
- taskManager->next = C_exit_code;
- goto meta(context, taskManager->taskManager->TaskManager.shutdown);
-}
-
-__code createTask2(struct TaskManager* taskManager) {
- par goto printIterator(iterate(2), exit);
- par goto printIterator(iterate(2, 2), exit);
- par goto printIterator(iterate(2, 2, 2), exit);
- goto createTask1();
-}
-
-void init(int argc, char** argv) {
- for (int i = 1; argv[i]; ++i) {
- if (strcmp(argv[i], "-cpu") == 0)
- cpu_num = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-l") == 0)
- length = (int)atoi(argv[i+1]);
- else if (strcmp(argv[i], "-cuda") == 0) {
- gpu_num = 1;
- CPU_CUDA = 0;
- }
- }
-}
-
-int main(int argc, char** argv) {
- init(argc, argv);
- struct Context* main_context = NEW(struct Context);
- initContext(main_context);
- main_context->next = C_initDataGears;
- goto start_code(main_context);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/printIterator.cbc
--- a/src/parallel_execution/test/printIterator.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#include "../../context.h"
-#include
-__code printIterator(struct MultiDim* multiDim, __code next(...)) {
- printf("x: %d, y: %d, z: %d\n", multiDim->x, multiDim->y, multiDim->z);
- goto meta(context, next);
-}
-
-__code printIterator_stub(struct Context* context) {
- goto printIterator(context,
- &context->data[context->idg]->MultiDim,
- context->next);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/queue_test.cbc
--- a/src/parallel_execution/test/queue_test.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#include "../../context.h"
-#interface "Queue.h"
-#include
-
-__code queueTest1(struct Queue* queue) {
- Node* node = new Node();
- node->color = Red;
- goto queue->put(node, queueTest2);
-}
-
-__code queueTest1_stub(struct Context* context) {
- Queue* queue = createSingleLinkedQueue(context);
- goto queueTest1(context, queue);
-}
-
-__code queueTest2(struct Queue* queue) {
- Node* node = new Node();
- node->color = Black;
- goto queue->put(node, queueTest3);
-}
-
-__code queueTest2_stub(struct Context* context) {
- SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
- assert(singleLinkedQueue->top->next->data->Node.color == Red);
- assert(singleLinkedQueue->last->data->Node.color == Red);
- Queue* queue = (struct Queue*)Gearef(context, Queue)->queue;
- goto queueTest2(context, queue);
-}
-
-__code queueTest3(struct Queue* queue) {
- goto queue->take(assert3);
-}
-
-__code queueTest3_stub(struct Context* context) {
- SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
- assert(singleLinkedQueue->top->next->data->Node.color == Red);
- assert(singleLinkedQueue->last->data->Node.color == Black);
- Queue* queue = (struct Queue*)Gearef(context, Queue)->queue;
- goto queueTest3(context, queue);
-}
-
-__code assert3(struct Queue* queue) {
- SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
- assert(singleLinkedQueue->top->next->data->Node.color == Black);
- assert(singleLinkedQueue->last->data->Node.color == Black);
- goto exit_code(context);
-}
-
-int main(int argc, char const* argv[]) {
- goto queueTest1();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/rbTree_test.cbc
--- a/src/parallel_execution/test/rbTree_test.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-#include
-#include "../../context.h"
-#interface "Tree.h"
-
-/* #include */
-
-__code rbTreeTest1(struct Tree* tree) {
- printf("Test1\n");
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = 3;
- node->key = 3;
- printf("value->%d,key->%d\n",node->value->Int,node->key);
- goto tree->put(node, rbTreeTest2);
-}
-
-__code rbTreeTest1_stub(struct Context* context) {
- printf("test1_stub\n");
- Tree* tree = createRedBlackTree(context);
- goto rbTreeTest1(context,tree);
-}
-
-
-__code rbTreeTest2(struct Tree* tree) {
- printf("Test2\n");
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = 4;
- node->key = 4;
- goto tree->put(node, rbTreeTest3);
-}
-
-__code rbTreeTest2_stub(struct Context* context) {
- printf("test2_stub\n");
- Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
- goto rbTreeTest2(context,tree);
-}
-
-
-__code rbTreeTest3(struct Tree* tree) {
- printf("test3\n");
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = 2;
- node->key = 2;
- goto tree->put(node, rbTreeTest4);
-}
-
-__code rbTreeTest3_stub(struct Context* context) {
- Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
- goto rbTreeTest3(context,tree);
-}
-
-__code rbTreeTest4(struct Tree* tree) {
- printf("test4\n");
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = 8;
- node->key = 8;
- goto tree->put(node, rbTreeTest5);
-}
-
-__code rbTreeTest4_stub(struct Context* context) {
- Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
- goto rbTreeTest4(context,tree);
-}
-
-__code rbTreeTest5(struct Tree* tree) {
- printf("test5\n");
- Node* node = new Node();
- node->value = (union Data*)new Int();
- node->value->Int = 8;
- node->key = 8;
- goto tree->remove(node,exit_code);
-}
-
-__code rbTreeTest5_stub(struct Context* context) {
- Tree* tree = (struct Tree*)Gearef(context, Tree)->tree;
- goto rbTreeTest5(context,tree);
-}
-
-
-
-int main(int argc, char const* argv[]) {
- printf("test_main\n");
- goto rbTreeTest1();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/test/stack_test.cbc
--- a/src/parallel_execution/test/stack_test.cbc Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-#include "../../context.h"
-#interface "Stack.h"
-#include
-
-__code stackTest1(struct Stack* stack) {
- Node* node = new Node();
- node->color = Red;
- goto stack->push(node, stackTest2);
-}
-
-__code stackTest1_stub(struct Context* context) {
- Stack* stack = createSingleLinkedStack(context);
- goto stackTest1(context, stack);
-}
-
-__code stackTest2(struct Stack* stack) {
- Node* node = new Node();
- node->color = Black;
- goto stack->push(node, stackTest3);
-}
-
-__code stackTest2_stub(struct Context* context) {
- SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
- assert(singleLinkedStack->top->data->Node.color == Red);
- Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
- goto stackTest2(context, stack);
-}
-
-__code stackTest3(struct Stack* stack) {
- goto stack->pop(assert3);
-}
-
-__code stackTest3_stub(struct Context* context) {
- /*
- assert on stack implementation
- */
- SingleLinkedStack* singleLinkedStack = (SingleLinkedStack*)GearImpl(context, Stack, stack);
- assert(singleLinkedStack->top->data->Node.color == Black);
- Stack* stack = (struct Stack*)Gearef(context, Stack)->stack;
- goto stackTest3(context, stack);
-}
-
-__code assert3(struct Node* node, struct Stack* stack) {
- /*
- assert in normal level
- */
- assert(node->color == Red);
- goto exit_code(0);
-}
-
-int main(int argc, char const* argv[]) {
- goto stackTest1();
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/verifier/llrbContextWithVerifier.c
--- a/src/parallel_execution/verifier/llrbContextWithVerifier.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#include
-#include "llrbContextWithVerifier.h"
-
-unsigned int min_height(struct Node* node, unsigned int height) {
- if ((node->left == NULL) && (node->right == NULL)) return height;
- if (node->left == NULL) return min_height(node->right, height+1);
- if (node->right == NULL) return min_height(node->left, height+1);
-
- unsigned int left_min = min_height(node->left, height+1);
- unsigned int right_min = min_height(node->right, height+1);
-
- if (left_min < right_min) {
- return left_min;
- } else {
- return right_min;
- }
-}
-
-unsigned int max_height(struct Node* node, unsigned int height) {
- if ((node->left == NULL) && (node->right == NULL)) return height;
- if (node->left == NULL) return max_height(node->right, height+1);
- if (node->right == NULL) return max_height(node->left, height+1);
-
- unsigned int left_max = max_height(node->left, height+1);
- unsigned int right_max = max_height(node->right, height+1);
-
- if (left_max > right_max) {
- return left_max;
- } else {
- return right_max;
- }
-}
-
-void verify_tree_height(struct Node* root) {
- if (root == NULL) return;
-
- unsigned int min_h = min_height(root, 1);
- unsigned int max_h = max_height(root, 1);
-
- if (max_h >= 2*min_h) {
- printf("llrb-condition violated.\n");
- printf("\tmin-height %u", min_h);
- printf("\tmax-height %u", max_h);
- exit(EXIT_FAILURE);
- }
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/verifier/llrbContextWithVerifier.h
--- a/src/parallel_execution/verifier/llrbContextWithVerifier.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#include "llrbContext.h"
-
-unsigned int min_height(struct Node* node, unsigned int height);
-unsigned int max_height(struct Node* node, unsigned int height);
-void verify_tree_height(struct Node* root);
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/parallel_execution/verifier/verify_put_cs.c
--- a/src/parallel_execution/verifier/verify_put_cs.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/* Verification of LLRB-Tree height in put operations.
- * LLRB-Tree allows (max-height) <= 2*(min-height).
- */
-
-#include
-#include
-#include
-#include "llrbContextWithVerifier.h"
-
-__code meta(struct Context* context, enum Code next) {
- if (next == Put) {
- verify_tree_height(context->data[Tree]->tree.root);
- }
- goto (context->code[next])(context);
-}
-
-__code start_code(struct Context* context, enum Code next) {
- unsigned int seed = (unsigned int)time(NULL);
-
- printf("--- srand(%u)\n", seed);
- goto meta(context, next);
-}
-
-__code exit_code(struct Context* context) {
- free(context->code);
- free(context->data);
- free(context->heapStart);
- goto exit(0);
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/CMakeLists.txt
--- a/src/test/CMakeLists.txt Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-add_definitions("-Wall -g -O0")
-
-set(NVCCFLAG "-std=c++11" "-g" "-O0" )
-
-include_directories("/usr/local/cuda/include")
-
-set(CMAKE_C_COMPILER $ENV{CBC_COMPILER})
-
-set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib")
-# for linux use -lcuda
-
-SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
-
-cmake_minimum_required(VERSION 2.8)
-find_package(CUDA REQUIRED)
-
-add_custom_command(OUTPUT main.o
- DEPENDS main.cu
- COMMAND nvcc ${NVCCFLAG} -c main.cu
-)
-
-add_executable(cudaExmple main.o test.c)
-
-add_custom_command(OUTPUT multiply.ptx
- DEPENDS multiply.cu
- COMMAND nvcc ${NVCCFLAG} -c multiply.cu -ptx
-)
-
-add_executable(twiceExample twice.cc multiply.ptx )
-
-add_custom_command(OUTPUT vectorAdd_kernel.ptx
- DEPENDS vectorAdd_kernel.cu
- COMMAND nvcc ${NVCCFLAG} -c vectorAdd_kernel.cu -ptx
-)
-
-add_executable(vectorExample vectorAddDrv.cc vectorAdd_kernel.ptx)
-
-# to compile these, comment out CMAKE_C_COMPILER
-# cuda_add_executable(Cudasample_gpu Cudasample_gpu.cu)
-# cuda_add_executable(Cudasample_cpu Cudasample_cpu.cu)
-
-# target_link_libraries(twiceExample ${CUDA_LIBRARIES} ${MPI_LIBRARIES} ${OPENGL_LIBRARIES})
-
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/Cudasample_cpu.cu
--- a/src/test/Cudasample_cpu.cu Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#include
-
-int main(void)
-{
- int b;
-
- for (b = 99; b >= 0; b--) {
- switch (b) {
- case 0:
- printf("No more bottles of beer on the wall, no more bottles of beer.\n");
- printf("Go to the store and buy some more, 99 bottles of beer on the wall.\n");
- break;
- case 1:
- printf("1 bottle of beer on the wall, 1 bottle of beer.\n");
- printf("Take one down and pass it around, no more bottles of beer on the wall\n");
- break;
- default:
- printf("%d bottles of beer on the wall, %d bottles of beer.\n", b, b);
- printf("Take one down and pass it around, %d %s of beer on the wall.\n"
- ,b - 1
- ,((b - 1) > 1)? "bottles" : "bottle");
- break;
- }
- }
- return 0;
-}
\ No newline at end of file
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/Cudasample_gpu.cu
--- a/src/test/Cudasample_gpu.cu Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#include
-
-#define SIZE_TEXT (sizeof(text)-1)
-#define SIZE_END (sizeof(end)-1)
-
-__device__ char text[] =
-"__ bottles of beer on the wall, __ bottles of beer!\n"
-"Take one down, and pass it around, ## bottles of beer on the wall!\n\n";
-
-__device__ char end[] =
-"01 bottle of beer on the wall, 01 bottle of beer.\n"
-"Take one down and pass it around, no more bottles of beer on the wall.\n"
-"\n"
-"No more bottles of beer on the wall, no more bottles of beer.\n"
-"Go to the store and buy some more, 99 bottles of beer on the wall.";
-
-
-__global__
-void bottle99(char *addr){
- int x = threadIdx.x;
- addr += x * SIZE_TEXT;
- int bottle = 99 - x;
- if (bottle == 1) {
- for (int i=0; i>>(d_buffer);
-
- cudaMemcpy(buffer, d_buffer, size, cudaMemcpyDeviceToHost);
- cudaFree(d_buffer);
-
- puts(buffer);
- free(buffer);
- }
-
\ No newline at end of file
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/OpenCL_gpu.c
--- a/src/test/OpenCL_gpu.c Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#include
-#include
-
-#ifdef __APPLE__
-#include
-#else
-#include
-#endif
-
-#define MEM_SIZE (128)
-#define MAX_SOURCE_SIZE (0x100000)
-
-int main()
-{
- cl_device_id device_id = NULL;
- cl_context context = NULL;
- cl_command_queue command_queue = NULL;
- cl_mem memobj = NULL;
- cl_program program = NULL;
- cl_kernel kernel = NULL;
- cl_platform_id platform_id = NULL;
- cl_uint ret_num_devices;
- cl_uint ret_num_platforms;
- cl_int ret;
-
- char string[MEM_SIZE];
-
- FILE *fp;
- char fileName[] = "./hello.cl";
- char *source_str;
- size_t source_size;
-
-/* Load the source code containing the kernel*/
- fp = fopen(fileName, "r");
- if (!fp) {
- fprintf(stderr, "Failed to load kernel.\n");
- exit(1);
- }
- source_str = (char*)malloc(MAX_SOURCE_SIZE);
- source_size = fread(source_str, 1, MAX_SOURCE_SIZE, fp);
- fclose(fp);
-
-/* Get Platform and Device Info */
- ret = clGetPlatformIDs(1, &platform_id, &ret_num_platforms);
- ret = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_DEFAULT, 1, &device_id, &ret_num_devices);
-
-/* Create OpenCL context */
- context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &ret);
-
-/* Create Command Queue */
- command_queue = clCreateCommandQueue(context, device_id, 0, &ret);
-
-/* Create Memory Buffer */
- memobj = clCreateBuffer(context, CL_MEM_READ_WRITE,MEM_SIZE * sizeof(char), NULL, &ret);
-
-/* Create Kernel Program from the source */
- program = clCreateProgramWithSource(context, 1, (const char **)&source_str,
- (const size_t *)&source_size, &ret);
-
-/* Build Kernel Program */
- ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
-
-/* Create OpenCL Kernel */
- kernel = clCreateKernel(program, "hello", &ret);
-
-/* Set OpenCL Kernel Parameters */
- ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&memobj);
-
-/* Execute OpenCL Kernel */
- ret = clEnqueueTask(command_queue, kernel, 0, NULL,NULL);
-
-/* Copy results from the memory buffer */
- ret = clEnqueueReadBuffer(command_queue, memobj, CL_TRUE, 0,
- MEM_SIZE * sizeof(char),string, 0, NULL, NULL);
-
-/* Display Result */
- puts(string);
-
-/* Finalization */
- ret = clFlush(command_queue);
- ret = clFinish(command_queue);
- ret = clReleaseKernel(kernel);
- ret = clReleaseProgram(program);
- ret = clReleaseMemObject(memobj);
- ret = clReleaseCommandQueue(command_queue);
- ret = clReleaseContext(context);
-
- free(source_str);
-
- return 0;
-}
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/helper_cuda.h
--- a/src/test/helper_cuda.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1283 +0,0 @@
-/**
- * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
- *
- * Please refer to the NVIDIA end user license agreement (EULA) associated
- * with this source code for terms and conditions that govern your use of
- * this software. Any use, reproduction, disclosure, or distribution of
- * this software and related documentation outside the terms of the EULA
- * is strictly prohibited.
- *
- */
-
-////////////////////////////////////////////////////////////////////////////////
-// These are CUDA Helper functions for initialization and error checking
-
-#ifndef HELPER_CUDA_H
-#define HELPER_CUDA_H
-
-#pragma once
-
-#include
-#include
-#include
-
-#include "helper_string.h"
-
-#ifndef EXIT_WAIVED
-#define EXIT_WAIVED 2
-#endif
-
-// Note, it is required that your SDK sample to include the proper header files, please
-// refer the CUDA examples for examples of the needed CUDA headers, which may change depending
-// on which CUDA functions are used.
-
-// CUDA Runtime error messages
-#ifdef __DRIVER_TYPES_H__
-static const char *_cudaGetErrorEnum(cudaError_t error)
-{
- switch (error)
- {
- case cudaSuccess:
- return "cudaSuccess";
-
- case cudaErrorMissingConfiguration:
- return "cudaErrorMissingConfiguration";
-
- case cudaErrorMemoryAllocation:
- return "cudaErrorMemoryAllocation";
-
- case cudaErrorInitializationError:
- return "cudaErrorInitializationError";
-
- case cudaErrorLaunchFailure:
- return "cudaErrorLaunchFailure";
-
- case cudaErrorPriorLaunchFailure:
- return "cudaErrorPriorLaunchFailure";
-
- case cudaErrorLaunchTimeout:
- return "cudaErrorLaunchTimeout";
-
- case cudaErrorLaunchOutOfResources:
- return "cudaErrorLaunchOutOfResources";
-
- case cudaErrorInvalidDeviceFunction:
- return "cudaErrorInvalidDeviceFunction";
-
- case cudaErrorInvalidConfiguration:
- return "cudaErrorInvalidConfiguration";
-
- case cudaErrorInvalidDevice:
- return "cudaErrorInvalidDevice";
-
- case cudaErrorInvalidValue:
- return "cudaErrorInvalidValue";
-
- case cudaErrorInvalidPitchValue:
- return "cudaErrorInvalidPitchValue";
-
- case cudaErrorInvalidSymbol:
- return "cudaErrorInvalidSymbol";
-
- case cudaErrorMapBufferObjectFailed:
- return "cudaErrorMapBufferObjectFailed";
-
- case cudaErrorUnmapBufferObjectFailed:
- return "cudaErrorUnmapBufferObjectFailed";
-
- case cudaErrorInvalidHostPointer:
- return "cudaErrorInvalidHostPointer";
-
- case cudaErrorInvalidDevicePointer:
- return "cudaErrorInvalidDevicePointer";
-
- case cudaErrorInvalidTexture:
- return "cudaErrorInvalidTexture";
-
- case cudaErrorInvalidTextureBinding:
- return "cudaErrorInvalidTextureBinding";
-
- case cudaErrorInvalidChannelDescriptor:
- return "cudaErrorInvalidChannelDescriptor";
-
- case cudaErrorInvalidMemcpyDirection:
- return "cudaErrorInvalidMemcpyDirection";
-
- case cudaErrorAddressOfConstant:
- return "cudaErrorAddressOfConstant";
-
- case cudaErrorTextureFetchFailed:
- return "cudaErrorTextureFetchFailed";
-
- case cudaErrorTextureNotBound:
- return "cudaErrorTextureNotBound";
-
- case cudaErrorSynchronizationError:
- return "cudaErrorSynchronizationError";
-
- case cudaErrorInvalidFilterSetting:
- return "cudaErrorInvalidFilterSetting";
-
- case cudaErrorInvalidNormSetting:
- return "cudaErrorInvalidNormSetting";
-
- case cudaErrorMixedDeviceExecution:
- return "cudaErrorMixedDeviceExecution";
-
- case cudaErrorCudartUnloading:
- return "cudaErrorCudartUnloading";
-
- case cudaErrorUnknown:
- return "cudaErrorUnknown";
-
- case cudaErrorNotYetImplemented:
- return "cudaErrorNotYetImplemented";
-
- case cudaErrorMemoryValueTooLarge:
- return "cudaErrorMemoryValueTooLarge";
-
- case cudaErrorInvalidResourceHandle:
- return "cudaErrorInvalidResourceHandle";
-
- case cudaErrorNotReady:
- return "cudaErrorNotReady";
-
- case cudaErrorInsufficientDriver:
- return "cudaErrorInsufficientDriver";
-
- case cudaErrorSetOnActiveProcess:
- return "cudaErrorSetOnActiveProcess";
-
- case cudaErrorInvalidSurface:
- return "cudaErrorInvalidSurface";
-
- case cudaErrorNoDevice:
- return "cudaErrorNoDevice";
-
- case cudaErrorECCUncorrectable:
- return "cudaErrorECCUncorrectable";
-
- case cudaErrorSharedObjectSymbolNotFound:
- return "cudaErrorSharedObjectSymbolNotFound";
-
- case cudaErrorSharedObjectInitFailed:
- return "cudaErrorSharedObjectInitFailed";
-
- case cudaErrorUnsupportedLimit:
- return "cudaErrorUnsupportedLimit";
-
- case cudaErrorDuplicateVariableName:
- return "cudaErrorDuplicateVariableName";
-
- case cudaErrorDuplicateTextureName:
- return "cudaErrorDuplicateTextureName";
-
- case cudaErrorDuplicateSurfaceName:
- return "cudaErrorDuplicateSurfaceName";
-
- case cudaErrorDevicesUnavailable:
- return "cudaErrorDevicesUnavailable";
-
- case cudaErrorInvalidKernelImage:
- return "cudaErrorInvalidKernelImage";
-
- case cudaErrorNoKernelImageForDevice:
- return "cudaErrorNoKernelImageForDevice";
-
- case cudaErrorIncompatibleDriverContext:
- return "cudaErrorIncompatibleDriverContext";
-
- case cudaErrorPeerAccessAlreadyEnabled:
- return "cudaErrorPeerAccessAlreadyEnabled";
-
- case cudaErrorPeerAccessNotEnabled:
- return "cudaErrorPeerAccessNotEnabled";
-
- case cudaErrorDeviceAlreadyInUse:
- return "cudaErrorDeviceAlreadyInUse";
-
- case cudaErrorProfilerDisabled:
- return "cudaErrorProfilerDisabled";
-
- case cudaErrorProfilerNotInitialized:
- return "cudaErrorProfilerNotInitialized";
-
- case cudaErrorProfilerAlreadyStarted:
- return "cudaErrorProfilerAlreadyStarted";
-
- case cudaErrorProfilerAlreadyStopped:
- return "cudaErrorProfilerAlreadyStopped";
-
- /* Since CUDA 4.0*/
- case cudaErrorAssert:
- return "cudaErrorAssert";
-
- case cudaErrorTooManyPeers:
- return "cudaErrorTooManyPeers";
-
- case cudaErrorHostMemoryAlreadyRegistered:
- return "cudaErrorHostMemoryAlreadyRegistered";
-
- case cudaErrorHostMemoryNotRegistered:
- return "cudaErrorHostMemoryNotRegistered";
-
- /* Since CUDA 5.0 */
- case cudaErrorOperatingSystem:
- return "cudaErrorOperatingSystem";
-
- case cudaErrorPeerAccessUnsupported:
- return "cudaErrorPeerAccessUnsupported";
-
- case cudaErrorLaunchMaxDepthExceeded:
- return "cudaErrorLaunchMaxDepthExceeded";
-
- case cudaErrorLaunchFileScopedTex:
- return "cudaErrorLaunchFileScopedTex";
-
- case cudaErrorLaunchFileScopedSurf:
- return "cudaErrorLaunchFileScopedSurf";
-
- case cudaErrorSyncDepthExceeded:
- return "cudaErrorSyncDepthExceeded";
-
- case cudaErrorLaunchPendingCountExceeded:
- return "cudaErrorLaunchPendingCountExceeded";
-
- case cudaErrorNotPermitted:
- return "cudaErrorNotPermitted";
-
- case cudaErrorNotSupported:
- return "cudaErrorNotSupported";
-
- /* Since CUDA 6.0 */
- case cudaErrorHardwareStackError:
- return "cudaErrorHardwareStackError";
-
- case cudaErrorIllegalInstruction:
- return "cudaErrorIllegalInstruction";
-
- case cudaErrorMisalignedAddress:
- return "cudaErrorMisalignedAddress";
-
- case cudaErrorInvalidAddressSpace:
- return "cudaErrorInvalidAddressSpace";
-
- case cudaErrorInvalidPc:
- return "cudaErrorInvalidPc";
-
- case cudaErrorIllegalAddress:
- return "cudaErrorIllegalAddress";
-
- /* Since CUDA 6.5*/
- case cudaErrorInvalidPtx:
- return "cudaErrorInvalidPtx";
-
- case cudaErrorInvalidGraphicsContext:
- return "cudaErrorInvalidGraphicsContext";
-
- case cudaErrorStartupFailure:
- return "cudaErrorStartupFailure";
-
- case cudaErrorApiFailureBase:
- return "cudaErrorApiFailureBase";
-
- /* Since CUDA 8.0*/
- case cudaErrorNvlinkUncorrectable :
- return "cudaErrorNvlinkUncorrectable";
- }
-
- return "";
-}
-#endif
-
-#ifdef __cuda_cuda_h__
-// CUDA Driver API errors
-const char *_cudaGetErrorEnum(CUresult error)
-{
- switch (error)
- {
- case CUDA_SUCCESS:
- return "CUDA_SUCCESS";
-
- case CUDA_ERROR_INVALID_VALUE:
- return "CUDA_ERROR_INVALID_VALUE";
-
- case CUDA_ERROR_OUT_OF_MEMORY:
- return "CUDA_ERROR_OUT_OF_MEMORY";
-
- case CUDA_ERROR_NOT_INITIALIZED:
- return "CUDA_ERROR_NOT_INITIALIZED";
-
- case CUDA_ERROR_DEINITIALIZED:
- return "CUDA_ERROR_DEINITIALIZED";
-
- case CUDA_ERROR_PROFILER_DISABLED:
- return "CUDA_ERROR_PROFILER_DISABLED";
-
- case CUDA_ERROR_PROFILER_NOT_INITIALIZED:
- return "CUDA_ERROR_PROFILER_NOT_INITIALIZED";
-
- case CUDA_ERROR_PROFILER_ALREADY_STARTED:
- return "CUDA_ERROR_PROFILER_ALREADY_STARTED";
-
- case CUDA_ERROR_PROFILER_ALREADY_STOPPED:
- return "CUDA_ERROR_PROFILER_ALREADY_STOPPED";
-
- case CUDA_ERROR_NO_DEVICE:
- return "CUDA_ERROR_NO_DEVICE";
-
- case CUDA_ERROR_INVALID_DEVICE:
- return "CUDA_ERROR_INVALID_DEVICE";
-
- case CUDA_ERROR_INVALID_IMAGE:
- return "CUDA_ERROR_INVALID_IMAGE";
-
- case CUDA_ERROR_INVALID_CONTEXT:
- return "CUDA_ERROR_INVALID_CONTEXT";
-
- case CUDA_ERROR_CONTEXT_ALREADY_CURRENT:
- return "CUDA_ERROR_CONTEXT_ALREADY_CURRENT";
-
- case CUDA_ERROR_MAP_FAILED:
- return "CUDA_ERROR_MAP_FAILED";
-
- case CUDA_ERROR_UNMAP_FAILED:
- return "CUDA_ERROR_UNMAP_FAILED";
-
- case CUDA_ERROR_ARRAY_IS_MAPPED:
- return "CUDA_ERROR_ARRAY_IS_MAPPED";
-
- case CUDA_ERROR_ALREADY_MAPPED:
- return "CUDA_ERROR_ALREADY_MAPPED";
-
- case CUDA_ERROR_NO_BINARY_FOR_GPU:
- return "CUDA_ERROR_NO_BINARY_FOR_GPU";
-
- case CUDA_ERROR_ALREADY_ACQUIRED:
- return "CUDA_ERROR_ALREADY_ACQUIRED";
-
- case CUDA_ERROR_NOT_MAPPED:
- return "CUDA_ERROR_NOT_MAPPED";
-
- case CUDA_ERROR_NOT_MAPPED_AS_ARRAY:
- return "CUDA_ERROR_NOT_MAPPED_AS_ARRAY";
-
- case CUDA_ERROR_NOT_MAPPED_AS_POINTER:
- return "CUDA_ERROR_NOT_MAPPED_AS_POINTER";
-
- case CUDA_ERROR_ECC_UNCORRECTABLE:
- return "CUDA_ERROR_ECC_UNCORRECTABLE";
-
- case CUDA_ERROR_UNSUPPORTED_LIMIT:
- return "CUDA_ERROR_UNSUPPORTED_LIMIT";
-
- case CUDA_ERROR_CONTEXT_ALREADY_IN_USE:
- return "CUDA_ERROR_CONTEXT_ALREADY_IN_USE";
-
- case CUDA_ERROR_PEER_ACCESS_UNSUPPORTED:
- return "CUDA_ERROR_PEER_ACCESS_UNSUPPORTED";
-
- case CUDA_ERROR_INVALID_PTX:
- return "CUDA_ERROR_INVALID_PTX";
-
- case CUDA_ERROR_INVALID_GRAPHICS_CONTEXT:
- return "CUDA_ERROR_INVALID_GRAPHICS_CONTEXT";
-
- case CUDA_ERROR_NVLINK_UNCORRECTABLE:
- return "CUDA_ERROR_NVLINK_UNCORRECTABLE";
-
- case CUDA_ERROR_INVALID_SOURCE:
- return "CUDA_ERROR_INVALID_SOURCE";
-
- case CUDA_ERROR_FILE_NOT_FOUND:
- return "CUDA_ERROR_FILE_NOT_FOUND";
-
- case CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND:
- return "CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND";
-
- case CUDA_ERROR_SHARED_OBJECT_INIT_FAILED:
- return "CUDA_ERROR_SHARED_OBJECT_INIT_FAILED";
-
- case CUDA_ERROR_OPERATING_SYSTEM:
- return "CUDA_ERROR_OPERATING_SYSTEM";
-
- case CUDA_ERROR_INVALID_HANDLE:
- return "CUDA_ERROR_INVALID_HANDLE";
-
- case CUDA_ERROR_NOT_FOUND:
- return "CUDA_ERROR_NOT_FOUND";
-
- case CUDA_ERROR_NOT_READY:
- return "CUDA_ERROR_NOT_READY";
-
- case CUDA_ERROR_ILLEGAL_ADDRESS:
- return "CUDA_ERROR_ILLEGAL_ADDRESS";
-
- case CUDA_ERROR_LAUNCH_FAILED:
- return "CUDA_ERROR_LAUNCH_FAILED";
-
- case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES:
- return "CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES";
-
- case CUDA_ERROR_LAUNCH_TIMEOUT:
- return "CUDA_ERROR_LAUNCH_TIMEOUT";
-
- case CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING:
- return "CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING";
-
- case CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED:
- return "CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED";
-
- case CUDA_ERROR_PEER_ACCESS_NOT_ENABLED:
- return "CUDA_ERROR_PEER_ACCESS_NOT_ENABLED";
-
- case CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE:
- return "CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE";
-
- case CUDA_ERROR_CONTEXT_IS_DESTROYED:
- return "CUDA_ERROR_CONTEXT_IS_DESTROYED";
-
- case CUDA_ERROR_ASSERT:
- return "CUDA_ERROR_ASSERT";
-
- case CUDA_ERROR_TOO_MANY_PEERS:
- return "CUDA_ERROR_TOO_MANY_PEERS";
-
- case CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED:
- return "CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED";
-
- case CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED:
- return "CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED";
-
- case CUDA_ERROR_HARDWARE_STACK_ERROR:
- return "CUDA_ERROR_HARDWARE_STACK_ERROR";
-
- case CUDA_ERROR_ILLEGAL_INSTRUCTION:
- return "CUDA_ERROR_ILLEGAL_INSTRUCTION";
-
- case CUDA_ERROR_MISALIGNED_ADDRESS:
- return "CUDA_ERROR_MISALIGNED_ADDRESS";
-
- case CUDA_ERROR_INVALID_ADDRESS_SPACE:
- return "CUDA_ERROR_INVALID_ADDRESS_SPACE";
-
- case CUDA_ERROR_INVALID_PC:
- return "CUDA_ERROR_INVALID_PC";
-
- case CUDA_ERROR_NOT_PERMITTED:
- return "CUDA_ERROR_NOT_PERMITTED";
-
- case CUDA_ERROR_NOT_SUPPORTED:
- return "CUDA_ERROR_NOT_SUPPORTED";
-
- case CUDA_ERROR_UNKNOWN:
- return "CUDA_ERROR_UNKNOWN";
- }
-
- return "";
-}
-#endif
-
-#ifdef CUBLAS_API_H_
-// cuBLAS API errors
-static const char *_cudaGetErrorEnum(cublasStatus_t error)
-{
- switch (error)
- {
- case CUBLAS_STATUS_SUCCESS:
- return "CUBLAS_STATUS_SUCCESS";
-
- case CUBLAS_STATUS_NOT_INITIALIZED:
- return "CUBLAS_STATUS_NOT_INITIALIZED";
-
- case CUBLAS_STATUS_ALLOC_FAILED:
- return "CUBLAS_STATUS_ALLOC_FAILED";
-
- case CUBLAS_STATUS_INVALID_VALUE:
- return "CUBLAS_STATUS_INVALID_VALUE";
-
- case CUBLAS_STATUS_ARCH_MISMATCH:
- return "CUBLAS_STATUS_ARCH_MISMATCH";
-
- case CUBLAS_STATUS_MAPPING_ERROR:
- return "CUBLAS_STATUS_MAPPING_ERROR";
-
- case CUBLAS_STATUS_EXECUTION_FAILED:
- return "CUBLAS_STATUS_EXECUTION_FAILED";
-
- case CUBLAS_STATUS_INTERNAL_ERROR:
- return "CUBLAS_STATUS_INTERNAL_ERROR";
-
- case CUBLAS_STATUS_NOT_SUPPORTED:
- return "CUBLAS_STATUS_NOT_SUPPORTED";
-
- case CUBLAS_STATUS_LICENSE_ERROR:
- return "CUBLAS_STATUS_LICENSE_ERROR";
- }
-
- return "";
-}
-#endif
-
-#ifdef _CUFFT_H_
-// cuFFT API errors
-static const char *_cudaGetErrorEnum(cufftResult error)
-{
- switch (error)
- {
- case CUFFT_SUCCESS:
- return "CUFFT_SUCCESS";
-
- case CUFFT_INVALID_PLAN:
- return "CUFFT_INVALID_PLAN";
-
- case CUFFT_ALLOC_FAILED:
- return "CUFFT_ALLOC_FAILED";
-
- case CUFFT_INVALID_TYPE:
- return "CUFFT_INVALID_TYPE";
-
- case CUFFT_INVALID_VALUE:
- return "CUFFT_INVALID_VALUE";
-
- case CUFFT_INTERNAL_ERROR:
- return "CUFFT_INTERNAL_ERROR";
-
- case CUFFT_EXEC_FAILED:
- return "CUFFT_EXEC_FAILED";
-
- case CUFFT_SETUP_FAILED:
- return "CUFFT_SETUP_FAILED";
-
- case CUFFT_INVALID_SIZE:
- return "CUFFT_INVALID_SIZE";
-
- case CUFFT_UNALIGNED_DATA:
- return "CUFFT_UNALIGNED_DATA";
-
- case CUFFT_INCOMPLETE_PARAMETER_LIST:
- return "CUFFT_INCOMPLETE_PARAMETER_LIST";
-
- case CUFFT_INVALID_DEVICE:
- return "CUFFT_INVALID_DEVICE";
-
- case CUFFT_PARSE_ERROR:
- return "CUFFT_PARSE_ERROR";
-
- case CUFFT_NO_WORKSPACE:
- return "CUFFT_NO_WORKSPACE";
-
- case CUFFT_NOT_IMPLEMENTED:
- return "CUFFT_NOT_IMPLEMENTED";
-
- case CUFFT_LICENSE_ERROR:
- return "CUFFT_LICENSE_ERROR";
-
- case CUFFT_NOT_SUPPORTED:
- return "CUFFT_NOT_SUPPORTED";
- }
-
- return "";
-}
-#endif
-
-
-#ifdef CUSPARSEAPI
-// cuSPARSE API errors
-static const char *_cudaGetErrorEnum(cusparseStatus_t error)
-{
- switch (error)
- {
- case CUSPARSE_STATUS_SUCCESS:
- return "CUSPARSE_STATUS_SUCCESS";
-
- case CUSPARSE_STATUS_NOT_INITIALIZED:
- return "CUSPARSE_STATUS_NOT_INITIALIZED";
-
- case CUSPARSE_STATUS_ALLOC_FAILED:
- return "CUSPARSE_STATUS_ALLOC_FAILED";
-
- case CUSPARSE_STATUS_INVALID_VALUE:
- return "CUSPARSE_STATUS_INVALID_VALUE";
-
- case CUSPARSE_STATUS_ARCH_MISMATCH:
- return "CUSPARSE_STATUS_ARCH_MISMATCH";
-
- case CUSPARSE_STATUS_MAPPING_ERROR:
- return "CUSPARSE_STATUS_MAPPING_ERROR";
-
- case CUSPARSE_STATUS_EXECUTION_FAILED:
- return "CUSPARSE_STATUS_EXECUTION_FAILED";
-
- case CUSPARSE_STATUS_INTERNAL_ERROR:
- return "CUSPARSE_STATUS_INTERNAL_ERROR";
-
- case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
- return "CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
- }
-
- return "";
-}
-#endif
-
-#ifdef CUSOLVER_COMMON_H_
-//cuSOLVER API errors
-static const char *_cudaGetErrorEnum(cusolverStatus_t error)
-{
- switch(error)
- {
- case CUSOLVER_STATUS_SUCCESS:
- return "CUSOLVER_STATUS_SUCCESS";
- case CUSOLVER_STATUS_NOT_INITIALIZED:
- return "CUSOLVER_STATUS_NOT_INITIALIZED";
- case CUSOLVER_STATUS_ALLOC_FAILED:
- return "CUSOLVER_STATUS_ALLOC_FAILED";
- case CUSOLVER_STATUS_INVALID_VALUE:
- return "CUSOLVER_STATUS_INVALID_VALUE";
- case CUSOLVER_STATUS_ARCH_MISMATCH:
- return "CUSOLVER_STATUS_ARCH_MISMATCH";
- case CUSOLVER_STATUS_MAPPING_ERROR:
- return "CUSOLVER_STATUS_MAPPING_ERROR";
- case CUSOLVER_STATUS_EXECUTION_FAILED:
- return "CUSOLVER_STATUS_EXECUTION_FAILED";
- case CUSOLVER_STATUS_INTERNAL_ERROR:
- return "CUSOLVER_STATUS_INTERNAL_ERROR";
- case CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
- return "CUSOLVER_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
- case CUSOLVER_STATUS_NOT_SUPPORTED :
- return "CUSOLVER_STATUS_NOT_SUPPORTED ";
- case CUSOLVER_STATUS_ZERO_PIVOT:
- return "CUSOLVER_STATUS_ZERO_PIVOT";
- case CUSOLVER_STATUS_INVALID_LICENSE:
- return "CUSOLVER_STATUS_INVALID_LICENSE";
- }
-
- return "";
-
-}
-#endif
-
-#ifdef CURAND_H_
-// cuRAND API errors
-static const char *_cudaGetErrorEnum(curandStatus_t error)
-{
- switch (error)
- {
- case CURAND_STATUS_SUCCESS:
- return "CURAND_STATUS_SUCCESS";
-
- case CURAND_STATUS_VERSION_MISMATCH:
- return "CURAND_STATUS_VERSION_MISMATCH";
-
- case CURAND_STATUS_NOT_INITIALIZED:
- return "CURAND_STATUS_NOT_INITIALIZED";
-
- case CURAND_STATUS_ALLOCATION_FAILED:
- return "CURAND_STATUS_ALLOCATION_FAILED";
-
- case CURAND_STATUS_TYPE_ERROR:
- return "CURAND_STATUS_TYPE_ERROR";
-
- case CURAND_STATUS_OUT_OF_RANGE:
- return "CURAND_STATUS_OUT_OF_RANGE";
-
- case CURAND_STATUS_LENGTH_NOT_MULTIPLE:
- return "CURAND_STATUS_LENGTH_NOT_MULTIPLE";
-
- case CURAND_STATUS_DOUBLE_PRECISION_REQUIRED:
- return "CURAND_STATUS_DOUBLE_PRECISION_REQUIRED";
-
- case CURAND_STATUS_LAUNCH_FAILURE:
- return "CURAND_STATUS_LAUNCH_FAILURE";
-
- case CURAND_STATUS_PREEXISTING_FAILURE:
- return "CURAND_STATUS_PREEXISTING_FAILURE";
-
- case CURAND_STATUS_INITIALIZATION_FAILED:
- return "CURAND_STATUS_INITIALIZATION_FAILED";
-
- case CURAND_STATUS_ARCH_MISMATCH:
- return "CURAND_STATUS_ARCH_MISMATCH";
-
- case CURAND_STATUS_INTERNAL_ERROR:
- return "CURAND_STATUS_INTERNAL_ERROR";
- }
-
- return "";
-}
-#endif
-
-#ifdef NV_NPPIDEFS_H
-// NPP API errors
-static const char *_cudaGetErrorEnum(NppStatus error)
-{
- switch (error)
- {
- case NPP_NOT_SUPPORTED_MODE_ERROR:
- return "NPP_NOT_SUPPORTED_MODE_ERROR";
-
- case NPP_ROUND_MODE_NOT_SUPPORTED_ERROR:
- return "NPP_ROUND_MODE_NOT_SUPPORTED_ERROR";
-
- case NPP_RESIZE_NO_OPERATION_ERROR:
- return "NPP_RESIZE_NO_OPERATION_ERROR";
-
- case NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY:
- return "NPP_NOT_SUFFICIENT_COMPUTE_CAPABILITY";
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
-
- case NPP_BAD_ARG_ERROR:
- return "NPP_BAD_ARGUMENT_ERROR";
-
- case NPP_COEFF_ERROR:
- return "NPP_COEFFICIENT_ERROR";
-
- case NPP_RECT_ERROR:
- return "NPP_RECTANGLE_ERROR";
-
- case NPP_QUAD_ERROR:
- return "NPP_QUADRANGLE_ERROR";
-
- case NPP_MEM_ALLOC_ERR:
- return "NPP_MEMORY_ALLOCATION_ERROR";
-
- case NPP_HISTO_NUMBER_OF_LEVELS_ERROR:
- return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_INVALID_INPUT:
- return "NPP_INVALID_INPUT";
-
- case NPP_POINTER_ERROR:
- return "NPP_POINTER_ERROR";
-
- case NPP_WARNING:
- return "NPP_WARNING";
-
- case NPP_ODD_ROI_WARNING:
- return "NPP_ODD_ROI_WARNING";
-#else
-
- // These are for CUDA 5.5 or higher
- case NPP_BAD_ARGUMENT_ERROR:
- return "NPP_BAD_ARGUMENT_ERROR";
-
- case NPP_COEFFICIENT_ERROR:
- return "NPP_COEFFICIENT_ERROR";
-
- case NPP_RECTANGLE_ERROR:
- return "NPP_RECTANGLE_ERROR";
-
- case NPP_QUADRANGLE_ERROR:
- return "NPP_QUADRANGLE_ERROR";
-
- case NPP_MEMORY_ALLOCATION_ERR:
- return "NPP_MEMORY_ALLOCATION_ERROR";
-
- case NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR:
- return "NPP_HISTOGRAM_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_INVALID_HOST_POINTER_ERROR:
- return "NPP_INVALID_HOST_POINTER_ERROR";
-
- case NPP_INVALID_DEVICE_POINTER_ERROR:
- return "NPP_INVALID_DEVICE_POINTER_ERROR";
-#endif
-
- case NPP_LUT_NUMBER_OF_LEVELS_ERROR:
- return "NPP_LUT_NUMBER_OF_LEVELS_ERROR";
-
- case NPP_TEXTURE_BIND_ERROR:
- return "NPP_TEXTURE_BIND_ERROR";
-
- case NPP_WRONG_INTERSECTION_ROI_ERROR:
- return "NPP_WRONG_INTERSECTION_ROI_ERROR";
-
- case NPP_NOT_EVEN_STEP_ERROR:
- return "NPP_NOT_EVEN_STEP_ERROR";
-
- case NPP_INTERPOLATION_ERROR:
- return "NPP_INTERPOLATION_ERROR";
-
- case NPP_RESIZE_FACTOR_ERROR:
- return "NPP_RESIZE_FACTOR_ERROR";
-
- case NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR:
- return "NPP_HAAR_CLASSIFIER_PIXEL_MATCH_ERROR";
-
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) <= 0x5000
-
- case NPP_MEMFREE_ERR:
- return "NPP_MEMFREE_ERR";
-
- case NPP_MEMSET_ERR:
- return "NPP_MEMSET_ERR";
-
- case NPP_MEMCPY_ERR:
- return "NPP_MEMCPY_ERROR";
-
- case NPP_MIRROR_FLIP_ERR:
- return "NPP_MIRROR_FLIP_ERR";
-#else
-
- case NPP_MEMFREE_ERROR:
- return "NPP_MEMFREE_ERROR";
-
- case NPP_MEMSET_ERROR:
- return "NPP_MEMSET_ERROR";
-
- case NPP_MEMCPY_ERROR:
- return "NPP_MEMCPY_ERROR";
-
- case NPP_MIRROR_FLIP_ERROR:
- return "NPP_MIRROR_FLIP_ERROR";
-#endif
-
- case NPP_ALIGNMENT_ERROR:
- return "NPP_ALIGNMENT_ERROR";
-
- case NPP_STEP_ERROR:
- return "NPP_STEP_ERROR";
-
- case NPP_SIZE_ERROR:
- return "NPP_SIZE_ERROR";
-
- case NPP_NULL_POINTER_ERROR:
- return "NPP_NULL_POINTER_ERROR";
-
- case NPP_CUDA_KERNEL_EXECUTION_ERROR:
- return "NPP_CUDA_KERNEL_EXECUTION_ERROR";
-
- case NPP_NOT_IMPLEMENTED_ERROR:
- return "NPP_NOT_IMPLEMENTED_ERROR";
-
- case NPP_ERROR:
- return "NPP_ERROR";
-
- case NPP_SUCCESS:
- return "NPP_SUCCESS";
-
- case NPP_WRONG_INTERSECTION_QUAD_WARNING:
- return "NPP_WRONG_INTERSECTION_QUAD_WARNING";
-
- case NPP_MISALIGNED_DST_ROI_WARNING:
- return "NPP_MISALIGNED_DST_ROI_WARNING";
-
- case NPP_AFFINE_QUAD_INCORRECT_WARNING:
- return "NPP_AFFINE_QUAD_INCORRECT_WARNING";
-
- case NPP_DOUBLE_SIZE_WARNING:
- return "NPP_DOUBLE_SIZE_WARNING";
-
- case NPP_WRONG_INTERSECTION_ROI_WARNING:
- return "NPP_WRONG_INTERSECTION_ROI_WARNING";
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x6000
- /* These are 6.0 or higher */
- case NPP_LUT_PALETTE_BITSIZE_ERROR:
- return "NPP_LUT_PALETTE_BITSIZE_ERROR";
-
- case NPP_ZC_MODE_NOT_SUPPORTED_ERROR:
- return "NPP_ZC_MODE_NOT_SUPPORTED_ERROR";
-
- case NPP_QUALITY_INDEX_ERROR:
- return "NPP_QUALITY_INDEX_ERROR";
-
- case NPP_CHANNEL_ORDER_ERROR:
- return "NPP_CHANNEL_ORDER_ERROR";
-
- case NPP_ZERO_MASK_VALUE_ERROR:
- return "NPP_ZERO_MASK_VALUE_ERROR";
-
- case NPP_NUMBER_OF_CHANNELS_ERROR:
- return "NPP_NUMBER_OF_CHANNELS_ERROR";
-
- case NPP_COI_ERROR:
- return "NPP_COI_ERROR";
-
- case NPP_DIVISOR_ERROR:
- return "NPP_DIVISOR_ERROR";
-
- case NPP_CHANNEL_ERROR:
- return "NPP_CHANNEL_ERROR";
-
- case NPP_STRIDE_ERROR:
- return "NPP_STRIDE_ERROR";
-
- case NPP_ANCHOR_ERROR:
- return "NPP_ANCHOR_ERROR";
-
- case NPP_MASK_SIZE_ERROR:
- return "NPP_MASK_SIZE_ERROR";
-
- case NPP_MOMENT_00_ZERO_ERROR:
- return "NPP_MOMENT_00_ZERO_ERROR";
-
- case NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR:
- return "NPP_THRESHOLD_NEGATIVE_LEVEL_ERROR";
-
- case NPP_THRESHOLD_ERROR:
- return "NPP_THRESHOLD_ERROR";
-
- case NPP_CONTEXT_MATCH_ERROR:
- return "NPP_CONTEXT_MATCH_ERROR";
-
- case NPP_FFT_FLAG_ERROR:
- return "NPP_FFT_FLAG_ERROR";
-
- case NPP_FFT_ORDER_ERROR:
- return "NPP_FFT_ORDER_ERROR";
-
- case NPP_SCALE_RANGE_ERROR:
- return "NPP_SCALE_RANGE_ERROR";
-
- case NPP_DATA_TYPE_ERROR:
- return "NPP_DATA_TYPE_ERROR";
-
- case NPP_OUT_OFF_RANGE_ERROR:
- return "NPP_OUT_OFF_RANGE_ERROR";
-
- case NPP_DIVIDE_BY_ZERO_ERROR:
- return "NPP_DIVIDE_BY_ZERO_ERROR";
-
- case NPP_RANGE_ERROR:
- return "NPP_RANGE_ERROR";
-
- case NPP_NO_MEMORY_ERROR:
- return "NPP_NO_MEMORY_ERROR";
-
- case NPP_ERROR_RESERVED:
- return "NPP_ERROR_RESERVED";
-
- case NPP_NO_OPERATION_WARNING:
- return "NPP_NO_OPERATION_WARNING";
-
- case NPP_DIVIDE_BY_ZERO_WARNING:
- return "NPP_DIVIDE_BY_ZERO_WARNING";
-#endif
-
-#if ((NPP_VERSION_MAJOR << 12) + (NPP_VERSION_MINOR << 4)) >= 0x7000
- /* These are 7.0 or higher */
- case NPP_OVERFLOW_ERROR:
- return "NPP_OVERFLOW_ERROR";
-
- case NPP_CORRUPTED_DATA_ERROR:
- return "NPP_CORRUPTED_DATA_ERROR";
-#endif
- }
-
- return "";
-}
-#endif
-
-#ifdef __DRIVER_TYPES_H__
-#ifndef DEVICE_RESET
-#define DEVICE_RESET cudaDeviceReset();
-#endif
-#else
-#ifndef DEVICE_RESET
-#define DEVICE_RESET
-#endif
-#endif
-
-template< typename T >
-void check(T result, char const *const func, const char *const file, int const line)
-{
- if (result)
- {
- fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n",
- file, line, static_cast(result), _cudaGetErrorEnum(result), func);
- DEVICE_RESET
- // Make sure we call CUDA Device Reset before exiting
- exit(EXIT_FAILURE);
- }
-}
-
-#ifdef __DRIVER_TYPES_H__
-// This will output the proper CUDA error strings in the event that a CUDA host call returns an error
-#define checkCudaErrors(val) check ( (val), #val, __FILE__, __LINE__ )
-
-// This will output the proper error string when calling cudaGetLastError
-#define getLastCudaError(msg) __getLastCudaError (msg, __FILE__, __LINE__)
-
-inline void __getLastCudaError(const char *errorMessage, const char *file, const int line)
-{
- cudaError_t err = cudaGetLastError();
-
- if (cudaSuccess != err)
- {
- fprintf(stderr, "%s(%i) : getLastCudaError() CUDA error : %s : (%d) %s.\n",
- file, line, errorMessage, (int)err, cudaGetErrorString(err));
- DEVICE_RESET
- exit(EXIT_FAILURE);
- }
-}
-#endif
-
-#ifndef MAX
-#define MAX(a,b) (a > b ? a : b)
-#endif
-
-// Float To Int conversion
-inline int ftoi(float value)
-{
- return (value >= 0 ? (int)(value + 0.5) : (int)(value - 0.5));
-}
-
-// Beginning of GPU Architecture definitions
-inline int _ConvertSMVer2Cores(int major, int minor)
-{
- // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
- typedef struct
- {
- int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM minor version
- int Cores;
- } sSMtoCores;
-
- sSMtoCores nGpuArchCoresPerSM[] =
- {
- { 0x20, 32 }, // Fermi Generation (SM 2.0) GF100 class
- { 0x21, 48 }, // Fermi Generation (SM 2.1) GF10x class
- { 0x30, 192}, // Kepler Generation (SM 3.0) GK10x class
- { 0x32, 192}, // Kepler Generation (SM 3.2) GK10x class
- { 0x35, 192}, // Kepler Generation (SM 3.5) GK11x class
- { 0x37, 192}, // Kepler Generation (SM 3.7) GK21x class
- { 0x50, 128}, // Maxwell Generation (SM 5.0) GM10x class
- { 0x52, 128}, // Maxwell Generation (SM 5.2) GM20x class
- { 0x53, 128}, // Maxwell Generation (SM 5.3) GM20x class
- { 0x60, 64 }, // Pascal Generation (SM 6.0) GP100 class
- { 0x61, 128}, // Pascal Generation (SM 6.1) GP10x class
- { 0x62, 128}, // Pascal Generation (SM 6.2) GP10x class
- { -1, -1 }
- };
-
- int index = 0;
-
- while (nGpuArchCoresPerSM[index].SM != -1)
- {
- if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor))
- {
- return nGpuArchCoresPerSM[index].Cores;
- }
-
- index++;
- }
-
- // If we don't find the values, we default use the previous one to run properly
- printf("MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n", major, minor, nGpuArchCoresPerSM[index-1].Cores);
- return nGpuArchCoresPerSM[index-1].Cores;
-}
-// end of GPU Architecture definitions
-
-#ifdef __CUDA_RUNTIME_H__
-// General GPU Device CUDA Initialization
-inline int gpuDeviceInit(int devID)
-{
- int device_count;
- checkCudaErrors(cudaGetDeviceCount(&device_count));
-
- if (device_count == 0)
- {
- fprintf(stderr, "gpuDeviceInit() CUDA error: no devices supporting CUDA.\n");
- exit(EXIT_FAILURE);
- }
-
- if (devID < 0)
- {
- devID = 0;
- }
-
- if (devID > device_count-1)
- {
- fprintf(stderr, "\n");
- fprintf(stderr, ">> %d CUDA capable GPU device(s) detected. <<\n", device_count);
- fprintf(stderr, ">> gpuDeviceInit (-device=%d) is not a valid GPU device. <<\n", devID);
- fprintf(stderr, "\n");
- return -devID;
- }
-
- cudaDeviceProp deviceProp;
- checkCudaErrors(cudaGetDeviceProperties(&deviceProp, devID));
-
- if (deviceProp.computeMode == cudaComputeModeProhibited)
- {
- fprintf(stderr, "Error: device is running in , no threads can use ::cudaSetDevice().\n");
- return -1;
- }
-
- if (deviceProp.major < 1)
- {
- fprintf(stderr, "gpuDeviceInit(): GPU device does not support CUDA.\n");
- exit(EXIT_FAILURE);
- }
-
- checkCudaErrors(cudaSetDevice(devID));
- printf("gpuDeviceInit() CUDA Device [%d]: \"%s\n", devID, deviceProp.name);
-
- return devID;
-}
-
-// This function returns the best GPU (with maximum GFLOPS)
-inline int gpuGetMaxGflopsDeviceId()
-{
- int current_device = 0, sm_per_multiproc = 0;
- int max_perf_device = 0;
- int device_count = 0, best_SM_arch = 0;
- int devices_prohibited = 0;
-
- unsigned long long max_compute_perf = 0;
- cudaDeviceProp deviceProp;
- cudaGetDeviceCount(&device_count);
-
- checkCudaErrors(cudaGetDeviceCount(&device_count));
-
- if (device_count == 0)
- {
- fprintf(stderr, "gpuGetMaxGflopsDeviceId() CUDA error: no devices supporting CUDA.\n");
- exit(EXIT_FAILURE);
- }
-
- // Find the best major SM Architecture GPU device
- while (current_device < device_count)
- {
- cudaGetDeviceProperties(&deviceProp, current_device);
-
- // If this GPU is not running on Compute Mode prohibited, then we can add it to the list
- if (deviceProp.computeMode != cudaComputeModeProhibited)
- {
- if (deviceProp.major > 0 && deviceProp.major < 9999)
- {
- best_SM_arch = MAX(best_SM_arch, deviceProp.major);
- }
- }
- else
- {
- devices_prohibited++;
- }
-
- current_device++;
- }
-
- if (devices_prohibited == device_count)
- {
- fprintf(stderr, "gpuGetMaxGflopsDeviceId() CUDA error: all devices have compute mode prohibited.\n");
- exit(EXIT_FAILURE);
- }
-
- // Find the best CUDA capable GPU device
- current_device = 0;
-
- while (current_device < device_count)
- {
- cudaGetDeviceProperties(&deviceProp, current_device);
-
- // If this GPU is not running on Compute Mode prohibited, then we can add it to the list
- if (deviceProp.computeMode != cudaComputeModeProhibited)
- {
- if (deviceProp.major == 9999 && deviceProp.minor == 9999)
- {
- sm_per_multiproc = 1;
- }
- else
- {
- sm_per_multiproc = _ConvertSMVer2Cores(deviceProp.major, deviceProp.minor);
- }
-
- unsigned long long compute_perf = (unsigned long long) deviceProp.multiProcessorCount * sm_per_multiproc * deviceProp.clockRate;
-
- if (compute_perf > max_compute_perf)
- {
- // If we find GPU with SM major > 2, search only these
- if (best_SM_arch > 2)
- {
- // If our device==dest_SM_arch, choose this, or else pass
- if (deviceProp.major == best_SM_arch)
- {
- max_compute_perf = compute_perf;
- max_perf_device = current_device;
- }
- }
- else
- {
- max_compute_perf = compute_perf;
- max_perf_device = current_device;
- }
- }
- }
-
- ++current_device;
- }
-
- return max_perf_device;
-}
-
-
-// Initialization code to find the best CUDA Device
-inline int findCudaDevice(int argc, const char **argv)
-{
- cudaDeviceProp deviceProp;
- int devID = 0;
-
- // If the command-line has a device number specified, use it
- if (checkCmdLineFlag(argc, argv, "device"))
- {
- devID = getCmdLineArgumentInt(argc, argv, "device=");
-
- if (devID < 0)
- {
- printf("Invalid command line parameter\n ");
- exit(EXIT_FAILURE);
- }
- else
- {
- devID = gpuDeviceInit(devID);
-
- if (devID < 0)
- {
- printf("exiting...\n");
- exit(EXIT_FAILURE);
- }
- }
- }
- else
- {
- // Otherwise pick the device with highest Gflops/s
- devID = gpuGetMaxGflopsDeviceId();
- checkCudaErrors(cudaSetDevice(devID));
- checkCudaErrors(cudaGetDeviceProperties(&deviceProp, devID));
- printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n", devID, deviceProp.name, deviceProp.major, deviceProp.minor);
- }
-
- return devID;
-}
-
-// General check for CUDA GPU SM Capabilities
-inline bool checkCudaCapabilities(int major_version, int minor_version)
-{
- cudaDeviceProp deviceProp;
- deviceProp.major = 0;
- deviceProp.minor = 0;
- int dev;
-
- checkCudaErrors(cudaGetDevice(&dev));
- checkCudaErrors(cudaGetDeviceProperties(&deviceProp, dev));
-
- if ((deviceProp.major > major_version) ||
- (deviceProp.major == major_version && deviceProp.minor >= minor_version))
- {
- printf(" Device %d: <%16s >, Compute SM %d.%d detected\n", dev, deviceProp.name, deviceProp.major, deviceProp.minor);
- return true;
- }
- else
- {
- printf(" No GPU device was found that can support CUDA compute capability %d.%d.\n", major_version, minor_version);
- return false;
- }
-}
-#endif
-
-// end of CUDA Helper Functions
-
-
-#endif
diff -r f63a9a081b61 -r 8fbc3ef749b6 src/test/helper_string.h
--- a/src/test/helper_string.h Fri Jan 05 09:41:27 2018 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,527 +0,0 @@
-/**
- * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
- *
- * Please refer to the NVIDIA end user license agreement (EULA) associated
- * with this source code for terms and conditions that govern your use of
- * this software. Any use, reproduction, disclosure, or distribution of
- * this software and related documentation outside the terms of the EULA
- * is strictly prohibited.
- *
- */
-
-// These are helper functions for the SDK samples (string parsing, timers, etc)
-#ifndef STRING_HELPER_H
-#define STRING_HELPER_H
-
-#include
-#include
-#include
-#include
-
-#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-#ifndef STRCASECMP
-#define STRCASECMP _stricmp
-#endif
-#ifndef STRNCASECMP
-#define STRNCASECMP _strnicmp
-#endif
-#ifndef STRCPY
-#define STRCPY(sFilePath, nLength, sPath) strcpy_s(sFilePath, nLength, sPath)
-#endif
-
-#ifndef FOPEN
-#define FOPEN(fHandle,filename,mode) fopen_s(&fHandle, filename, mode)
-#endif
-#ifndef FOPEN_FAIL
-#define FOPEN_FAIL(result) (result != 0)
-#endif
-#ifndef SSCANF
-#define SSCANF sscanf_s
-#endif
-#ifndef SPRINTF
-#define SPRINTF sprintf_s
-#endif
-#else // Linux Includes
-#include
-#include
-
-#ifndef STRCASECMP
-#define STRCASECMP strcasecmp
-#endif
-#ifndef STRNCASECMP
-#define STRNCASECMP strncasecmp
-#endif
-#ifndef STRCPY
-#define STRCPY(sFilePath, nLength, sPath) strcpy(sFilePath, sPath)
-#endif
-
-#ifndef FOPEN
-#define FOPEN(fHandle,filename,mode) (fHandle = fopen(filename, mode))
-#endif
-#ifndef FOPEN_FAIL
-#define FOPEN_FAIL(result) (result == NULL)
-#endif
-#ifndef SSCANF
-#define SSCANF sscanf
-#endif
-#ifndef SPRINTF
-#define SPRINTF sprintf
-#endif
-#endif
-
-#ifndef EXIT_WAIVED
-#define EXIT_WAIVED 2
-#endif
-
-// CUDA Utility Helper Functions
-inline int stringRemoveDelimiter(char delimiter, const char *string)
-{
- int string_start = 0;
-
- while (string[string_start] == delimiter)
- {
- string_start++;
- }
-
- if (string_start >= (int)strlen(string)-1)
- {
- return 0;
- }
-
- return string_start;
-}
-
-inline int getFileExtension(char *filename, char **extension)
-{
- int string_length = (int)strlen(filename);
-
- while (filename[string_length--] != '.')
- {
- if (string_length == 0)
- break;
- }
-
- if (string_length > 0) string_length += 2;
-
- if (string_length == 0)
- *extension = NULL;
- else
- *extension = &filename[string_length];
-
- return string_length;
-}
-
-
-inline bool checkCmdLineFlag(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
-
- const char *equal_pos = strchr(string_argv, '=');
- int argv_length = (int)(equal_pos == 0 ? strlen(string_argv) : equal_pos - string_argv);
-
- int length = (int)strlen(string_ref);
-
- if (length == argv_length && !STRNCASECMP(string_argv, string_ref, length))
- {
- bFound = true;
- continue;
- }
- }
- }
-
- return bFound;
-}
-
-// This function wraps the CUDA Driver API into a template function
-template
-inline bool getCmdLineArgumentValue(const int argc, const char **argv, const char *string_ref, T *value)
-{
- bool bFound = false;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- if (length+1 <= (int)strlen(string_argv))
- {
- int auto_inc = (string_argv[length] == '=') ? 1 : 0;
- *value = (T)atoi(&string_argv[length + auto_inc]);
- }
-
- bFound = true;
- i=argc;
- }
- }
- }
-
- return bFound;
-}
-
-inline int getCmdLineArgumentInt(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
- int value = -1;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- if (length+1 <= (int)strlen(string_argv))
- {
- int auto_inc = (string_argv[length] == '=') ? 1 : 0;
- value = atoi(&string_argv[length + auto_inc]);
- }
- else
- {
- value = 0;
- }
-
- bFound = true;
- continue;
- }
- }
- }
-
- if (bFound)
- {
- return value;
- }
- else
- {
- return 0;
- }
-}
-
-inline float getCmdLineArgumentFloat(const int argc, const char **argv, const char *string_ref)
-{
- bool bFound = false;
- float value = -1;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- const char *string_argv = &argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- if (length+1 <= (int)strlen(string_argv))
- {
- int auto_inc = (string_argv[length] == '=') ? 1 : 0;
- value = (float)atof(&string_argv[length + auto_inc]);
- }
- else
- {
- value = 0.f;
- }
-
- bFound = true;
- continue;
- }
- }
- }
-
- if (bFound)
- {
- return value;
- }
- else
- {
- return 0;
- }
-}
-
-inline bool getCmdLineArgumentString(const int argc, const char **argv,
- const char *string_ref, char **string_retval)
-{
- bool bFound = false;
-
- if (argc >= 1)
- {
- for (int i=1; i < argc; i++)
- {
- int string_start = stringRemoveDelimiter('-', argv[i]);
- char *string_argv = (char *)&argv[i][string_start];
- int length = (int)strlen(string_ref);
-
- if (!STRNCASECMP(string_argv, string_ref, length))
- {
- *string_retval = &string_argv[length+1];
- bFound = true;
- continue;
- }
- }
- }
-
- if (!bFound)
- {
- *string_retval = NULL;
- }
-
- return bFound;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//! Find the path for a file assuming that
-//! files are found in the searchPath.
-//!
-//! @return the path if succeeded, otherwise 0
-//! @param filename name of the file
-//! @param executable_path optional absolute path of the executable
-//////////////////////////////////////////////////////////////////////////////
-inline char *sdkFindFilePath(const char *filename, const char *executable_path)
-{
- // defines a variable that is replaced with the name of the executable
-
- // Typical relative search paths to locate needed companion files (e.g. sample input data, or JIT source files)
- // The origin for the relative search may be the .exe file, a .bat file launching an .exe, a browser .exe launching the .exe or .bat, etc
- const char *searchPath[] =
- {
- "./", // same dir
- "./_data_files/",
- "./common/", // "/common/" subdir
- "./common/data/", // "/common/data/" subdir
- "./data/", // "/data/" subdir
- "./src/", // "/src/" subdir
- "./src//data/", // "/src//data/" subdir
- "./inc/", // "/inc/" subdir
- "./0_Simple/", // "/0_Simple/" subdir
- "./1_Utilities/", // "/1_Utilities/" subdir
- "./2_Graphics/", // "/2_Graphics/" subdir
- "./3_Imaging/", // "/3_Imaging/" subdir
- "./4_Finance/", // "/4_Finance/" subdir
- "./5_Simulations/", // "/5_Simulations/" subdir
- "./6_Advanced/", // "/6_Advanced/" subdir
- "./7_CUDALibraries/", // "/7_CUDALibraries/" subdir
- "./8_Android/", // "/8_Android/" subdir
- "./samples/", // "/samples/" subdir
-
- "./0_Simple//data/", // "/0_Simple//data/" subdir
- "./1_Utilities//data/", // "/1_Utilities//data/" subdir
- "./2_Graphics//data/", // "/2_Graphics//data/" subdir
- "./3_Imaging//data/", // "/3_Imaging//data/" subdir
- "./4_Finance//data/", // "/4_Finance//data/" subdir
- "./5_Simulations//data/", // "/5_Simulations//data/" subdir
- "./6_Advanced//data/", // "/6_Advanced//data/" subdir
- "./7_CUDALibraries//", // "/7_CUDALibraries//" subdir
- "./7_CUDALibraries//data/", // "/7_CUDALibraries//data/" subdir
-
- "../", // up 1 in tree
- "../common/", // up 1 in tree, "/common/" subdir
- "../common/data/", // up 1 in tree, "/common/data/" subdir
- "../data/", // up 1 in tree, "/data/" subdir
- "../src/", // up 1 in tree, "/src/" subdir
- "../inc/", // up 1 in tree, "/inc/" subdir
-
- "../0_Simple//data/", // up 1 in tree, "/0_Simple//" subdir
- "../1_Utilities//data/", // up 1 in tree, "/1_Utilities//" subdir
- "../2_Graphics//data/", // up 1 in tree, "/2_Graphics//" subdir
- "../3_Imaging//data/", // up 1 in tree, "/3_Imaging//" subdir
- "../4_Finance//data/", // up 1 in tree, "/4_Finance//" subdir
- "../5_Simulations//data/", // up 1 in tree, "/5_Simulations//" subdir
- "../6_Advanced//data/", // up 1 in tree, "/6_Advanced//" subdir
- "../7_CUDALibraries//data/",// up 1 in tree, "/7_CUDALibraries//" subdir
- "../8_Android//data/", // up 1 in tree, "/8_Android//" subdir
- "../samples//data/", // up 1 in tree, "/samples//" subdir
- "../../", // up 2 in tree
- "../../common/", // up 2 in tree, "/common/" subdir
- "../../common/data/", // up 2 in tree, "/common/data/" subdir
- "../../data/", // up 2 in tree, "/data/" subdir
- "../../src/", // up 2 in tree, "/src/" subdir
- "../../inc/", // up 2 in tree, "/inc/" subdir
- "../../sandbox//data/", // up 2 in tree, "/sandbox//" subdir
- "../../0_Simple//data/", // up 2 in tree, "/0_Simple//" subdir
- "../../1_Utilities//data/", // up 2 in tree, "/1_Utilities//" subdir
- "../../2_Graphics//data/", // up 2 in tree, "/2_Graphics//" subdir
- "../../3_Imaging//data/", // up 2 in tree, "/3_Imaging//" subdir
- "../../4_Finance//data/", // up 2 in tree, "/4_Finance//" subdir
- "../../5_Simulations//data/", // up 2 in tree, "/5_Simulations//" subdir
- "../../6_Advanced//data/", // up 2 in tree, "/6_Advanced//" subdir
- "../../7_CUDALibraries//data/", // up 2 in tree, "/7_CUDALibraries//" subdir
- "../../8_Android//data/", // up 2 in tree, "/8_Android//" subdir
- "../../samples//data/", // up 2 in tree, "/samples//" subdir
- "../../../", // up 3 in tree
- "../../../src//", // up 3 in tree, "/src//" subdir
- "../../../src//data/", // up 3 in tree, "/src//data/" subdir
- "../../../src//src/", // up 3 in tree, "/src//src/" subdir
- "../../../src//inc/", // up 3 in tree, "/src//inc/" subdir
- "../../../sandbox//", // up 3 in tree, "/sandbox//" subdir
- "../../../sandbox//data/", // up 3 in tree, "/sandbox//data/" subdir
- "../../../sandbox//src/", // up 3 in tree, "/sandbox//src/" subdir
- "../../../sandbox//inc/", // up 3 in tree, "/sandbox//inc/" subdir
- "../../../0_Simple//data/", // up 3 in tree, "/0_Simple//" subdir
- "../../../1_Utilities//data/", // up 3 in tree, "/1_Utilities//" subdir
- "../../../2_Graphics//data/", // up 3 in tree, "/2_Graphics//" subdir
- "../../../3_Imaging//data/", // up 3 in tree, "/3_Imaging//" subdir
- "../../../4_Finance//data/", // up 3 in tree, "/4_Finance//" subdir
- "../../../5_Simulations//data/", // up 3 in tree, "/5_Simulations//" subdir
- "../../../6_Advanced//data/", // up 3 in tree, "/6_Advanced//" subdir
- "../../../7_CUDALibraries//data/", // up 3 in tree, "/7_CUDALibraries//" subdir
- "../../../8_Android//data/", // up 3 in tree, "/8_Android//" subdir
- "../../../0_Simple//", // up 3 in tree, "/0_Simple//" subdir
- "../../../1_Utilities//", // up 3 in tree, "/1_Utilities//" subdir
- "../../../2_Graphics//", // up 3 in tree, "/2_Graphics//" subdir
- "../../../3_Imaging//", // up 3 in tree, "/3_Imaging/