Skip to content

Commit c29cb10

Browse files
authored
[GRCUDA-hotfix] added generic install scripts + fallback configuration for java workloads (#53)
1 parent ca826df commit c29cb10

File tree

18 files changed

+375
-6
lines changed

18 files changed

+375
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ If you want to build GrCUDA yourself, instead of using an existing release, you
175175
This section contains all the steps required to setup GrCUDA if your goal is to contribute to its development, or simply hack with it.
176176
For simplicity, let's assume that your installation is done in your home directory, `~`.
177177

178-
If you are installing GrCUDA on a new machine, you can simply follow or execute `oci_setup/setup_machine_from_scratch.sh` first, and then `oci_setup/setup_graalvm.sh`.
178+
If you are installing GrCUDA on a new machine, you can simply follow or execute `scripts/oci_setup/setup_machine_from_scratch.sh` first, and then `scripts/oci_setup/setup_graalvm.sh`.
179179
Here we repeat the same steps, with additional comments.
180180
The installation process has been validated with CUDA 11.4 - 11.7 and Ubuntu 20.04.
181181
The same `oci_setup` has a number of useful scripts to configure machines on OCI and easily use GrCUDA.

projects/resources/java/grcuda-benchmark/src/test/java/it/necst/grcuda/benchmark/TestBenchmarks.java

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@ public void init() throws IOException, InterruptedException {
6868
br.readLine(); // discard "name" at the beginning of the output
6969
while((line=br.readLine())!=null){
7070
GPU g = GPU.valueOfName(line);
71-
assertNotEquals("There is no configuration file for the current GPU model, please add it and modify the GPU enum in TestBenchmarks.java",null, g);
72-
detectedGPUS.add(g);
71+
// assertNotEquals("There is no configuration file for the current GPU model, please add it and modify the GPU enum in TestBenchmarks.java",null, g);
72+
if(g == null){
73+
detectedGPUS.add(GPU.fallback_2gpu);
74+
}else{
75+
detectedGPUS.add(g);
76+
}
77+
7378
}
74-
assertEquals(1, detectedGPUS.size());
79+
// assertEquals(1, detectedGPUS.size());
7580
this.currentGPU = detectedGPUS.iterator().next();
81+
// System.out.println(this.currentGPU);
7682
}
7783

7884
@Test
@@ -131,6 +137,22 @@ public void runAll_A100_multi() throws FileNotFoundException, ClassNotFoundExcep
131137
iterateAllPossibleConfig(parsedConfig);
132138
}
133139

140+
@Test
141+
public void runAll_fallback_2gpu() throws FileNotFoundException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, JsonProcessingException {
142+
// Ensure the current GPU does not match any of the GPUs defined in the enum
143+
assumeTrue(this.currentGPU.equals(GPU.fallback_2gpu));
144+
145+
// get the configuration for the selected GPU into a Config class
146+
String CONFIG_PATH = PATH + "/config_fallback.json";
147+
Gson gson = new GsonBuilder().setPrettyPrinting().create();
148+
JsonReader reader = new JsonReader(new FileReader(CONFIG_PATH));
149+
Config parsedConfig = gson.fromJson(reader, Config.class);
150+
//System.out.println(gson.toJson(parsedConfig)); // print the current configuration
151+
152+
iterateAllPossibleConfig(parsedConfig);
153+
}
154+
155+
134156
/*
135157
This method reflects the pattern of benchmark_wrapper.py present in the python suite.
136158
*/
@@ -250,9 +272,10 @@ private Benchmark createBench(BenchmarkConfig config) throws ClassNotFoundExcept
250272

