1# @HEADER 2# ************************************************************************ 3# 4# TriBITS: Tribal Build, Integrate, and Test System 5# Copyright 2013 Sandia Corporation 6# 7# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 8# the U.S. Government retains certain rights in this software. 9# 10# Redistribution and use in source and binary forms, with or without 11# modification, are permitted provided that the following conditions are 12# met: 13# 14# 1. Redistributions of source code must retain the above copyright 15# notice, this list of conditions and the following disclaimer. 16# 17# 2. Redistributions in binary form must reproduce the above copyright 18# notice, this list of conditions and the following disclaimer in the 19# documentation and/or other materials provided with the distribution. 20# 21# 3. Neither the name of the Corporation nor the names of the 22# contributors may be used to endorse or promote products derived from 23# this software without specific prior written permission. 24# 25# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 26# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 29# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 30# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 31# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 33# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 34# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 35# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36# 37# ************************************************************************ 38# @HEADER 39 40 41# 42# Top-level project logic to generate resources spec file 43# 44FUNCTION(TRIBITS_GENERATE_CTEST_RESOURCE_SPEC_FILE_PROJECT_LOGIC) 45 IF (${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE) 46 IF (CTEST_RESOURCE_SPEC_FILE STREQUAL CTEST_RESOURCE_SPEC_FILE_DEFAULT) 47 TRIBITS_GENERATE_CTEST_RESOURCE_SPEC_FILE() 48 ELSE() 49 MESSAGE("NOTE: The test resource file CTEST_RESOURCE_SPEC_FILE='${CTEST_RESOURCE_SPEC_FILE}'" 50 " will not be auto-generated even through" 51 " ${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE=${${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE}" 52 " because its location does not match the default" 53 " location '${CTEST_RESOURCE_SPEC_FILE_DEFAULT}'." 54 " If you want to auto-generate this file, please clear CTEST_RESOURCE_SPEC_FILE and" 55 " reconfigure or create that file on your own and clear" 56 " ${PROJECT_NAME}_AUTOGENERATE_TEST_RESOURCE_FILE." 57 ) 58 ENDIF() 59 ENDIF() 60ENDFUNCTION() 61 62 63# 64# Generate resource spec file 65# 66FUNCTION(TRIBITS_GENERATE_CTEST_RESOURCE_SPEC_FILE) 67 SET(GPUS_JSON) 68 MATH(EXPR LAST_GPU "${${PROJECT_NAME}_CUDA_NUM_GPUS} - 1") 69 SET(FIRST 1) 70 FOREACH(GPU RANGE 0 ${LAST_GPU}) 71 IF(NOT FIRST) 72 STRING(APPEND GPUS_JSON ",\n") 73 ENDIF() 74 SET(FIRST 0) 75 STRING(APPEND GPUS_JSON " { 76 \"id\": \"${GPU}\", 77 \"slots\": ${${PROJECT_NAME}_CUDA_SLOTS_PER_GPU} 78 }") 79 ENDFOREACH() 80 FILE(WRITE "${CMAKE_BINARY_DIR}/ctest_resources.json" "{ 81 \"version\": { 82 \"major\": 1, 83 \"minor\": 0 84 }, 85 \"local\": [ 86 { 87 \"gpus\": [ 88${GPUS_JSON} 89 ] 90 } 91 ] 92} 93") 94ENDFUNCTION() 95