Skip to content

Commit d63678d

Browse files
AlbertoParravicinigwdidonatolnghrdntcr
authored
Grcuda 61 cleanup for release 1 (#19)
* adding changelog, removed unused thread manager * fixed install.sh, now using env variables to retrieve the absolute path to grcuda.jar * added curl to install script * added license to demo * removed unused cuda code; added license to benchmarks * added license to tests * added license to functions and libraries * fixed removal of thread manager breaking build * added more updated licenses * added license to runtime files * Updated changelog * fixed typo * added grcuda-data info to readme * udpated tracking of grcuda-data * temporarily removed submodule grcuda-data * readded grcuda-data submodule * tracking master? * updated grcuda-data tracking * Added the possibility to send execution times to the frontend * Display execution times in race mode * clarified streamattach in changelog Co-authored-by: Guido Walter Di Donato <[email protected]> Co-authored-by: Francesco Sgherzi <[email protected]>
1 parent 311ea3e commit d63678d

File tree

265 files changed

+5117
-3286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+5117
-3286
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "grcuda-data"]
22
path = grcuda-data
3-
url = https://github.com/AlbertoParravicini/grcuda-data.git
3+
url = https://github.com/AlbertoParravicini/grcuda-data.git
44
branch = master

CHANGELOG.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# 2021-09-30, Release 1
2+
3+
## API Changes
4+
5+
* Added option to specify arguments in NFI kernel signatures as `const`
6+
* The effect is the same as marking them as `in` in the NIDL syntax
7+
* It is not strictly required to have the corresponding arguments in the CUDA kernel marked as `const`, although that's recommended
8+
* Marking arguments as `const` or `in` enables the async scheduler to overlap kernels that use the same read-only arguments
9+
10+
## New asynchronous scheduler
11+
12+
* Added a new asynchronous scheduler for GrCUDA, enable it with `--experimental-options --grcuda.ExecutionPolicy=async`
13+
* With this scheduler, GPU kernels are executed asynchronously. Once they are launched, the host execution resumes immediately
14+
* The computation is synchronized (i.e. the host thread is stalled and waits for the kernel to finish) only once GPU data are accessed by the host thread
15+
* Execution of multiple kernels (operating on different data, e.g. distinct DeviceArrays) is overlapped using different streams
16+
* Data transfer and execution (on different data, e.g. distinct DeviceArrays) is overlapped using different streams
17+
* The scheduler supports different options, see `README.md` for the full list
18+
* It is the scheduler presented in "DAG-based Scheduling with Resource Sharing for Multi-task Applications in a Polyglot GPU Runtime" (IPDPS 2021)
19+
20+
* Enabled partial support for cuBLAS and cuML in the aync scheduler
21+
* **Known limitation:** functions in these libraries work with the async scheduler, although they still run on the default stream (i.e. they are not asynchronous)
22+
* They do benefit from prefetching
23+
* Set TensorRT support to experimental
24+
* TensorRT is currently not supported on CUDA 11.4, making it impossible to use along a recent version of cuML
25+
* **Known limitation:** due to this incompatibility, TensorRT is currently not available on the async scheduler
26+
27+
## New features
28+
29+
* Added generic AbstractArray data structure, which is extended by DeviceArray, MultiDimDeviceArray, MultiDimDeviceArrayView, and provides high-level array interfaces
30+
* Added API for prefetching
31+
* If enabled (and using a GPU with architecture newer or equal than Pascal), it prefetches data to the GPU before executing a kernel, instead of relying on page-faults for data transfer. It can greatly improve performance
32+
* Added API for stream attachment
33+
* Always enabled in GPUs with with architecture older than Pascal, and the async scheduler is active. With the sync scheduler, it can be manually enabled
34+
* It restricts the visibility of GPU data to the specified stream
35+
* In architectures newer or equal than Pascal it can provide a small performance benefit
36+
* Added `copyTo/copyFrom` functions on generic arrays (Truffle interoperable objects that expose the array API)
37+
* Internally, the copy is implemented as a for loop, instead of using CUDA's `memcpy`
38+
* It is still faster than copying using loops in the host languages, in many cases, and especially if host code is not JIT-ted
39+
* It is also used for copying data to/from DeviceArrays with column-major layout, as `memcpy` cannot copy non-contiguous data
40+
41+
## Demos, benchmarks and code samples
42+
43+
* Added demo used at SeptembeRSE 2021 (`demos/image_pipeline_local` and `demos/image_pipeline_web`)
44+
* It shows an image processing pipeline that applies a retro look to images. We have a local version and a web version that displays results a in web page
45+
* Added benchmark suite written in Graalpython, used in "DAG-based Scheduling with Resource Sharing for Multi-task Applications in a Polyglot GPU Runtime" (IPDPS 2021)
46+
* It is a collection of complex multi-kernel benchmarks meant to show the benefits of asynchronous scheduling.
47+
48+
## Miscellaneosus
49+
50+
* Added dependency to `grcuda-data` submodule, used to store data, results and plots used in publications and demos.
51+
* Updated name "grCUDA" to "GrCUDA". It looks better, doesn't it?
52+
* Added support for Java 11 along with Java 8
53+
* Added option to specify the location of cuBLAS and cuML with environment variables (`LIBCUBLAS_DIR` and `LIBCUML_DIR`)
54+
* Refactored package hierarchy to reflect changes to current GrCUDA (e.g. `gpu -> runtime`)
55+
* Added basic support for TruffleLogger
56+
* Removed a number of existing deprecation warnings
57+
* Added around 800 unit tests, with support for extensive parametrized testing and GPU mocking
58+
* Updated documentation
59+
* Bumped GraalVM version to 21.2
60+
* Added scripts to setup a new machine from scratch (e.g. on OCI), plus other OCI-specific utility scripts (see `oci_setup/`)
61+
* Added documentation to setup IntelliJ Idea for GrCUDA development
62+
* Added documentation about Python benchmark suite
63+
* Added documentation on asynchronous scheduler options