251273
enum GPU {
252274
GTX1660_SUPER("GeForce GTX 1660 SUPER"),
253-
A100("NVIDIA A100-SXM4-40GB"),
275+
A100("NVIDIA A100-SXM4-40GB"), // OCI: NVIDIA A100-SXM4-40GB / LEONARDO: NVIDIA A100-SXM-64GB
254276
V100("Tesla V100-SXM2-16GB"),
255-
GTX960("GeForce GTX 960");
277+
GTX960("GeForce GTX 960"),
278+
fallback_2gpu("null");
256279

257280
public final String name;
258281

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"num_iter": 1,
3+
"reInit": false,
4+
"randomInit": false,
5+
"cpuValidation": false,
6+
"heap_size": 470,
7+
"debug": false,
8+
"nvprof_profile": false,
9+
"num_elem": {
10+
"B1M": [
11+
160000,
12+
500000,
13+
950000
14+
],
15+
"B5M": [
16+
10000,
17+
21000,
18+
35000
19+
],
20+
"B6M": [
21+
1000,
22+
1400,
23+
1800
24+
],
25+
"B9M": [
26+
2000,
27+
4000,
28+
6000
29+
],
30+
"B11M": [
31+
2000,
32+
4000,
33+
6000
34+
]
35+
},
36+
"benchmarks": [
37+
"B1M",
38+
"B5M",
39+
"B6M",
40+
"B9M",
41+
"B11M"
42+
],
43+
"numBlocks": {
44+
"B1M": 64,
45+
"B5M": 64,
46+
"B6M": 64,
47+
"B9M": 64,
48+
"B11M": 64
49+
},
50+
"exec_policies": [
51+
"async"
52+
],
53+
"dependency_policies": [
54+
"with-const"
55+
],
56+
"new_stream_policies": [
57+
"always-new"
58+
],
59+
"parent_stream_policies": [
60+
"multigpu-disjoint"
61+
],
62+
"choose_device_policies": [
63+
"round-robin",
64+
"stream-aware",
65+
"min-transfer-size",
66+
"minmax-transfer-time"
67+
],
68+
"memory_advise": [
69+
"none"
70+
],
71+
"prefetch": [
72+
false
73+
],
74+
"stream_attach": [
75+
false
76+
],
77+
"time_computation": [
78+
false
79+
],
80+
"num_gpus": [
81+
2
82+
],
83+
"block_size1d": {
84+
"B1M": 32,
85+
"B5M": 1024,
86+
"B6M": 32,
87+
"B9M": 32,
88+
"B11M": 256
89+
},
90+
"block_size2d": {
91+
"B1M": 8,
92+
"B5M": 8,
93+
"B6M": 8,
94+
"B9M": 8,
95+
"B11M": 8
96+
}
97+
}

scripts/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Useful scripts
2+
3+
This folder contains useful scripts to build GrCUDA and run both the Java and Python.
4+
The scripts are expected, unless otherwise specified, to be run from the scripts' folder (i.e., `cd` to the folder containing the script)
5+
6+
### Generic setup
7+
8+
The scripts in this folder are intended for a generic/custom setup.
9+
The only requirements that are not automatically satisfied by the scripts are:
10+
11+
- `cuda`: a properly configured version of cuda (tested: 11.4 - 11.7 - 12.1)
12+
- `maven`: necessary to run the Java workloads
13+
14+
The installation proceeds by modifying accordingly `env.sh`, and then running `bash generic_setup/setup.sh` and `bash generic_setup/install.sh`.
15+
16+
The file `env.sh` contains the env variables that needs to be properly set to build and run GrCUDA.
17+
18+
19+
### OCI setup
20+
This folder contains the scripts necessary for a full install of GrCUDA on OCI resources as detailed by the outermost README of this repository.
21+
22+
### run_local
23+
The scripts within this folder are used to run the java workloads on a simple local multi-GPU machine.
24+
The file `env.sh` contains the env variables that needs to be properly set to build and run GrCUDA.
25+
26+
### run_slurm
27+
The scripts within this folder are used to run the python and java workloads within a slurm setup. The file `env.sh` contains the env variables that needs to be properly set to build and run GrCUDA.

