| 1 |
# @HEADER |
| 2 |
# ***************************************************************************** |
| 3 |
# TriBITS: Tribal Build, Integrate, and Test System |
| 4 |
# |
| 5 |
# Copyright 2013-2016 NTESS and the TriBITS contributors. |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# ***************************************************************************** |
| 8 |
# @HEADER |
| 9 |
|
| 10 |
|
| 11 |
# |
| 12 |
# Top-level project logic to generate resources spec file |
| 13 |
# |
| 14 |
function(tribits_generate_ctest_resource_spec_file_project_logic) |
| 15 |
if (${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE) |
| 16 |
if (CTEST_RESOURCE_SPEC_FILE STREQUAL CTEST_RESOURCE_SPEC_FILE_DEFAULT) |
| 17 |
tribits_generate_ctest_resource_spec_file() |
| 18 |
else() |
| 19 |
message("NOTE: The test resource file CTEST_RESOURCE_SPEC_FILE='${CTEST_RESOURCE_SPEC_FILE}'" |
| 20 |
" will not be auto-generated even through" |
| 21 |
" ${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE=${${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE}" |
| 22 |
" because its location does not match the default" |
| 23 |
" location '${CTEST_RESOURCE_SPEC_FILE_DEFAULT}'." |
| 24 |
" If you want to auto-generate this file, please clear CTEST_RESOURCE_SPEC_FILE and" |
| 25 |
" reconfigure or create that file on your own and clear" |
| 26 |
" ${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE." |
| 27 |
) |
| 28 |
endif() |
| 29 |
endif() |
| 30 |
endfunction() |
| 31 |
|
| 32 |
|
| 33 |
# |
| 34 |
# Generate resource spec file |
| 35 |
# |
| 36 |
function(tribits_generate_ctest_resource_spec_file) |
| 37 |
set(GPUS_JSON) |
| 38 |
math(EXPR LAST_GPU "${${PROJECT_NAME}_CUDA_NUM_GPUS} - 1") |
| 39 |
set(FIRST 1) |
| 40 |
foreach(GPU RANGE 0 ${LAST_GPU}) |
| 41 |
if(NOT FIRST) |
| 42 |
string(APPEND GPUS_JSON ",\n") |
| 43 |
endif() |
| 44 |
set(FIRST 0) |
| 45 |
string(APPEND GPUS_JSON " { |
| 46 |
\"id\": \"${GPU}\", |
| 47 |
\"slots\": ${${PROJECT_NAME}_CUDA_SLOTS_PER_GPU} |
| 48 |
}") |
| 49 |
endforeach() |
| 50 |
file(WRITE "${CMAKE_BINARY_DIR}/ctest_resources.json" "{ |
| 51 |
\"version\": { |
| 52 |
\"major\": 1, |
| 53 |
\"minor\": 0 |
| 54 |
}, |
| 55 |
\"local\": [ |
| 56 |
{ |
| 57 |
\"gpus\": [ |
| 58 |
${GPUS_JSON} |
| 59 |
] |
| 60 |
} |
| 61 |
] |
| 62 |
} |
| 63 |
") |
| 64 |
endfunction() |