Skip to content

Commit 09ea3bc

Browse files
author
Ben Wooding
committed
GPU working - via Sorted Verification/Synthesis
1 parent 9d3146c commit 09ea3bc

File tree

13 files changed

+8893
-0
lines changed

13 files changed

+8893
-0
lines changed

examples/ex_GPU/GPU.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/// To use this example, run and implement the 2Drobot-RU case study.
2+
/// Then copy to this folder the files is.h5, ss.h5, minttm.h5, maxttm.h5,
3+
/// mintm.h5, maxtm.h5, minatm.h5 and maxatm.h5
4+
5+
// Run: make
6+
// ./GPU
7+
8+
9+
// Code: Ben Wooding 4 Jan 2024
10+
11+
#include <iostream>
12+
#include <vector>
13+
#include <functional>
14+
#include "../../src/IMDP.h"
15+
#include <armadillo>
16+
#include <chrono>
17+
18+
using namespace std;
19+
using namespace arma;
20+
21+
/*
22+
################################# PARAMETERS ###############################################
23+
*/
24+
25+
// Set the dimensions
26+
const int dim_x = 2;
27+
const int dim_u = 2;
28+
const int dim_w = 0;
29+
30+
/*
31+
################################# MAIN FUNCTION ##############################################
32+
*/
33+
34+
int main() {
35+
36+
/* ###### create IMDP object ###### */
37+
IMDP mdp(dim_x,dim_u,dim_w);
38+
39+
/* ###### load the different spaces ###### */
40+
mdp.loadStateSpace("ss.h5");
41+
mdp.loadInputSpace("is.h5");
42+
43+
/* ###### load matrices and vectors ######*/
44+
mdp.loadMinTargetTransitionVector("minttm.h5");
45+
mdp.loadMaxTargetTransitionVector("minttm.h5");
46+
mdp.loadMinAvoidTransitionVector("minatm.h5");
47+
mdp.loadMaxAvoidTransitionVector("maxatm.h5");
48+
mdp.loadMinTransitionMatrix("mintm.h5");
49+
mdp.loadMaxTransitionMatrix("maxtm.h5");
50+
51+
/* ###### synthesize infinite horizon controller ######*/
52+
mdp.infiniteHorizonReachControllerSorted(true);
53+
54+
/* ###### save controller ######*/
55+
mdp.saveController();
56+
57+
return 0;
58+
}
59+

examples/ex_GPU/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CC = acpp # check AdaptiveCPP GitHub for correct GPU selection and put inside --acpp-targets="" (see: https://github.com/AdaptiveCpp/AdaptiveCpp/blob/develop/doc/using-hipsycl.md)
2+
CFLAGS = --acpp-targets="cuda:sm_70;omp" -O3 -lnlopt -lm -I/usr/include/hdf5/serial -L/usr/lib/x86_64-linux-gnu/hdf5/serial -lhdf5 -lglpk -lgsl -lgslcblas -DH5_USE_110_API -larmadillo
3+
4+
# Find all .cpp files in the current directory
5+
CPP_FILES := $(wildcard *.cpp)
6+
7+
# Generate corresponding executable names
8+
EXECUTABLES := $(patsubst %.cpp,%,$(CPP_FILES))
9+
10+
all: $(EXECUTABLES)
11+
12+
# see: below IMDP.cpp replaced with GPU_synthesis.cpp
13+
%: %.cpp ../../src/GPU_synthesis.cpp ../../src/MDP.cpp
14+
$(CC) $^ $(CFLAGS) -o $@
15+
16+
clean:
17+
rm -f $(EXECUTABLES)
18+

examples/ex_GPU/is.h5

3.89 KB
Binary file not shown.

examples/ex_GPU/maxatm.h5

404 KB
Binary file not shown.

examples/ex_GPU/maxtm.h5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:017924b2d747131aa8cf2beeb1cf3b9ba47d3472548ce1e550c84ad1fe8004f7
3+
size 174847048

examples/ex_GPU/maxttm.h5

404 KB
Binary file not shown.

examples/ex_GPU/minatm.h5

404 KB
Binary file not shown.

examples/ex_GPU/mintm.h5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:f996fe37afe7485abead1fb173a97f6730540bcb9e7c6fd60ded920cd9d00dd4
3+
size 174847048

examples/ex_GPU/minttm.h5

404 KB
Binary file not shown.

examples/ex_GPU/ss.h5

8.64 KB
Binary file not shown.

0 commit comments

Comments
 (0)