Programming with Exceptions in JCilk
JCilk extends the Java language to provide call-return semantics for multithreading, much as Cilk does for C. Java's built-in thread model does not support the passing of exceptions or return values from one thread back to the "parent" thread that created it. JCilk imports Cilk'...
Main Authors: | , , |
---|---|
Format: | Article |
Language: | English |
Published: |
2005
|
Subjects: | |
Online Access: | http://hdl.handle.net/1721.1/30275 |
_version_ | 1826191973910839296 |
---|---|
author | Danaher, John S. Lee, I-Ting Angelina Leiserson, Charles E. |
author_facet | Danaher, John S. Lee, I-Ting Angelina Leiserson, Charles E. |
author_sort | Danaher, John S. |
collection | MIT |
description | JCilk extends the Java language to provide call-return semantics for multithreading, much as Cilk does for C. Java's built-in thread model does not support the passing of exceptions or return values from one thread back to the "parent" thread that created it. JCilk imports Cilk's fork-join primitives spawn and sync into Java to provide procedure-call semantics for concurrent subcomputations. This paper shows how JCilk integrates exception handling with multithreading by defining semantics consistent with the existing semantics of Java's try and catch constructs, but which
handle concurrency in spawned methods.
JCilk's strategy of integrating multithreading with Java's exception semantics yields some surprising semantic synergies. In particular, JCilk extends Java's exception semantics to allow exceptions to be passed from a spawned method to its parent in a natural way that obviates the need for Cilk's inlet and abort constructs. This extension is "faithful" in that it obeys Java's ordinary serial semantics when executed on a single processor. When executed in parallel, however, an exception thrown by a JCilk computation signals its sibling computations to abort, which yields a clean semantics in which only a single exception from the enclosing try block is handled. The decision to implicitly abort side computations opens a Pandora's box of subsidiary linguistic problems to be resolved, however. For instance, aborting might cause a computation to be interrupted asynchronously, causing havoc in programmer understanding of code behavior. To minimize the complexity of reasoning about aborts, JCilk signals them "semisynchronously" so that abort signals do not interrupt ordinary serial code. In addition, JCilk propagates an abort signal throughout a subcomputation naturally with a built-in CilkAbort exception, thereby allowing programmers to handle clean-up by simply catching the CilkAbort exception.
The semantics of JCilk allow programs with speculative computations to be programmed easily. Speculation is essential for parallelizing programs such as branch-and-bound or heuristic search. We show how JCilk's linguistic mechanisms can be used to program a solution to the "queens" problem and an implemention of a parallel alpha-beta search. |
first_indexed | 2024-09-23T09:04:13Z |
format | Article |
id | mit-1721.1/30275 |
institution | Massachusetts Institute of Technology |
language | English |
last_indexed | 2024-09-23T09:04:13Z |
publishDate | 2005 |
record_format | dspace |
spelling | mit-1721.1/302752019-04-10T20:33:07Z Programming with Exceptions in JCilk Danaher, John S. Lee, I-Ting Angelina Leiserson, Charles E. Cilk Spawn Sync JCilk extends the Java language to provide call-return semantics for multithreading, much as Cilk does for C. Java's built-in thread model does not support the passing of exceptions or return values from one thread back to the "parent" thread that created it. JCilk imports Cilk's fork-join primitives spawn and sync into Java to provide procedure-call semantics for concurrent subcomputations. This paper shows how JCilk integrates exception handling with multithreading by defining semantics consistent with the existing semantics of Java's try and catch constructs, but which handle concurrency in spawned methods. JCilk's strategy of integrating multithreading with Java's exception semantics yields some surprising semantic synergies. In particular, JCilk extends Java's exception semantics to allow exceptions to be passed from a spawned method to its parent in a natural way that obviates the need for Cilk's inlet and abort constructs. This extension is "faithful" in that it obeys Java's ordinary serial semantics when executed on a single processor. When executed in parallel, however, an exception thrown by a JCilk computation signals its sibling computations to abort, which yields a clean semantics in which only a single exception from the enclosing try block is handled. The decision to implicitly abort side computations opens a Pandora's box of subsidiary linguistic problems to be resolved, however. For instance, aborting might cause a computation to be interrupted asynchronously, causing havoc in programmer understanding of code behavior. To minimize the complexity of reasoning about aborts, JCilk signals them "semisynchronously" so that abort signals do not interrupt ordinary serial code. In addition, JCilk propagates an abort signal throughout a subcomputation naturally with a built-in CilkAbort exception, thereby allowing programmers to handle clean-up by simply catching the CilkAbort exception. The semantics of JCilk allow programs with speculative computations to be programmed easily. Speculation is essential for parallelizing programs such as branch-and-bound or heuristic search. We show how JCilk's linguistic mechanisms can be used to program a solution to the "queens" problem and an implemention of a parallel alpha-beta search. Singapore-MIT Alliance (SMA) 2005-12-14T19:35:11Z 2005-12-14T19:35:11Z 2006-01 Article http://hdl.handle.net/1721.1/30275 en Computer Science (CS) 107579 bytes application/pdf application/pdf |
spellingShingle | Cilk Spawn Sync Danaher, John S. Lee, I-Ting Angelina Leiserson, Charles E. Programming with Exceptions in JCilk |
title | Programming with Exceptions in JCilk |
title_full | Programming with Exceptions in JCilk |
title_fullStr | Programming with Exceptions in JCilk |
title_full_unstemmed | Programming with Exceptions in JCilk |
title_short | Programming with Exceptions in JCilk |
title_sort | programming with exceptions in jcilk |
topic | Cilk Spawn Sync |
url | http://hdl.handle.net/1721.1/30275 |
work_keys_str_mv | AT danaherjohns programmingwithexceptionsinjcilk AT leeitingangelina programmingwithexceptionsinjcilk AT leisersoncharlese programmingwithexceptionsinjcilk |