LICENSE

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
1+
Copyright (c) 2019, 2020, NVIDIA CORPORATION. All rights reserved.
2+
Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
3+
Copyright (c) 2020, 2021, NECSTLab, Politecnico di Milano. All rights reserved.
24

35
Redistribution and use in source and binary forms, with or without
46
modification, are permitted provided that the following conditions
@@ -11,6 +13,12 @@ are met:
1113
* Neither the name of NVIDIA CORPORATION nor the names of its
1214
contributors may be used to endorse or promote products derived
1315
from this software without specific prior written permission.
16+
* Neither the name of NECSTLab nor the names of its
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
* Neither the name of Politecnico di Milano nor the names of its
20+
contributors may be used to endorse or promote products derived
21+
from this software without specific prior written permission.
1422

1523
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
1624
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,15 @@ graalpython -m ginstall install numpy;
282282

283283
4. **Run GrCUDA Unit tests** using
284284

285-
```bash
285+
```
286286
mx unittest com.nvidia
287287
# To run a specific test, you can use
288288
mx unittest com.nvidia.grcuda.test.BuildKernelTest#testBuildKernelwithNFILegacytSignature
289289
```
290290

291+
5. **Setup the grcuda-data sumbodule**
292+
The `grcuda-data` repository is used as a `git` submodule to store data, results, and plots for demos, benchmarks, and publications. You will need this submodule to run the full benchmark suite, and some of the demos. To setup the submodule, follow this [`README`](https://github.com/AlbertoParravicini/grcuda-data/tree/master).
293+
291294
### Setup your IDE
292295

293296
To develop GrCUDA, you will greatly benefit from having an IDE that allows jumping between symbols and debugging individual tests.
@@ -296,6 +299,7 @@ Here, we explain how to setup IntelliJ Idea.
296299
1. `mx ideinit` from `$GRCUDA_HOME`, to setup the IDE
297300
2. Open Idea and select *"open project"*, then open GrCUDA
298301
3. See this [guide](https://github.com/graalvm/mx/blob/master/docs/IDE.md) to configure the syntax checker
302+
* `File -> Settings -> Plugins -> Marketplace -> Search "Eclipse Code Formatter" and install it`
299303
4. In IntelliJ Idea, install the Python plugin with `Settings -> Plugin -> Search "Python"`, then do `Project Structure -> SDKs -> Create a new Python 3.8 Virtual Environment`, it is used by `mx`
300304
5. Select the right JVM. It should select automatically your `$JAVA_HOME`. Othewise, `Project Structures -> Modules -> Set the Module SDK (under Dependencies)` of `mx` and submodules to your Java SDK (e.g. `11`). You can pick either the `labsjdk` or `graalvm`.
301305
* This is also given by the `configure` option if you try to build the project in IntelliJ Idea before setting these options. Set your project Java SDK (e.g. `11`) for those missing modules
@@ -304,16 +308,18 @@ Here, we explain how to setup IntelliJ Idea.
304308

305309
a. For those packages (look at the log to find them), manually specify a more recent SDK (e.g. `11`) as you did in step above. If you get errors of missing symbols, follow IntelliJ's hints and export the requested packages
306310

307-
b. Remove the exports. `File -> Settings -> Build ... -> Java Compiler`, then remove all the `--export` flags.
311+
b. Remove the exports. `File -> Settings -> Build ... -> Compiler -> Java Compiler`, then remove all the `--export` flags.
308312
7. To run tests:
309313

310314
a. Go to `Run (top bar) -> Edit Configurations -> Edit configuration templates -> Junit`
311315

312316
b. (Not always necessary) By default, Idea should use your `env`. If not, make sure to have the same. Update the `PATH` variable so that it can find `nvcc`, and export `$GRAAL_HOME`. See `setup_machine_from_scratch.sh` to find all the environment variables.
313317

314-
c. Modify the template Junit test configuration adding `-Djava.library.path="$GRAAL_HOME/lib` (in Java 11) to the VM options to find `trufflenfi`
318+
c. Modify the template Junit test configuration adding `-Djava.library.path="$GRAAL_HOME/lib"` (in Java 11) to the VM options to find `trufflenfi`
315319

