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