forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdumpGPUParamByArch.sh
More file actions
executable file
·60 lines (47 loc) · 1.82 KB
/
dumpGPUParamByArch.sh
File metadata and controls
executable file
·60 lines (47 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
if [[ -z $3 ]]; then
echo "Usage: dumpGPUParamByArch.sh [JSON or CSV parameter file] [Architecture] [Output File]"
exit 1
fi
if ! command -v root &> /dev/null; then
echo "Cannot run root, please make sure ROOT is available and in the parh"
exit 1
fi
if [[ ! -f $1 ]]; then
echo "Input file $1 does not exist"
exit 1
fi
if [[ -f "include/GPU/GPUDefParametersLoad.inc" ]]; then
LOADDIR=$(realpath "include/GPU")
elif [[ -f "$O2_ROOT/include/GPU/GPUDefParametersLoad.inc" ]]; then
LOADDIR=$(realpath "$O2_ROOT/include/GPU/")
else
echo "Cannot find GPUDefParametersLoad.inc, please run from standalone benchmark folder or set \$O2_ROOT to the standalone or O2 installation"
exit 1
fi
set -e
TMPDIR=$(mktemp -d)
if [[ $? != 0 ]]; then
echo "Failed to create a temporary directory"
exit 1
fi
BASE_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
if [[ $1 =~ \.csv$ ]]; then
"${BASE_DIR}"/../../Definitions/Parameters/csv_to_json.sh $1 > "$TMPDIR"/temp.json
JSON_FILE="$TMPDIR"/temp.json
else
JSON_FILE=$(realpath $1)
fi
cat <<EOT > "${TMPDIR}"/CMakeLists.txt
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(DumpGPUParam NONE)
include($BASE_DIR/../../Definitions/Parameters/gpu_param_header_generator.cmake)
generate_gpu_param_header("${JSON_FILE}" "$2" "${TMPDIR}/GPUDefParametersDefaultsOnTheFly.h" "${TMPDIR}/GPUDefParametersDefaultsDeviceOnTheFly.h")
EOT
cmake -B "${TMPDIR}" -S"${TMPDIR}"
echo -e "#define GPUCA_GPUTYPE_$2\n" \
"#define PARAMETER_FILE \"${TMPDIR}/GPUDefParametersDefaultsOnTheFly.h\"\n" \
"gInterpreter->AddIncludePath(\"${TMPDIR}\");gInterpreter->AddIncludePath(\"${LOADDIR}\");\n" \
".x $BASE_DIR/dumpGPUDefParam.C(\"$3\")\n.q\n" | root -l -b
echo -e "\nCreated $3 with parameters for $2 architecture from $1"
rm -Rf "${TMPDIR}"