Skip to content

Commit e1c1e06

Browse files
authored
Merge pull request #55 from OpenVADL/feature/run-benchmarks-on-master
ci: Setup benchmarking lcb
2 parents 68a4ed0 + c0d6799 commit e1c1e06

File tree

4 files changed

+121
-12
lines changed

4 files changed

+121
-12
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: benchmark LCB
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
checks: write
12+
13+
jobs:
14+
build:
15+
runs-on: self-hosted
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: graalvm/setup-graalvm@v1
19+
with:
20+
java-version: '21'
21+
distribution: 'graalvm'
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
- name: Build
24+
run: ./gradlew assemble testClasses -PFailOnWarnings
25+
test:
26+
needs: build
27+
runs-on: self-hosted-x64
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: graalvm/setup-graalvm@v1
31+
with:
32+
java-version: '21'
33+
distribution: 'graalvm'
34+
github-token: ${{ secrets.GITHUB_TOKEN }}
35+
cache: 'gradle'
36+
- name: Run tests
37+
run: |
38+
./gradlew test --tests EmbenchBenchmarkNumberOfExecutedInstructionsSpikeRiscv32SimulationTest -DincludeTags=BenchmarkTest
39+
env:
40+
isCI: true
41+
GATE_KEEPER_EMBENCH_NUMBER_EXECUTED_INSTRUCTIONS: true
42+
EMBENCH_BENCHMARK_RESULT_HOST_PATH: ${{ github.workspace }}/riscv32.csv
43+
EMBENCH_BENCHMARK_RESULT_GUEST_PATH: /src/embench/result/executed_instructions_relative.csv
44+
- name: Read
45+
run: cat ${{ github.workspace }}/riscv32.csv
46+
- name: Update csv
47+
run: awk -v hash="${{ github.sha }}" -v date="$(date --rfc-3339=date)" -F',' '{print $0 "," hash "," date}' ${{ github.workspace }}/riscv32.csv > ${{ github.workspace }}/${{ github.sha }}.csv
48+
- name: Read Updated
49+
run: cat ${{ github.workspace }}/${{ github.sha }}.csv
50+
- name: Pushes csv
51+
uses: dmnemec/copy_file_to_another_repo_action@main
52+
env:
53+
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN_RESSELPARK }}
54+
with:
55+
source_file: ${{ github.workspace }}/${{ github.sha }}.csv
56+
destination_repo: 'openVADL/resselpark'
57+
destination_branch: 'master'
58+
destination_folder: 'data/lcb/riscv32'
59+
user_email: 'ci@openvadl.org'
60+
user_name: 'ci'
61+
commit_message: 'data: Pushed LCB data'

.run/Benchmark Number Executed Instructions RV32IM.run.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
</map>
88
</option>
99
<option name="executionName" />
10-
<option name="externalProjectPath" value="$PROJECT_DIR$/.." />
10+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
1111
<option name="externalSystemIdString" value="GRADLE" />
12-
<option name="scriptParameters" value="-PopenVadl.tests=EmbenchBenchmarkNumberOfExecutedInstructionsSpikeRiscv32SimulationTest -PnoXtendCompile -i" />
12+
<option name="scriptParameters" value="-i" />
1313
<option name="taskDescriptions">
1414
<list />
1515
</option>
1616
<option name="taskNames">
1717
<list>
1818
<option value="test" />
1919
<option value="--tests" />
20-
<option value="at.ac.tuwien.complang.vadl.tests.OpenVADLSpecificTests" />
20+
<option value="vadl.lcb.riscv.EmbenchBenchmarkNumberOfExecutedInstructionsSpikeRiscv32SimulationTest" />
2121
</list>
2222
</option>
2323
<option name="vmOptions" />

