Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
100ea04
[libhooks] Add hooks for some LLVM Neon intrinsics and llvm.get.dynam…
neboat Mar 3, 2024
97b8f1b
[libhooks] Fix library hook for __memcpy_chk, when the length of the …
neboat Mar 3, 2024
210d9ab
[test/cilksan] Disable call-once test on Darwin, where the test is no…
neboat Mar 3, 2024
f1463ad
Resolve compiler warning about uninitialized field.
neboat Jul 5, 2024
5a30947
Fix lit configuration for newer Python versions.
neboat Jul 5, 2024
458233b
Update stacksave and stackrestore LLVM intrinsic hooks for LLVM 18.
neboat Jul 5, 2024
45895ae
[cilksan] Clean up #include's in Cilksan source and header files.
neboat Nov 1, 2024
c7dac9b
[cilksan] Add reducer hooks to Cilksan bitcode file.
neboat Dec 1, 2024
fadd97c
[cilksan] Add library hooks for cabs and fstat64.
neboat Dec 1, 2024
ed1d61b
[README] Add README with basic instructions for building cilktools as…
neboat Jan 26, 2024
416d427
[cilkscale] Draft change to use updated OpenCilk compiler support for…
neboat Jan 26, 2024
1b78733
[cilkscale] Convert shadow_stack class member from pointer to reducer…
neboat Sep 8, 2024
393e684
[cilkscale] Cleanup cilkscale and benchmark tools based on LLVM code …
neboat Dec 7, 2024
0b6d28f
[github] GitHub workflow to run small Cilk apps with Cilkscale and Ci…
neboat Jan 13, 2025
8bc2d9e
[cilkscale] Fix Cilkscale debug build after recent code cleanup.
neboat Jan 12, 2025
0541b1d
[benchmark] Fix Timer member variable in SERAL_TOOL build.
neboat Jan 13, 2025
f315b8f
[cilksan] Fix logic for combining reducer views to handle cases where…
neboat Jan 15, 2025
fc17e5e
[cilksan] Update llvm.va.start and llvm.va.end hooks for LLVM 19. Ad…
neboat Jan 13, 2025
b613bd7
[cilksan] Fix instrumentation of free() calls in code compiled withou…
neboat Mar 28, 2025
fc0af20
[github] Build only host targets.
neboat Mar 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .github/workflows/small-cilkapps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Small Cilk application tests

permissions:
contents: read

on:
workflow_dispatch:
push:
pull_request:

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
small-apps:
runs-on: ${{ matrix.os }}
container:
image: ${{(startsWith(matrix.os, 'ubuntu') && 'ghcr.io/llvm/ci-ubuntu-22.04:latest') || null}}
volumes:
- /mnt/:/mnt/
options: --user root
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-13, macOS-latest]
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup OpenCilk compiler
id: build-opencilk
uses: OpenCilk/actions/build-opencilk-project@main
with:
projects: clang
os_list: '${{ matrix.os }}'
extra_cmake_args: -DLLVM_TARGETS_TO_BUILD=host
- name: Build cheetah
id: build-cheetah
uses: OpenCilk/actions/build-cheetah@main
with:
opencilk_install: '${{ steps.build-opencilk.outputs.opencilk-installdir }}'
opencilk_build: '${{ steps.build-opencilk.outputs.opencilk-builddir }}'
- name: Build cilktools
id: build-cilktools
shell: bash
run: |
builddir="$(pwd)"/build
opencilkdir='${{ steps.build-opencilk.outputs.opencilk-installdir }}'
opencilkbuilddir='${{ steps.build-opencilk.outputs.opencilk-builddir }}'
clangversion="$($opencilkdir/bin/llvm-config --version | cut -d '.' -f 1)"
mkdir -p $builddir
cmake -G Ninja \
-B "$builddir" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=$opencilkdir/bin/clang \
-DCMAKE_CXX_COMPILER=$opencilkdir/bin/clang++ \
-DLLVM_CMAKE_DIR=$opencilkdir \
-DCMAKE_INSTALL_PREFIX=$opencilkdir \
-DLLVM_COMMON_CMAKE_UTILS=$opencilkbuilddir/../cmake \
-DCILKTOOLS_OUTPUT_DIR="$(pwd)"/lib/clang/$clangversion \
-DCILKTOOLS_INSTALL_PATH=$opencilkdir/lib/clang/$clangversion
ninja -C "$builddir" install
- name: Checkout small application tests
uses: actions/checkout@v4
with:
repository: OpenCilk/smallapps
path: smallapps
- name: Check Cilkscale
shell: bash
run: |
cheetahdir="$(pwd)"/build
opencilkdir='${{ steps.build-opencilk.outputs.opencilk-installdir }}'
make_prefix=""
if [ "${{ runner.os }}" == "macOS" ]; then
# Use xcrun to build benchmarks on macOS.
make_prefix="xcrun"
fi
$make_prefix make -C smallapps -B check \
CC=$opencilkdir/bin/clang \
CXX=$opencilkdir/bin/clang++ \
EXTRA_CFLAGS="-fcilktool=cilkscale" \
EXTRA_LDFLAGS="-fcilktool=cilkscale"
- name: Check Cilksan
shell: bash
run: |
cheetahdir="$(pwd)"/build
opencilkdir='${{ steps.build-opencilk.outputs.opencilk-installdir }}'
make_prefix=""
if [ "${{ runner.os }}" == "macOS" ]; then
# Use xcrun to build benchmarks on macOS.
make_prefix="xcrun"
fi
$make_prefix make -C smallapps -B one-check \
CC=$opencilkdir/bin/clang \
CXX=$opencilkdir/bin/clang++ \
EXTRA_CFLAGS="-fsanitize=cilk -g" \
EXTRA_LDFLAGS="-fsanitize=cilk"
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Building a standalone copy of the OpenCilk tools

