Skip to content

Commit

Permalink
Merge branch 'master' into ci-mi100
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Aug 15, 2024
2 parents ff2528a + 13ee071 commit 312ba0b
Show file tree
Hide file tree
Showing 189 changed files with 1,720 additions and 680 deletions.
2 changes: 1 addition & 1 deletion .github/actions/benchmark/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ runs:
module load perl
cd futhark-benchmarks
./get-data.sh external-data.txt
slurm-options: --time=10:00 -c 1
slurm-options: --time=30:00 -c 1

- uses: ./.github/actions/futhark-slurm
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27

- uses: cachix/cachix-action@v12
- uses: cachix/cachix-action@v15
with:
name: futhark
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
- uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27

- uses: cachix/cachix-action@v12
- uses: cachix/cachix-action@v15
with:
name: futhark
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
Expand Down Expand Up @@ -145,7 +145,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27

- uses: actions/cache@v3
name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
Expand All @@ -167,7 +167,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27

- name: Style check
run: nix-shell --pure --run "black --check ."
Expand Down Expand Up @@ -301,7 +301,7 @@ jobs:
sudo apt-get install -y python3-jsonschema
- name: Install Nix
uses: cachix/install-nix-action@v20
uses: cachix/install-nix-action@v27

- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -372,7 +372,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y opencl-headers oclgrind virtualenv
sudo apt-get install -y opencl-headers oclgrind
- uses: actions/download-artifact@v3
with:
name: futhark-nightly-linux-x86_64.tar.xz
Expand All @@ -383,9 +383,9 @@ jobs:
echo "$HOME/.local/bin" >> $GITHUB_PATH
- run: |
set -e
virtualenv virtualenv
python -m venv virtualenv
source virtualenv/bin/activate
pip install numpy pyopencl jsonschema
pip install 'numpy<2.0.0' pyopencl jsonschema
futhark test tests -c --no-terminal --backend=pyopencl --exclude=compiled --cache-extension=cache --pass-option=--build-option=-O0 --runner=tools/oclgrindrunner.sh
test-opencl:
Expand All @@ -399,7 +399,7 @@ jobs:
with:
script: |
set -e
virtualenv virtualenv
python -m venv virtualenv
source virtualenv/bin/activate
pip install jsonschema
module unload cuda
Expand All @@ -421,7 +421,7 @@ jobs:
with:
script: |
set -e
virtualenv virtualenv
python -m venv virtualenv
source virtualenv/bin/activate
pip install numpy pyopencl jsonschema
module unload cuda
Expand All @@ -440,7 +440,7 @@ jobs:
with:
script: |
set -e
virtualenv virtualenv
python -m venv virtualenv
source virtualenv/bin/activate
pip install jsonschema
module unload cuda
Expand All @@ -461,7 +461,7 @@ jobs:
- uses: actions/checkout@v3

- run: |
virtualenv virtualenv
python -m venv virtualenv
source virtualenv/bin/activate
pip install jsonschema
Expand Down Expand Up @@ -520,7 +520,7 @@ jobs:
- uses: mymindstorm/setup-emsdk@v12
with:
version: 2.0.18
actions-cache-folder: 'emsdk-cache'
actions-cache-folder: 'emsdk-mc-cache'

- uses: actions/[email protected]
with:
Expand Down
60 changes: 56 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,77 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [0.26.0]

* Faster device-to-device copies on CUDA.

* "More correctly" detect L2 cache size for OpenCL backend on AMD GPUs.

### Added

* Better error message when in-place updates fail at runtime due to a
shape mismatch.

### Removed

### Changed

### Fixed

* `#[unroll]` on an outer loop now no longer causes unrolling of all
loops nested inside the loop body.

* Obscure issue related to replications of constants in complex
intrablock kernels.

* Interpreter no longer crashes on attributes in patterns.

## [0.25.19]

### Added

* The compiler now does slightly less aggressive inlining. Use the
`#[inline]` attribute if you want to force inlining of some
function.