scripts/generic_setup/env.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
## make sure cuda is properly loaded/installed, e.g.:
4+
# module load cuda/12.1
5+
6+
## (java workloads) maven installed/configured, e.g.:
7+
# module load maven/3.8.4
8+
9+
## setup env
10+
export INSTALL_DIR=$HOME/cf25_grcuda ## modify as necessary
11+
mkdir -p $INSTALL_DIR
12+
13+
export LABSJDK_HOME=$INSTALL_DIR/labsjdk-ce-11.0.15-jvmci-22.1-b01
14+
export JAVA_HOME=$LABSJDK_HOME
15+
export GRCUDA_HOME=$INSTALL_DIR/grcuda
16+
export GRAAL_HOME=$INSTALL_DIR/graalvm-ce-java11-22.1.0
17+
18+
export PATH=$INSTALL_DIR/mx:$PATH
19+
export PATH=$GRAAL_HOME/bin:$PATH
20+
export PATH=$JAVA_HOME/bin:$PATH

scripts/generic_setup/install.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
source env.sh
3+
4+
# build needs to be perfomed with labsjdk
5+
export JAVA_HOME=$LABSJDK_HOME
6+
mx build;
7+
8+
# Install (moving the jar to the languages folder of graalvm)
9+
mkdir -p $GRAAL_HOME/languages/grcuda;
10+
cp $GRCUDA_HOME/mxbuild/dists/grcuda.jar $GRAAL_HOME/languages/grcuda/.;
11+
12+
13+
# (java workloads) enable running them in offline-mode (e.g, for compute nodes of a cluster)
14+
export JAVA_HOME=$GRAAL_HOME
15+
cd $GRCUDA_HOME/projects/resources/java/grcuda-benchmark
16+
mvn clean
17+
mvn dependency:get -Dartifact=org.apache.maven.surefire:surefire-junit4:2.22.1 -Dtransitive=true
18+
mvn dependency:resolve-plugins
19+
mvn dependency:go-offline
20+
mvn test-compile
21+
mvn surefire:test -DskipTests

scripts/generic_setup/setup.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
source env.sh
3+
4+
### GrCUDA
5+
# cd $INSTALL_DIR
6+
# git clone https://github.com/necst/grcuda.git
7+
8+
### GRAALVM
9+
cd $INSTALL_DIR
10+
wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.1.0/graalvm-ce-java11-linux-amd64-22.1.0.tar.gz
11+
tar xfz graalvm-ce-java11-linux-amd64-22.1.0.tar.gz
12+
rm graalvm-ce-java11-linux-amd64-22.1.0.tar.gz
13+
14+
### LABSJDK (to build from source)
15+
cd $INSTALL_DIR
16+
wget https://github.com/graalvm/labs-openjdk-11/releases/download/jvmci-22.1-b01/labsjdk-ce-11.0.15+2-jvmci-22.1-b01-linux-amd64.tar.gz
17+
tar xfz labsjdk-ce-11.0.15+2-jvmci-22.1-b01-linux-amd64.tar.gz
18+
rm labsjdk-ce-11.0.15+2-jvmci-22.1-b01-linux-amd64.tar.gz
19+
20+
### MX
21+
cd $INSTALL_DIR
22+
git clone https://github.com/graalvm/mx.git
23+
cd $INSTALL_DIR/mx
24+
git checkout 722b86b8ef87fbb297f7e33ee6014bbbd3f4a3a8
25+
26+
### GRAAL (to develop)
27+
cd $INSTALL_DIR
28+
git clone https://github.com/oracle/graal.git
29+
cd $INSTALL_DIR/graal
30+
git checkout 84541b16ae8a8726a0e7d76c7179d94a57ed84ee
31+
32+
## install the necessary components of graalvm
33+
gu available
34+
gu install native-image
35+
gu install llvm-toolchain
36+
gu install python
37+
gu rebuild-images polyglot
38+
39+
### (python benchmarks) create a graalpython env
40+
graalpython -m venv $INSTALL_DIR/graalpython_venv
41+
source $INSTALL_DIR/graalpython_venv/bin/activate
42+
graalpython -m ginstall install setuptools;
43+
graalpython -m ginstall install Cython;
44+
graalpython -m ginstall install numpy;
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)