Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fixci' into main
Browse files Browse the repository at this point in the history
* origin/fixci:
  Allow GHC 8.6.5 and 8.4.4 to fail
  Use GCC11 and use ghcup to install GHC
  Use Ubuntu 22.04 on CI
  Minor tweak to the workflow file
  Improve code quality of Common.hs, Compiler.hs
  Modify github workflows
  Fix float case when rhs of a let binding is also a case expression
  wip: check RB invariants
  Check in jazullo's RB tree
  Inferlocs: fix releasing bindings in case exprs
  Alias analysis for copy calls
  Remove nursery/fast-allocation bits from RTS
  Add head, tail, is_empty to PList
  InferLocations.hs: Fix copy-calls floating outside scope, fix order in which copyCalls are generated. Compiler.hs: Change the order in which copyOutOfOrderPacked is called, simplify binds and regions Inwards RegionsInwards.hs: fix case for DataConE LayoutBenchmarks: Remove copyCalls in haskell code since they are not needed after this commit. test_191.hs: Add test file for issue 191 tests/config.yaml: Add issue 191 test case.
  • Loading branch information
ckoparkar committed Jun 14, 2023
2 parents a951808 + f99ee41 commit af2c23c
Show file tree
Hide file tree
Showing 40 changed files with 913 additions and 360 deletions.
53 changes: 29 additions & 24 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' '--config=cabal.haskell-ci' 'cabal.project'
# haskell-ci '--distribution' 'jammy' 'github' 'cabal.project'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.15.20221225
# version: 0.16.3
#
# REGENDATA ("0.15.20221225",["github","--config=cabal.haskell-ci","cabal.project"])
# REGENDATA ("0.16.3",["--distribution","jammy","github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -19,11 +19,11 @@ on:
jobs:
linux:
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes:
60
container:
image: buildpack-deps:bionic
image: buildpack-deps:jammy
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
Expand Down Expand Up @@ -51,18 +51,18 @@ jobs:
- compiler: ghc-8.8.4
compilerKind: ghc
compilerVersion: 8.8.4
setup-method: hvr-ppa
setup-method: ghcup
allow-failure: false
- compiler: ghc-8.6.5
compilerKind: ghc
compilerVersion: 8.6.5
setup-method: hvr-ppa
allow-failure: false
setup-method: ghcup
allow-failure: true
- compiler: ghc-8.4.4
compilerKind: ghc
compilerVersion: 8.4.4
setup-method: hvr-ppa
allow-failure: false
setup-method: ghcup
allow-failure: true
fail-fast: false
steps:
- name: apt
Expand All @@ -71,18 +71,18 @@ jobs:
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.18.0/x86_64-linux-ghcup-0.1.18.0 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
Expand All @@ -95,18 +95,19 @@ jobs:
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
Expand Down Expand Up @@ -158,14 +159,14 @@ jobs:
- name: install cabal-plan
run: |
mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > cabal-plan.xz
echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c -
curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.7.3.0/cabal-plan-0.7.3.0-x86_64-linux.xz > cabal-plan.xz
echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c -
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
rm -f cabal-plan.xz
chmod a+x $HOME/.cabal/bin/cabal-plan
cabal-plan --version
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: source
- name: initial cabal.project for sdist
Expand Down Expand Up @@ -200,13 +201,11 @@ jobs:
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
cabal-plan
- name: cache
uses: actions/cache@v2
- name: restore cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: |
~/.cabal/store
~/.cabal/packages
path: ~/.cabal/store
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
- name: install dependencies
run: |
Expand All @@ -218,3 +217,9 @@ jobs:
- name: tests
run: |
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: save cache
uses: actions/cache/save@v3
if: always()
with:
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
45 changes: 31 additions & 14 deletions .github/workflows/test-gibbon-examples.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
name: Test Gibbon examples
on:
- push
- pull_request
on: [ push, pull_request ]
jobs:
linux:
name: test-gibbon-examples
runs-on: ubuntu-18.04
name: test-gibbon
runs-on: ubuntu-22.04
steps:
- name: dependencies
run: |
sudo apt-get update
sudo apt-add-repository -y 'ppa:hvr/ghc'
sudo apt-get update
sudo add-apt-repository -y 'ppa:plt/racket'
sudo apt-get update
sudo apt-get install -y libgc-dev libgmp-dev uthash-dev gcc-7 ghc-9.0.1 racket
sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt-get install -y libgc-dev libgmp-dev uthash-dev gcc-11 racket
sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-11 /usr/bin/gcc
- name: ghc and cabal
env:
HCKIND: ghc
HCVER: 9.0.1
run: |
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
sudo chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
echo "HC=$HC" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "$HOME/.ghcup/bin/" >> $GITHUB_PATH
- name: versions
run: |
ghc --version
Expand All @@ -25,8 +37,8 @@ jobs:
cabal --version
- name: checkout
uses: actions/checkout@v2
- run: cabal v2-update -w /opt/ghc/9.0.1/bin/ghc
- run: cabal v2-freeze -w /opt/ghc/9.0.1/bin/ghc
- run: cabal v2-update -w $HC
- run: cabal v2-freeze -w $HC
- name: cache-cabal
uses: actions/cache@v3
with:
Expand All @@ -40,8 +52,13 @@ jobs:
- name: build
run: |
cd gibbon-compiler
cabal v2-update -w /opt/ghc/9.0.1/bin/ghc
cabal v2-build -w /opt/ghc/9.0.1/bin/ghc .
cabal v2-update -w $HC
cabal v2-build -w $HC .
- name: cache-answers
uses: actions/cache@v2
with:
key: ${{ runner.os }}-answers
path: gibbon-compiler/examples/build_tmp/*.ans
- name: answers
run: |
cd gibbon-compiler
Expand All @@ -53,4 +70,4 @@ jobs:
run: |
export GIBBONDIR=`pwd`
cd gibbon-compiler/
cabal v2-exec -w /opt/ghc/9.0.1/bin/ghc test-gibbon-examples -- -v2
cabal v2-exec -w $HC test-gibbon-examples -- -v2
72 changes: 10 additions & 62 deletions gibbon-compiler/examples/gc/Reverse_master_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,55 +180,14 @@ void restore_alloc_state() {}
#endif // BUMPALLOC


// -------------------------------------
// Bump allocated nursery for regions
// -------------------------------------

// See https://github.com/iu-parfunc/gibbon/issues/122.

__thread char* nursery_heap_ptr = (char*)NULL;
__thread char* nursery_heap_ptr_end = (char*)NULL;

#define NURSERY_SIZE 0
// #define NURSERY_SIZE global_init_biginf_buf_size
#define NURSERY_ALLOC_UPPER_BOUND 1024

static inline void init_nursery() {
nursery_heap_ptr = (char*)malloc(NURSERY_SIZE);
if (nursery_heap_ptr == NULL) {
printf("init_region: malloc failed: %d", NURSERY_SIZE);
exit(1);
}
nursery_heap_ptr_end = nursery_heap_ptr + NURSERY_SIZE;
#ifdef _DEBUG
printf("init_nursery: DONE, heap_ptr = %p\n", nursery_heap_ptr);
#endif
}

static inline void* alloc_in_nursery(long long n) {
if (! nursery_heap_ptr) {
init_nursery();
}
if (nursery_heap_ptr + n < nursery_heap_ptr_end) {
char* old = nursery_heap_ptr;
nursery_heap_ptr += n;
#ifdef _DEBUG
printf("alloc_in_nursery: DONE, %lld\n", n);
#endif
return old;
} else {
return NULL;
}
}

// -------------------------------------
// ALLOC and ALLOC_PACKED macros
// -------------------------------------


/*
If parallelism is enabled, we always use a nursery/malloc based allocator
If parallelism is enabled, we always use a malloc based allocator
since Boehm GC is not thread-safe in its default configuration. It can be
made thread-safe by building it with appropriate flags, but we don't do that.
Presently, all parallel pointer-based programs will leak memory.
Expand Down Expand Up @@ -641,7 +600,7 @@ Garbage collection
and for garbage collection. The footer:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
serialized data | rf_reg_metadata_ptr | rf_seq_no | rf_nursery_allocated | rf_size | rf_next | rf_prev
serialized data | rf_reg_metadata_ptr | rf_seq_no | rf_size | rf_next | rf_prev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The metadata after the serialized data serves various purposes:
Expand All @@ -659,8 +618,6 @@ Garbage collection
- rf_seq_no: The index of this particular chunk in the list.
- rf_nursery_allocated: Whether this chunk was allocated in a nursery.
- rf_size: Used during bounds checking to calculate the size of the next region in
the linked list.
Expand Down Expand Up @@ -710,7 +667,6 @@ typedef struct RegionFooter_struct {
RegionTy *rf_reg_metadata_ptr;

IntTy rf_seq_no;
bool rf_nursery_allocated;
IntTy rf_size;
struct RegionFooter_struct *rf_next;
struct RegionFooter_struct *rf_prev;
Expand Down Expand Up @@ -771,9 +727,7 @@ RegionTy *alloc_region(IntTy size) {

// Allocate the first chunk.
IntTy total_size = size + sizeof(RegionFooter);
CursorTy heap;
bool nursery_allocated = false;
heap = malloc(total_size);
CursorTy heap = ALLOC_PACKED_BIG(total_size);
if (heap == NULL) {
printf("alloc_region: malloc failed: %lld", total_size);
exit(1);
Expand All @@ -788,14 +742,13 @@ RegionTy *alloc_region(IntTy size) {
reg->reg_outset_len = 0;

#ifdef _DEBUG
printf("Allocated a region(%lld): %lld bytes, nursery=%d.\n", reg->reg_id, size, nursery_allocated);
printf("Allocated a region(%lld): %lld bytes.\n", reg->reg_id, size);
#endif

// Write the footer.
RegionFooter *footer = (RegionFooter *) heap_end;
footer->rf_reg_metadata_ptr = reg;
footer->rf_seq_no = 1;
footer->rf_nursery_allocated = nursery_allocated;
footer->rf_size = size;
footer->rf_next = NULL;
footer->rf_prev = NULL;
Expand Down Expand Up @@ -834,7 +787,6 @@ ChunkTy alloc_chunk(CursorTy end_old_chunk) {
RegionFooter* new_footer = (RegionFooter *) end;
new_footer->rf_reg_metadata_ptr = footer->rf_reg_metadata_ptr;
new_footer->rf_seq_no = footer->rf_seq_no + 1;
new_footer->rf_nursery_allocated = false;
new_footer->rf_size = newsize;
new_footer->rf_next = NULL;
new_footer->rf_prev = footer;
Expand Down Expand Up @@ -980,18 +932,14 @@ void free_region(CursorTy end_reg) {
next_chunk = (char*) footer->rf_next;

#ifdef _DEBUG
printf("free_region(%lld): first chunk in nursery: %d\n",
reg->reg_id,
first_chunk_footer->rf_nursery_allocated);
printf("free_region(%lld)\n", reg->reg_id);
#endif

if (! first_chunk_footer->rf_nursery_allocated) {
#ifdef _DEBUG
num_freed_chunks++;
total_bytesize = total_bytesize + first_chunk_footer->rf_size;
#endif
free(first_chunk);
}
#ifdef _DEBUG
num_freed_chunks++;
total_bytesize = total_bytesize + first_chunk_footer->rf_size;
#endif
free(first_chunk);

while (next_chunk != NULL) {
next_chunk_footer = (RegionFooter *) next_chunk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ emphKeywordInContent keyword blogs =
--_ = printPacked newContent
--_ = printsym (quote "NEWLINE")
newRst = emphKeywordInContent keyword rst
in Layout1 (header) (id) (author) (copyPacked date) (copyPacked newContent) (copyPacked tags) (copyPacked newRst)
in Layout1 header id author date newContent tags newRst

-- main function
gibbon_main =
Expand Down Expand Up @@ -98,14 +98,14 @@ gibbon_main =
ft10 = readArrayFile (Just ("blog10/blog10Tag.txt", 485))
lfc = mkListFiles fc1 fc2 fc3 fc4 fc5 fc6 fc7 fc8 fc9 fc10 9
ltc = mkListFiles ft1 ft2 ft3 ft4 ft5 ft6 ft7 ft8 ft9 ft10 9
blogs = mkBlogs_layout1 lfc ltc 10000
--_ = printPacked blogs
--_ = printsym (quote "NEWLINE")
--_ = printsym (quote "NEWLINE")
blogs = mkBlogs_layout1 lfc ltc 2
_ = printPacked blogs
_ = printsym (quote "NEWLINE")
_ = printsym (quote "NEWLINE")
keyword :: Vector Char
keyword = "feelings"
newblgs = iterate (emphKeywordInContent keyword blogs)
--_ = printPacked newblgs
--_ = printsym (quote "NEWLINE")
--_ = printsym (quote "NEWLINE")
_ = printPacked newblgs
_ = printsym (quote "NEWLINE")
_ = printsym (quote "NEWLINE")
in ()
Loading

0 comments on commit af2c23c

Please sign in to comment.