-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mtzguido/misc
Misc changes to task pool
- Loading branch information
Showing
20 changed files
with
850 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module MSort.Parallel | ||
|
||
open Pulse.Lib.Pervasives | ||
module S = FStar.Seq | ||
module SZ = FStar.SizeT | ||
open MSort.SeqLemmas | ||
open MSort.Base | ||
|
||
```pulse | ||
fn | ||
rec | ||
msort | ||
(a : array int) | ||
(lo hi : SZ.t) | ||
(s : erased (S.seq int)) | ||
requires pts_to_range a (SZ.v lo) (SZ.v hi) (reveal s) | ||
ensures pts_to_range a (SZ.v lo) (SZ.v hi) (sort (reveal s)) | ||
{ | ||
pts_to_range_prop a; | ||
if ((hi `SZ.sub` lo) `SZ.lt` 2sz) { | ||
pts_to_range_prop a; | ||
singl_is_sorted s; | ||
() | ||
} else { | ||
let mid : SZ.t = lo `SZ.add` ((hi `SZ.sub` lo) `SZ.div` 2sz); | ||
|
||
pts_to_range_split a (SZ.v lo) (SZ.v mid) (SZ.v hi); | ||
|
||
with s1. assert (pts_to_range a (SZ.v lo) (SZ.v mid) s1); | ||
with s2. assert (pts_to_range a (SZ.v mid) (SZ.v hi) s2); | ||
|
||
parallel | ||
requires pts_to_range a (SZ.v lo) (SZ.v mid) (reveal s1) | ||
and pts_to_range a (SZ.v mid) (SZ.v hi) (reveal s2) | ||
ensures pts_to_range a (SZ.v lo) (SZ.v mid) (sort (reveal s1)) | ||
and pts_to_range a (SZ.v mid) (SZ.v hi) (sort (reveal s2)) | ||
{ msort a lo mid s1; } | ||
{ msort a mid hi s2; }; | ||
|
||
merge_impl a lo mid hi () (sort s1) (sort s2); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module MSort.Sequential | ||
|
||
open Pulse.Lib.Pervasives | ||
module S = FStar.Seq | ||
module SZ = FStar.SizeT | ||
open MSort.SeqLemmas | ||
open MSort.Base | ||
|
||
```pulse | ||
fn rec msort | ||
(a : array int) | ||
(lo hi : SZ.t) | ||
(s : erased (S.seq int)) | ||
requires pts_to_range a (SZ.v lo) (SZ.v hi) (reveal s) | ||
ensures pts_to_range a (SZ.v lo) (SZ.v hi) (sort (reveal s)) | ||
{ | ||
pts_to_range_prop a; | ||
if ((hi `SZ.sub` lo) `SZ.lt` 2sz) { | ||
pts_to_range_prop a; | ||
singl_is_sorted s; | ||
() | ||
} else { | ||
let mid : SZ.t = lo `SZ.add` ((hi `SZ.sub` lo) `SZ.div` 2sz); | ||
|
||
pts_to_range_split a (SZ.v lo) (SZ.v mid) (SZ.v hi); | ||
|
||
with s1. assert (pts_to_range a (SZ.v lo) (SZ.v mid) s1); | ||
with s2. assert (pts_to_range a (SZ.v mid) (SZ.v hi) s2); | ||
|
||
msort a lo mid s1; | ||
msort a mid hi s2; | ||
|
||
merge_impl a lo mid hi () (sort s1) (sort s2); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.