vadl/test/vadl/DockerExecutionTest.java

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.nio.file.Paths;
3333
import java.time.Duration;
3434
import java.util.ArrayList;
35+
import java.util.Collections;
3536
import java.util.List;
3637
import java.util.Map;
3738
import java.util.Objects;
@@ -201,18 +202,21 @@ protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
201202
* It will write the given {@code content} into a temporary file. The
202203
* temporary file requires a {@code prefix} and {@code suffix}.
203204
* Copies the data from {@code copyMappings}. Additionally, it will
204-
* set environment variables based on {@code environmentMappings}.
205+
* set environment variables based on {@code environmentMappings}. The {@code copyFromContainerToHost}
206+
* can be used to define mappings between host and guest system.
205207
*
206-
* @param image is the docker image for the {@link GenericContainer}.
207-
* @param copyMappings is a list where each {@link Pair} indicates what should be copied
208-
* from the host to the container.
209-
* @param environmentMappings is a list where each entry defines an environment variable which
210-
* will be set in the container.
211-
* @param cmd is the command which is executed.
208+
* @param image is the docker image for the {@link GenericContainer}.
209+
* @param copyMappings is a list where each {@link Pair} indicates what should be copied
210+
* from the host to the container.
211+
* @param environmentMappings is a list where each entry defines an environment variable which
212+
* will be set in the container.
213+
* @param copyFromContainerToHost copies from guest to host.
214+
* @param cmd is the command which is executed.
212215
*/
213216
protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
214217
List<Pair<Path, String>> copyMappings,
215218
Map<String, String> environmentMappings,
219+
List<Pair<String, String>> copyFromContainerToHost,
216220
String cmd) {
217221
runContainer(image, (container) -> {
218222
for (var mapping : copyMappings) {
@@ -233,9 +237,37 @@ protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
233237

234238
return container;
235239
}, (container) -> {
240+
for (var mapping : copyFromContainerToHost) {
241+
container.copyFileFromContainer(mapping.left(), mapping.right());
242+
}
236243
});
237244
}
238245

246+
/**
247+
* Starts a container and checks the status code for the exited container.
248+
* It will write the given {@code content} into a temporary file. The
249+
* temporary file requires a {@code prefix} and {@code suffix}.
250+
* Copies the data from {@code copyMappings}. Additionally, it will
251+
* set environment variables based on {@code environmentMappings}.
252+
*
253+
* @param image is the docker image for the {@link GenericContainer}.
254+
* @param copyMappings is a list where each {@link Pair} indicates what should be copied
255+
* from the host to the container.
256+
* @param environmentMappings is a list where each entry defines an environment variable which
257+
* will be set in the container.
258+
* @param cmd is the command which is executed.
259+
*/
260+
protected void runContainerAndCopyInputIntoContainer(ImageFromDockerfile image,
261+
List<Pair<Path, String>> copyMappings,
262+
Map<String, String> environmentMappings,
263+
String cmd) {
264+
runContainerAndCopyInputIntoContainer(image,
265+
copyMappings,
266+
environmentMappings,
267+
Collections.emptyList(),
268+
cmd);
269+
}
270+
239271
/**
240272
* Starts a container and checks the status code for the exited container.
241273
* It will assert that the status code is zero. If the check takes longer

vadl/test/vadl/lcb/riscv/EmbenchBenchmarkNumberOfExecutedInstructionsSpikeRiscv32SimulationTest.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@
2323
import java.nio.file.Files;
2424
import java.nio.file.Path;
2525
import java.nio.file.Paths;
26+
import java.util.Collections;
2627
import java.util.List;
2728
import java.util.Map;
29+
import org.junit.jupiter.api.Tag;
2830
import org.junit.jupiter.api.Test;
2931
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
3032
import org.testcontainers.images.builder.ImageFromDockerfile;
3133
import org.testcontainers.shaded.org.apache.commons.io.FileUtils;
3234
import vadl.configuration.LcbConfiguration;
33-
import vadl.gcb.valuetypes.ProcessorName;
3435
import vadl.gcb.valuetypes.TargetName;
3536
import vadl.lcb.AbstractLcbTest;
3637
import vadl.pass.exception.DuplicatedPassKeyException;
3738
import vadl.utils.Pair;
3839

40+
@Tag("benchmarkTest")
3941
public class EmbenchBenchmarkNumberOfExecutedInstructionsSpikeRiscv32SimulationTest
4042
extends AbstractLcbTest {
4143

@@ -71,17 +73,31 @@ void testEmbench() throws IOException, DuplicatedPassKeyException {
7173
}
7274

7375
var redisCache = getRunningRedisCache();
74-
var image = redisCache.setupEnv(new ImageFromDockerfile("tc_embench_spike_riscv32")
76+
var image = redisCache.setupEnv(new ImageFromDockerfile("tc_embench_spike_riscv32", false)
7577
.withDockerfile(Paths.get(configuration.outputPath() + "/lcb/Dockerfile"))
7678
.withBuildArg("TARGET", target)
7779
.withBuildArg("UPSTREAM_BUILD_TARGET", upstreamBuildTarget));
7880

81+
var volumeMapping = volumeMappings();
82+
7983
runContainerAndCopyInputIntoContainer(image,
8084
List.of(Pair.of(Path.of("test/resources/llvm/riscv/spike"),
8185
"/src/inputs")),
8286
Map.of(
8387
"LLVM_PARALLEL_COMPILE_JOBS", "4",
8488
"LLVM_PARALLEL_LINK_JOBS", "2"),
89+
volumeMapping,
8590
"sh /src/embench/benchmark-extras/get-number-executed-instructions-spike-clang-lcb.sh");
8691
}
92+
93+
private List<Pair<String, String>> volumeMappings() {
94+
var embenchHostOutput = System.getenv().get("EMBENCH_BENCHMARK_RESULT_HOST_PATH");
95+
var embenchGuestInput = System.getenv().get("EMBENCH_BENCHMARK_RESULT_GUEST_PATH");
96+
97+
if (embenchGuestInput != null && embenchHostOutput != null) {
98+
return List.of(Pair.of(embenchGuestInput, embenchHostOutput));
99+
}
100+
101+
return Collections.emptyList();
102+
}
87103
}

0 commit comments

Comments
 (0)