These instructions assume that you are building the OpenCilk tools
using the OpenCilk compiler.

## Building with CMake

1. Make a build directory at the top level and enter it:

```console
mkdir build
cd build
```

2. Configure CMake. Make sure to specify `CMAKE_C_COMPILER`,
`CMAKE_CXX_COMPILER`, and `LLVM_CMAKE_DIR` to point to the
corresponding build or installation of the OpenCilk compiler
binaries. In addition, set `CMAKE_BUILD_TYPE` to specify the build
type, such as, `Debug`, for an unoptimized build with all
assertions enabled; `Release`, for an fully optimized build with
assertions disabled; or `RelWithDebInfo`, to enable some
optimizations and assertions. (The default build type is `Debug`.)

Example configuration:

```console
cmake -DCMAKE_C_COMPILER=/path/to/opencilk-project/build/bin/clang -DCMAKE_C_COMPILER=/path/to/opencilk-project/build/bin/clang++ -DCMAKE_BUILD_TYPE=Release -DLLVM_CMAKE_DIR=/path/to/opencilk-project/build ../

3. Build the runtime:

```console
cmake --build . -- -j<number of build threads>
```

To clean the build, run `cmake --build . --target clean` from the build
directory.
3 changes: 2 additions & 1 deletion cilksan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ set(CILKSAN_SOURCES

set(CILKSAN_BITCODE_SOURCE
driver.cpp
libhooks.cpp)
libhooks.cpp
reducers.cpp)

set(CILKSAN_RR_FILES
rr_commands.py)
Expand Down
8 changes: 3 additions & 5 deletions cilksan/cilksan.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <inttypes.h>

#include "cilksan_internal.h"
#include "debug_util.h"
#include "disjointset.h"
Expand All @@ -12,6 +7,9 @@
#include "simple_shadow_mem.h"
#include "spbag.h"
#include "stack.h"
#include <cstdio>
#include <cstdlib>
#include <iostream>

// FILE io used to print error messages
FILE *err_io = stderr;
Expand Down
6 changes: 2 additions & 4 deletions cilksan/cilksan_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
#ifndef __CILKSAN_INTERNAL_H__
#define __CILKSAN_INTERNAL_H__

#include <cstdio>
#include <iostream>
#include <unordered_map>

#include "addrmap.h"
#include "csan.h"
#include "dictionary.h"
Expand All @@ -15,6 +11,8 @@
#include "locksets.h"
#include "shadow_mem_allocator.h"
#include "stack.h"
#include <cstdio>
#include <unordered_map>

extern bool CILKSAN_INITIALIZED;

Expand Down
7 changes: 3 additions & 4 deletions cilksan/csanrt.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <cstdlib>
#include <assert.h>
#include <atomic>
#include <iostream>
#include "csan.h"
#include <atomic>
#include <cassert>
#include <cstdlib>

#define CSIRT_API __attribute__((visibility("default")))

Expand Down
6 changes: 3 additions & 3 deletions cilksan/debug_util.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "debug_util.h"
#include "driver.h"
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <strings.h>
#include <cstring>
#include <signal.h>
#include "debug_util.h"
#include "driver.h"

/*
static void print_bt(FILE *f) {
Expand Down
2 changes: 1 addition & 1 deletion cilksan/debug_util.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __DEBUG_UTIL_H__
#define __DEBUG_UTIL_H__

#include <assert.h>
#include <cassert>

#ifndef CILKSAN_DEBUG
#ifdef _DEBUG
Expand Down
10 changes: 4 additions & 6 deletions cilksan/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
#ifndef __DICTIONARY__
#define __DICTIONARY__

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <inttypes.h>

#include "debug_util.h"
#include "disjointset.h"
#include "frame_data.h"
#include "race_info.h"
#include "spbag.h"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <iostream>

using DS_t = DisjointSet_t<call_stack_t>;

Expand Down
8 changes: 4 additions & 4 deletions cilksan/disjointset.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#ifndef _DISJOINTSET_H
#define _DISJOINTSET_H

#include <cstdio>
#include <cstdlib>
#include <cstdint>

#include "aligned_alloc.h"
#include "debug_util.h"
#include "race_info.h"
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>

#if DISJOINTSET_DEBUG
#define WHEN_DISJOINTSET_DEBUG(stmt) do { stmt; } while(0)
Expand Down
35 changes: 24 additions & 11 deletions cilksan/driver.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#include "checking.h"
#include "cilksan_internal.h"
#include "debug_util.h"
#include "driver.h"
#include "race_info.h"
#include "stack.h"
#include <csi/csi.h>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <dlfcn.h>
#include <map>
#include <sys/mman.h>
#include <unistd.h>

#include "checking.h"
#include "cilksan_internal.h"
#include "debug_util.h"
#include "driver.h"
#include "race_detect_update.h"
#include "simple_shadow_mem.h"
#include "stack.h"

// FILE io used to print error messages
extern FILE *err_io;

Expand Down Expand Up @@ -1100,7 +1097,23 @@ CILKSAN_API void __cilksan_record_alloc(void *addr, size_t size) {

CILKSAN_API void __cilksan_record_free(void *ptr) {
CheckingRAII nocheck;
CilkSanImpl.mark_free(ptr);
if (!should_check()) {
CilkSanImpl.mark_free(ptr);
return;
}
const size_t *size = CilkSanImpl.malloc_sizes.get((uintptr_t)ptr);
if (CilkSanImpl.malloc_sizes.contains((uintptr_t)ptr)) {
if (!is_execution_parallel()) {
CilkSanImpl.clear_alloc((size_t)ptr, *size);
CilkSanImpl.clear_shadow_memory((size_t)ptr, *size);
} else {
// Treat a free as a write to all freed addresses. This way the tool will
// report a race if an operation tries to access a location that was freed
// in parallel.
CilkSanImpl.record_free((uintptr_t)ptr, *size, UNKNOWN_CSI_ID, MAType_t::FREE);
}
CilkSanImpl.malloc_sizes.remove((uintptr_t)ptr);
}
}

// FIXME: Currently these dynamic interposers are never used, because common
Expand Down
8 changes: 3 additions & 5 deletions cilksan/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
#ifndef __DRIVER_H__
#define __DRIVER_H__

#include <csi/csi.h>
#include <cstdint>
#include <utility>

#include "addrmap.h"
#include "cilksan_internal.h"
#include "locksets.h"
#include "stack.h"
#include <csi/csi.h>
#include <cstdint>
#include <utility>

#ifndef CILKSAN_VIS
#define CILKSAN_VIS __attribute__((visibility("default")))
Expand Down
2 changes: 0 additions & 2 deletions cilksan/frame_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#ifndef __FRAME_DATA_H__
#define __FRAME_DATA_H__

#include "cilksan_internal.h"
#include "csan.h"
#include "disjointset.h"
#include "hypertable.h"
#include "spbag.h"
Expand Down
10 changes: 7 additions & 3 deletions cilksan/hook_format.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
// and http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
// with a few common GNU extensions.

#include <cstdarg>

#include "debug_util.h"
#include "driver.h"
#include <csi/csi.h>
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <cstring>

#define CHECK(p) cilksan_assert(p)
#define CHECK_GT(n, v) cilksan_assert(n > 0)
Expand Down Expand Up @@ -149,7 +153,7 @@ static int format_get_value_size(char convSpecifier,
case 'z':
return sizeof(size_t);
case 't':
return sizeof(ptrdiff_t);
return sizeof(std::ptrdiff_t);
case 0:
return sizeof(int);
default:
Expand Down
5 changes: 1 addition & 4 deletions cilksan/hyperobject_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
#ifndef _HYPEROBJECT_BASE
#define _HYPEROBJECT_BASE

#include <cstddef>
#include <cstdint>
#include <cstdlib>

#include <cilk/cilk_api.h>
#include <cstdlib>

// Reducer data.
//
Expand Down
5 changes: 3 additions & 2 deletions cilksan/hypertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#ifndef _HYPERTABLE_H
#define _HYPERTABLE_H

#include <cstdint>
#include "hyperobject_base.h"
#include <cassert>
#include <cstdint>

// Helper methods for testing and setting keys.
static const uintptr_t KEY_EMPTY = 0UL;
Expand All @@ -26,7 +27,7 @@ class hyper_table {
// An entry in the hash table.
struct bucket {
uintptr_t key = KEY_EMPTY; /* EMPTY, DELETED, or a user-provided pointer. */
index_t hash; /* hash of the key when inserted into the table. */
index_t hash = 0; /* hash of the key when inserted into the table. */
reducer_base value;

void make_tombstone() { key = KEY_DELETED; }
Expand Down
Loading
Loading