Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions .github/workflows/cmake-test-release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# from GitHub each run is quick; GC is rebuilt every run anyway.
- name: Delete __Build TS folders
continue-on-error: true
run: rm -R ./__build/tslang/ninja/release
run: rm -rf ./__build/tslang/ninja/release
shell: sh

- name: Create __Build Folders
Expand Down Expand Up @@ -139,11 +139,21 @@ jobs:
shell: sh
run: cmake ../../../../tslang -G "Ninja" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -Wno-dev

# The hosted runner has 4 cores and 16 GB: 8 compiles of the MLIR sources at once (2-3 GB each) ran it out of
# memory, and it dropped off ("The hosted runner lost communication with the server"). One job per core, as
# create-release.yml builds, and 8 GB more swap for the peaks.
- name: Add swap
continue-on-error: true
shell: sh
run: |
sudo fallocate -l 8G /swapfile_build && sudo chmod 600 /swapfile_build && sudo mkswap /swapfile_build && sudo swapon /swapfile_build
free -h

- name: Build
continue-on-error: false
working-directory: ${{github.workspace}}/__build/tslang/ninja/release
shell: sh
run: cmake --build . --config ${{ env.BUILD_TYPE }} -j 8
run: cmake --build . --config ${{ env.BUILD_TYPE }} -j 4

# The JIT tests are the ones named test-jit-*; every other test is the exe leg's.
- name: Test (Ubuntu 22.04, ${{ matrix.programs }} programs, ${{ matrix.kind }})
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jobs:

- name: Delete __Build TS folders
continue-on-error: true
run: rm -R ./__build/tslang/ninja/release
run: rm -rf ./__build/tslang/ninja/release
shell: sh

- name: Create __Build Folders
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ them on the fly via a built-in JIT — no Node.js or JavaScript runtime required

- [Quick start](#quick-start)
- [Memory models](#memory-models)
- [GPU kernels](#gpu-kernels)
- [Documentation](#documentation)
- [Showcase: native_ts_graphics](#showcase-native_ts_graphics)
- [Community](#community) · [License](#license) · [Contributing](#contributing)
Expand Down Expand Up @@ -81,8 +82,44 @@ How heap memory is managed is selected with `-mm=`:
| `-mm=own` | single ownership inferred at compile time, like Rust's borrow checker - no collector, no counting | **in development**; ownership that cannot be proven is a compile error |

See [memory-models.md](docs/memory-models.md) and the [`-mm=own` guide](docs/own-memory-model.md).
Under `-mm=own` tslang runs within 1.1-1.4x of idiomatic Rust on an object-heavy ray tracer and on
par with it on array loops — see [Performance](docs/performance.md).

`-mm=own` is Rust-style ownership: the compiler decides at compile time where each object is freed,
so a program runs with no collector and no reference counts, and its speed is close to Rust's
(release builds, ms, lower is better):

| benchmark | `-mm=own` | Rust | C++ (clang -O3) |
| --- | --- | --- | --- |
| ray tracer, classes and `switch` (Rust: enums and `match`; Linux) | 50 | 50 | |
| ray tracer, interfaces and closures (Rust: plain values; Windows) | 76 | 56 | 52 |
| array loops: matmul / hash (Linux) | 26.7 / 48.0 | 20.6 / 44.4 | 30.1 / 42.8 |

Written with every object in an `Rc` (a `shared_ptr` in C++), as code that shares objects freely must be,
the interface ray tracer takes 500 ms in Rust and 834 ms in C++. The details, the machines and the
other models are in [Performance](docs/performance.md).

## GPU kernels

A function marked `@kernel` runs on the GPU, one thread per index, on NVIDIA, AMD and Intel GPUs,
both from executables and from the JIT. No GPU SDK is needed to compile or to run: the program loads
the GPU's driver itself.

```typescript
@kernel
function add(i: int, a: number[], b: number[], c: number[]) {
c[i] = a[i] + b[i];
}

function main() {
const a: number[] = [1, 2, 3];
const b: number[] = [10, 20, 30];
const c: number[] = [0, 0, 0];
gpuLaunch(add, 3, a, b, c);
print(c); // [ 11, 22, 33 ]
}
```

The interface ray tracer above, one GPU thread per pixel (`rtbench_gpu.ts`), renders 512x512 in 1.9 ms on an RTX 5080. See
[GPU kernels](docs/gpu.md) for `gpuMap`/`gpuReduce`/`gpuSort`, shared memory, atomics and more.

## Documentation

Expand Down
Loading
Loading