implicit threading, speculation, and mutation in manticoreintroduction manticore the manticore...
TRANSCRIPT
![Page 1: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/1.jpg)
Implicit threading, Speculation, and Mutationin
Manticore
John Reppy
University of Chicago
April 30, 2010
![Page 2: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/2.jpg)
Introduction
Overview
This talk is about some very preliminary ideas for the next step in thedesign of the Parallel ML (PML) language, which is part of theManticore system.Specifically, we are exploring three related ways to grow the language:
1. better support for speculative parallelism2. support for shared state between implicitly-parallel computations3. supporting nondeterminism to increase parallelism
This talk focuses on the first two.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 2
![Page 3: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/3.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 4: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/4.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 5: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/5.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 6: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/6.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 7: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/7.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 8: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/8.jpg)
Introduction Manticore
The Manticore Project
I The Manticore project is our effort to address the programmingneeds of commodity applications running on multicore SMPsystems
I Prototype language design supports different levels of parallelismI High-level declarative mechanisms for fine-grain parallelismI No shared memoryI Preserve determinism where possible
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 3
![Page 9: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/9.jpg)
Introduction Manticore
The Manticore Project (continued ...)
Our initial language design is called Parallel ML (PML).I Sequential core language based on subset of SML: strict with no
mutable storage.I A variety of lightweight implicitly-threaded constructs for fine-grain
parallelism.I Explicitly-threaded parallelism based on CML: message passing
with first-class synchronization.I Prototype implementation with good scaling on 16-way parallel
hardware for a range of applications.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 4
![Page 10: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/10.jpg)
Introduction Manticore
The Manticore Project (continued ...)
Our initial language design is called Parallel ML (PML).I Sequential core language based on subset of SML: strict with no
mutable storage.I A variety of lightweight implicitly-threaded constructs for fine-grain
parallelism.I Explicitly-threaded parallelism based on CML: message passing
with first-class synchronization.I Prototype implementation with good scaling on 16-way parallel
hardware for a range of applications.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 4
![Page 11: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/11.jpg)
Introduction Manticore
The Manticore Project (continued ...)
Our initial language design is called Parallel ML (PML).I Sequential core language based on subset of SML: strict with no
mutable storage.I A variety of lightweight implicitly-threaded constructs for fine-grain
parallelism.I Explicitly-threaded parallelism based on CML: message passing
with first-class synchronization.I Prototype implementation with good scaling on 16-way parallel
hardware for a range of applications.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 4
![Page 12: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/12.jpg)
Introduction Manticore
The Manticore Project (continued ...)
Our initial language design is called Parallel ML (PML).I Sequential core language based on subset of SML: strict with no
mutable storage.I A variety of lightweight implicitly-threaded constructs for fine-grain
parallelism.I Explicitly-threaded parallelism based on CML: message passing
with first-class synchronization.I Prototype implementation with good scaling on 16-way parallel
hardware for a range of applications.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 4
![Page 13: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/13.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 14: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/14.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 15: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/15.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 16: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/16.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 17: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/17.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 18: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/18.jpg)
Implicit threading
Implicit threading
PML provides several light-weight syntactic forms for introducingparallel computation.
I Nested Data-parallel arrays provide fine-grain data-parallelcomputations over sequences.
I Parallel tuples provide a basic fork-join parallel computation.I Parallel bindings provide data-flow parallelism with cancellation of
unused subcomputations.I Parallel cases provide non-deterministic speculative parallelism.
These forms are declarations that a computation is a good candidatefor parallel execution, but the details are left to the implementation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 5
![Page 19: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/19.jpg)
Implicit threading
Implicit threading design space
We can organize these features by how well behaved they are.
non-speculative deterministicspeculation
nondeterministicspeculation
speculation+ mutation
Manticore 1.0
(| |)[| |]
pval pcase
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 6
![Page 20: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/20.jpg)
Implicit threading
Implicit threading design space
We can organize these features by how well behaved they are.
non-speculative deterministicspeculation
nondeterministicspeculation
speculation+ mutation
Manticore 1.0
(| |)[| |]
pval pcase
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 6
![Page 21: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/21.jpg)
Speculation
The need for speculation
I Amdahl’s Law tells us that as the number of cores increases,execution time will be dominated by sequential code.
I Speculation is an important tool for introducing parallelism inotherwise sequential code.
I PML supports both deterministic and nondeterministicspeculation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 7
![Page 22: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/22.jpg)
Speculation
The need for speculation
I Amdahl’s Law tells us that as the number of cores increases,execution time will be dominated by sequential code.
I Speculation is an important tool for introducing parallelism inotherwise sequential code.
I PML supports both deterministic and nondeterministicspeculation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 7
![Page 23: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/23.jpg)
Speculation
The need for speculation
I Amdahl’s Law tells us that as the number of cores increases,execution time will be dominated by sequential code.
I Speculation is an important tool for introducing parallelism inotherwise sequential code.
I PML supports both deterministic and nondeterministicspeculation.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 7
![Page 24: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/24.jpg)
Speculation
Parallel bindings
Parallel bindings allow deterministic speculation. For example, thecomputation of b may not be needed in the following program:
datatype tree = LF of long | ND of tree * tree
fun treeMul (LF n) = n| treeMul (ND(t1, t2)) = let
pval b = treeMul t2val a = treeMul t1in
if (a = 0) then 0 else a*bend
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 8
![Page 25: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/25.jpg)
Speculation
Parallel case
Parallel case supports non-deterministic speculation when we want thequickest answer (e.g., search problems). For example, considerpicking a leaf of the tree:
fun treePick (LF n) = n| treePick (ND(t1, t2)) = (
pcase treePick t1 & treePick t2of ? & n => n| n & ? => n)
There is some similarity with join patterns.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 9
![Page 26: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/26.jpg)
Speculation
Extending speculation to collections
Using pcase, one can define speculative functions over lists:
fun pExists f [] = false| pExists f (x::xs) = (pcase f x & pExists f xs
of true & ? => true| ? & true => true| false & false => false)
We plan to provide similar operations on our data-parallel arrays,which will avoid the sequential bottleneck of the list-based operations.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 10
![Page 27: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/27.jpg)
Mutation
The need for shared mutable state
I Mutable storage is a very powerful communication mechanism:essentially a broadcast mechanism supported by the memoryhardware.
I Sequential algorithms and data-structures gain significant(asymptotic) performance benefits from shared memory (e.g.,union-find with path compression).
I Some algorithms seem hard/impossible to parallelize withoutshared state (e.g., mesh refinement).
I But shared memory makes parallel programming hard, so wewant to be cautious in adding it to PML.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 11
![Page 28: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/28.jpg)
Mutation
The need for shared mutable state
I Mutable storage is a very powerful communication mechanism:essentially a broadcast mechanism supported by the memoryhardware.
I Sequential algorithms and data-structures gain significant(asymptotic) performance benefits from shared memory (e.g.,union-find with path compression).
I Some algorithms seem hard/impossible to parallelize withoutshared state (e.g., mesh refinement).
I But shared memory makes parallel programming hard, so wewant to be cautious in adding it to PML.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 11
![Page 29: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/29.jpg)
Mutation
The need for shared mutable state
I Mutable storage is a very powerful communication mechanism:essentially a broadcast mechanism supported by the memoryhardware.
I Sequential algorithms and data-structures gain significant(asymptotic) performance benefits from shared memory (e.g.,union-find with path compression).
I Some algorithms seem hard/impossible to parallelize withoutshared state (e.g., mesh refinement).
I But shared memory makes parallel programming hard, so wewant to be cautious in adding it to PML.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 11
![Page 30: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/30.jpg)
Mutation
The need for shared mutable state
I Mutable storage is a very powerful communication mechanism:essentially a broadcast mechanism supported by the memoryhardware.
I Sequential algorithms and data-structures gain significant(asymptotic) performance benefits from shared memory (e.g.,union-find with path compression).
I Some algorithms seem hard/impossible to parallelize withoutshared state (e.g., mesh refinement).
I But shared memory makes parallel programming hard, so wewant to be cautious in adding it to PML.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 11
![Page 31: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/31.jpg)
Mutation
The design challenge
I How do we add shared memory while preserving PML’sdeclarative programming model for fine-grain parallelism?
I Some races are okay in an implicitly-threaded setting.I Deadlock is not okay in an implicitly-threaded setting.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 12
![Page 32: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/32.jpg)
Mutation
The design challenge
I How do we add shared memory while preserving PML’sdeclarative programming model for fine-grain parallelism?
I Some races are okay in an implicitly-threaded setting.I Deadlock is not okay in an implicitly-threaded setting.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 12
![Page 33: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/33.jpg)
Mutation
The design challenge
I How do we add shared memory while preserving PML’sdeclarative programming model for fine-grain parallelism?
I Some races are okay in an implicitly-threaded setting.I Deadlock is not okay in an implicitly-threaded setting.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 12
![Page 34: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/34.jpg)
Mutation
Example: Minimax search
I Algorithms, such as minimax search and SAT solving, can benefitfrom sharing information between branches of the search.
I For game search, transposition tables are used to turn the searchtree into a DAG.
I Transposition tables provide a kind of function memoization.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 13
![Page 35: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/35.jpg)
Mutation
Example: Minimax search
I Algorithms, such as minimax search and SAT solving, can benefitfrom sharing information between branches of the search.
I For game search, transposition tables are used to turn the searchtree into a DAG.
I Transposition tables provide a kind of function memoization.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 13
![Page 36: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/36.jpg)
Mutation
Example: Minimax search
I Algorithms, such as minimax search and SAT solving, can benefitfrom sharing information between branches of the search.
I For game search, transposition tables are used to turn the searchtree into a DAG.
I Transposition tables provide a kind of function memoization.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 13
![Page 37: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/37.jpg)
Mutation
Transposition tables
XX
X OXO
XXOX
XO
XX
X OXO
XXO
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 14
![Page 38: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/38.jpg)
Mutation
Transposition tables (continued ...)
I For Tic-Tac-Toe, using a transposition table results in a 34-foldreduction in the number of board positions searched.
I Thus, a sequential search that uses a transposition table is likelyto beat a parallel search that doesn’t.
I Want to support sharing information between parallel branches.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 15
![Page 39: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/39.jpg)
Mutation
Transposition tables (continued ...)
I For Tic-Tac-Toe, using a transposition table results in a 34-foldreduction in the number of board positions searched.
I Thus, a sequential search that uses a transposition table is likelyto beat a parallel search that doesn’t.
I Want to support sharing information between parallel branches.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 15
![Page 40: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/40.jpg)
Mutation
Transposition tables (continued ...)
I For Tic-Tac-Toe, using a transposition table results in a 34-foldreduction in the number of board positions searched.
I Thus, a sequential search that uses a transposition table is likelyto beat a parallel search that doesn’t.
I Want to support sharing information between parallel branches.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 15
![Page 41: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/41.jpg)
Mutation
Possible feature: Blackboards
I Implementing memoization in a general-purpose language posesa lot of challenges, such as efficient equality testing and hashingfor user-defined types.
I An alternative are blackboards, which are essentially shared hashtables.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 16
![Page 42: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/42.jpg)
Mutation
Possible feature: Blackboards
I Implementing memoization in a general-purpose language posesa lot of challenges, such as efficient equality testing and hashingfor user-defined types.
I An alternative are blackboards, which are essentially shared hashtables.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 16
![Page 43: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/43.jpg)
Mutation
Adding blackboards to PML
Write-once blackboards; returns value if already set.
val setIfNotSet : (’a bb * key * ’a) -> ’a option
Memoize a function so that it is evaluated no more than once per call.
fun memo (bb, keyFn, f) x = letval iv = ivarNew()in
case setIfNotSet (bb, keyFn x, iv)of SOME iv’ => ivarGet iv’| NONE => let
val y = f xin ivarSet (iv, y); y end
end
This approach fits well with our existing mechanisms.
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 17
![Page 44: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/44.jpg)
Mutation
What is the right level of abstraction?
I One approach is to provide a collection of parallel data structures,such as blackboards.
I Alternatively, we can provide lower-level mechanisms.I For example, blackboards can be built from synchronous variables
(MVars and IVars), but synchronous variables introduce thepossibility of deadlock.
I Perhaps STM is the solution?
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 18
![Page 45: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/45.jpg)
Mutation
What is the right level of abstraction?
I One approach is to provide a collection of parallel data structures,such as blackboards.
I Alternatively, we can provide lower-level mechanisms.I For example, blackboards can be built from synchronous variables
(MVars and IVars), but synchronous variables introduce thepossibility of deadlock.
I Perhaps STM is the solution?
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 18
![Page 46: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/46.jpg)
Mutation
What is the right level of abstraction?
I One approach is to provide a collection of parallel data structures,such as blackboards.
I Alternatively, we can provide lower-level mechanisms.I For example, blackboards can be built from synchronous variables
(MVars and IVars), but synchronous variables introduce thepossibility of deadlock.
I Perhaps STM is the solution?
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 18
![Page 47: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/47.jpg)
Mutation
What is the right level of abstraction?
I One approach is to provide a collection of parallel data structures,such as blackboards.
I Alternatively, we can provide lower-level mechanisms.I For example, blackboards can be built from synchronous variables
(MVars and IVars), but synchronous variables introduce thepossibility of deadlock.
I Perhaps STM is the solution?
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 18
![Page 48: Implicit threading, Speculation, and Mutation in ManticoreIntroduction Manticore The Manticore Project I The Manticore project is our effort to address the programming needs of commodity](https://reader034.vdocument.in/reader034/viewer/2022042115/5e92bb3b2a661f1f537eb69a/html5/thumbnails/48.jpg)
Mutation
PeopleLars Bergstrom University of ChicagoMatthew Fluet Rochester Institute of TechnologyMike Rainey University of ChicagoAdam Shaw University of ChicagoYingqi Xiao University of Chicago
with help from
Nic Ford University of ChicagoKorie Klein University of ChicagoJoshua Knox University of ChicagoJon Riehl University of ChicagoRidg Scott University of Chicago
http://manticore.cs.uchicago.edu
TMW 2010 Implicit threading, Speculation, and Mutation in Manticore 19