* Arrays of opaque types now support indexing through the C API.
Arrays of records can also be constructed. (#2082)

### Fixed

* The `opencl` backend now always passes
`-cl-fp32-correctly-rounded-divide-sqrt` to the kernel compiler, in
order to match CUDA and HIP behaviour.

## [0.25.18]

### Added

* New prelude function: `rep`, an implicit form of `replicate`.

* Improved handling of large monomorphic single-dimensional array
literals (#2160).

### Fixed

* `futhark repl` no longer asks for confirmation on EOF.

* Obscure oversight related to abstract size-lifted types (#2120).

* Accidential exponential-time algorithm in layout optimisation for
multicore backends (#2151).

## [0.25.17]

* Faster device-to-device copies on CUDA.

* "More correctly" detect L2 cache size for OpenCL backend on AMD GPUs.

### Fixed

* Handling of `..` in `import` paths (again).

* Detection of impossible loop parameter sizes (#2144).

* Rare case where GPU histograms would use slightly too much shared
memory and fail at run-time.

* Rare crash in layout optimisation.

## [0.25.16]

### Added
Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages: futhark.cabal
index-state: 2024-05-22T04:42:44Z
index-state: 2024-07-22T12:41:48Z

package futhark
ghc-options: -j -fwrite-ide-info -hiedir=.hie
Expand Down
101 changes: 91 additions & 10 deletions docs/c-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Context creation is parameterised by a configuration object. Any
changes to the configuration must be made *before* calling
:c:func:`futhark_context_new`. A configuration object must not be
freed before any context objects for which it is used. The same
configuration may *not* be used for multiple concurrent contexts.
configuration must *not* be used for multiple concurrent contexts.
Configuration objects are cheap to create and destroy.

.. c:struct:: futhark_context_config
Expand Down Expand Up @@ -162,7 +162,7 @@ Context
:c:func:`futhark_context_get_error`, which will return non-``NULL``
if initialisation failed. If initialisation has failed, then you
still need to call :c:func:`futhark_context_free` to release
resources used for the context object, but you may not use the
resources used for the context object, but you must not use the
context object for anything else.
.. c:function:: void futhark_context_free(struct futhark_context *ctx)
Expand Down Expand Up @@ -230,6 +230,11 @@ because C does not have a standard ``half`` type. This integer
contains the bitwise representation of the ``f16`` value in the IEEE
754 binary16 format.
.. _array-values:
Arrays of Primitive Values
~~~~~~~~~~~~~~~~~~~~~~~~~~
For each distinct array type of primitives (ignoring sizes), an opaque
C struct is defined. Arrays of ``f16`` are presented as containing
``uint16_t`` elements. For types that do not map cleanly to C,
Expand Down Expand Up @@ -272,7 +277,7 @@ will not result in a double free.
.. c:function:: int futhark_free_i32_1d(struct futhark_context *ctx, struct futhark_i32_1d *arr)
Free the value. In practice, this merely decrements the reference
count by one. The value (or at least this reference) may not be
count by one. The value (or at least this reference) must not be
used again after this function returns.
.. c:function:: int futhark_values_i32_1d(struct futhark_context *ctx, struct futhark_i32_1d *arr, int32_t *data)
Expand All @@ -282,6 +287,14 @@ will not result in a double free.
space to store the full array. Multi-dimensional arrays are
written in row-major form.
.. c:function:: int futhark_index_i32_1d(struct futhark_context *ctx, int32_t *out, struct futhark_i32_1d *arr, int64_t i0);
Asynchronously copy a single element from the array and store it in
``*out``. Returns a nonzero value if the index is out of bounds.
**Note:** if you need to read many elements, it is much faster to
retrieve the entire array with the ``values`` function,
particularly when using a GPU backend.
.. c:function:: const int64_t *futhark_shape_i32_1d(struct futhark_context *ctx, struct futhark_i32_1d *arr)
Return a pointer to the shape of the array, with one element per
Expand Down Expand Up @@ -326,7 +339,7 @@ deserialisation, see :c:func:`futhark_restore_opaque_foo`).
.. c:function:: int futhark_free_opaque_foo(struct futhark_context *ctx, struct futhark_opaque_foo *obj)
Free the value. In practice, this merely decrements the reference
count by one. The value (or at least this reference) may not be
count by one. The value (or at least this reference) must not be
used again after this function returns.
.. c:function:: int futhark_store_opaque_foo(struct futhark_context *ctx, const struct futhark_opaque_foo *obj, void **p, size_t *n)
Expand Down Expand Up @@ -400,11 +413,13 @@ types.
.. c:function:: int futhark_new_opaque_t(struct futhark_context *ctx, struct futhark_opaque_t **out, const struct futhark_opaque_t2 *bar, const struct futhark_opaque_t1 *foo);
Construct a record in ``*out`` which has the given values for the
``bar`` and ``foo`` fields. The parameters are the
fields in alphabetic order. Tuple fields are named ``vX`` where
``X`` is an integer. The resulting record *aliases* the values
provided for ``bar`` and ``foo``, but has its own lifetime, and all
values must be individually freed when they are no longer needed.
``bar`` and ``foo`` fields. The parameters are the fields in
alphabetic order. As a special case, if the record is a tuple
(i.e., has numeric fields), the parameters are ordered numerically.
Tuple fields are named ``vX`` where ``X`` is an integer. The
resulting record *aliases* the values provided for ``bar`` and
``foo``, but has its own lifetime, and all values must be
individually freed when they are no longer needed.
.. c:function:: int futhark_project_opaque_t_bar(struct futhark_context *ctx, struct futhark_opaque_t2 **out, const struct futhark_opaque_t *obj);
Expand Down Expand Up @@ -472,6 +487,55 @@ defined. The following assume ``t`` is defined as ``type t = #foo
**Precondition:** ``t`` must be an instance of the ``foo`` variant,
which can be determined with :c:func:`futhark_variant_opaque_t`.
.. _arrays_of_opaques:
Arrays of Non-Primitive Values
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An array that contains a non-primitive type is considered an opaque
value. However, it also supports a subset of the API documented in
:ref:`array-values`.
For an opaque array type ``[]t``, the following functions are always
generated (assuming the generated C type is ``arr_t``):
.. c:function:: int futhark_index_opaque_arr_t(struct futhark_context *ctx, struct futhark_opaque_t **out, struct futhark_opaque_arr_t *arr, int64_t i0);
Asynchronously copy a single element from the array and store it in
``*out``. Returns a nonzero value if the index is out of bounds.
.. c:function:: const int64_t *futhark_shape_opaque_arr_t(struct futhark_context *ctx, struct futhark_opaque_arr_t *arr);
Return a pointer to the shape of the array, with one element per
dimension. The lifetime of the shape is the same as ``arr``, and
must *not* be manually freed. Assuming ``arr`` is a valid object,
this function cannot fail.
Additionally, if the element type is a record (or equivalently a
tuple), for example if the array type is ``[](f32,f32)``, the
following functions are also available:
.. c:function:: int futhark_zip_opaque_arr1d_tup2_f32_f32(struct futhark_context *ctx, struct futhark_opaque_arr1d_tup2_f32_f32 **out, const struct futhark_f32_1d *f_0, const struct futhark_f32_1d *f_1);
Construct an array of records from arrays of the component values.
This is analogous to ``zip`` in the source language. The provided
arrays must have compatible shapes, and the function returns
nonzero if they do not.
**Note:** This is a cheap operation, as it does not copy array
elements.
**Note:** The resulting array aliases the original arrays.
.. c:function:: int futhark_project_opaque_arr1d_tup2_f32_f32_0(struct futhark_context *ctx, struct futhark_f32_1d **out, const struct futhark_opaque_arr1d_tup2_f32_f32 *obj);
Retrieve an array of all the ``.0`` fields of the array elements. A
similar function is provided for each field.
**Note:** This is a cheap operation, as it does not copy array
elements.
**Note:** The resulting array aliases the original array.
Entry points
------------
Expand Down Expand Up @@ -736,7 +800,7 @@ the compiled Futhark program. Specifically, the manifest contains:
functions are as documented above. The following operations are
listed:
* For arrays: ``free``, ``shape``, ``values``, ``new``.
* For arrays: ``free``, ``shape``, ``values``, ``new``, ``index``.
* For opaques: ``free``, ``store``, ``restore``.
Expand All @@ -749,6 +813,23 @@ the compiled Futhark program. Specifically, the manifest contains:
* The name of the C *new* function for creating a record from
field values.
* For opaques that are actually arrays of records:
* The element type and rank.
* The operations ``index``, ``shape``, ``zip``.
* The fields, which will be the fields of the element type, but
with the dimensions preprended. These are the types of the
arrays that should be passed to the ``zip`` function.
* For other opaques that are actually arrays:
* The element type and rank.
* The operations ``index`` and ``shape``.
Manifests are defined by the following JSON Schema:
.. include:: manifest.schema.json
Expand Down
Loading

0 comments on commit 312ba0b

Please sign in to comment.