316320
d. In IntelliJ Idea, `Run -> Edit Configurations`. Create a new JUnit configuration set to `All in package` with `com.nvidia.grcuda` as module and `com.nvidia.grcuda.test` selected below. Add `-Djava.library.path="$GRAAL_HOME/lib"` (or your version of GraalVM) if it's not already in VM options. Specify the SDK by setting the GraalVM JRE in e.g. `$GRAAL_HOME`, if not specified already.
321+
322+
e. If you change something in GrCUDA, rebuild it with `./install.sh` before running tests. That's because tests that use the GPU load the `.jar` in `$GRAAL_HOME`, which is updated by `./install.sh`
317323

318324
## Execute performance tests using Graalpython
319325

demos/image_pipeline_local/array_copy_performance_test.js

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// Copyright (c) 2021, NECSTLab, Politecnico di Milano. All rights reserved.
2+
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// * Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
// * Neither the name of NECSTLab nor the names of its
12+
// contributors may be used to endorse or promote products derived
13+
// from this software without specific prior written permission.
14+
// * Neither the name of Politecnico di Milano nor the names of its
15+
// contributors may be used to endorse or promote products derived
16+
// from this software without specific prior written permission.
17+
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
130
const System = Java.type("java.lang.System");
231
const cu = Polyglot.eval('grcuda', 'CU')
332
const { assert } = require("console");

demos/image_pipeline_local/cuda/image_pipeline.cu

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// Copyright (c) 2021, NECSTLab, Politecnico di Milano. All rights reserved.
2+
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// * Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
// * Neither the name of NECSTLab nor the names of its
12+
// contributors may be used to endorse or promote products derived
13+
// from this software without specific prior written permission.
14+
// * Neither the name of Politecnico di Milano nor the names of its
15+
// contributors may be used to endorse or promote products derived
16+
// from this software without specific prior written permission.
17+
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
130
#include "image_pipeline.cuh"
231

332
//////////////////////////////

demos/image_pipeline_local/cuda/image_pipeline.cuh

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// Copyright (c) 2021, NECSTLab, Politecnico di Milano. All rights reserved.
2+
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// * Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
// * Neither the name of NECSTLab nor the names of its
12+
// contributors may be used to endorse or promote products derived
13+
// from this software without specific prior written permission.
14+
// * Neither the name of Politecnico di Milano nor the names of its
15+
// contributors may be used to endorse or promote products derived
16+
// from this software without specific prior written permission.
17+
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
130
#pragma once
231
#include <chrono>
332
#include <iostream>

demos/image_pipeline_local/cuda/main.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
// Copyright (c) 2021, NECSTLab, Politecnico di Milano. All rights reserved.
2+
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// * Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
// * Neither the name of NECSTLab nor the names of its
12+
// contributors may be used to endorse or promote products derived
13+
// from this software without specific prior written permission.
14+
// * Neither the name of Politecnico di Milano nor the names of its
15+
// contributors may be used to endorse or promote products derived
16+
// from this software without specific prior written permission.
17+
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
130
#include <string>
231
#include <iostream>
332
#include <ctime> // For time()

demos/image_pipeline_local/cuda/opencv_interface.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
// Copyright (c) 2021, NECSTLab, Politecnico di Milano. All rights reserved.
2+
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions
5+
// are met:
6+
// * Redistributions of source code must retain the above copyright
7+
// notice, this list of conditions and the following disclaimer.
8+
// * Redistributions in binary form must reproduce the above copyright
9+
// notice, this list of conditions and the following disclaimer in the
10+
// documentation and/or other materials provided with the distribution.
11+
// * Neither the name of NECSTLab nor the names of its
12+
// contributors may be used to endorse or promote products derived
13+
// from this software without specific prior written permission.
14+
// * Neither the name of Politecnico di Milano nor the names of its
15+
// contributors may be used to endorse or promote products derived
16+
// from this software without specific prior written permission.
17+
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
19+
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
129

230
#include "opencv_interface.hpp"
331

0 commit comments

Comments
 (0)