From 876cf62e0e307684f192a77bc36ca422f00f4bbd Mon Sep 17 00:00:00 2001 From: Vlad Sytchenko Date: Tue, 2 Jun 2020 11:56:14 -0400 Subject: [PATCH] Only build oclgl tests if OpenGL is installed on the system Change-Id: I226f2e09c98a970ce8dce0b6f670ca13d868aeb6 --- opencl/tests/ocltst/CMakeLists.txt | 8 ++-- .../tests/ocltst/module/common/CMakeLists.txt | 28 +++++++++--- .../tests/ocltst/module/perf/CMakeLists.txt | 25 ++++++++--- opencl/tests/ocltst/module/perf/TestList.cpp | 44 ++++++++++--------- .../ocltst/module/runtime/CMakeLists.txt | 11 +++-- 5 files changed, 79 insertions(+), 37 deletions(-) diff --git a/opencl/tests/ocltst/CMakeLists.txt b/opencl/tests/ocltst/CMakeLists.txt index d455088f82..db110fde1f 100644 --- a/opencl/tests/ocltst/CMakeLists.txt +++ b/opencl/tests/ocltst/CMakeLists.txt @@ -2,12 +2,14 @@ cmake_minimum_required(VERSION 3.5.1) set(OCLTST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -find_package(OpenGL REQUIRED) -find_package(GLEW REQUIRED) +find_package(OpenGL) +find_package(GLEW) add_subdirectory(module/common) add_subdirectory(log) add_subdirectory(env) -add_subdirectory(module/gl) +if(OPENGL_FOUND AND GLEW_FOUND) + add_subdirectory(module/gl) +endif() add_subdirectory(module/perf) add_subdirectory(module/runtime) diff --git a/opencl/tests/ocltst/module/common/CMakeLists.txt b/opencl/tests/ocltst/module/common/CMakeLists.txt index 307db89f8b..a4447c6a52 100644 --- a/opencl/tests/ocltst/module/common/CMakeLists.txt +++ b/opencl/tests/ocltst/module/common/CMakeLists.txt @@ -1,7 +1,5 @@ -add_library(Common OBJECT +set(COMMON_SOURCES ${OCLTST_DIR}/module/common/BaseTestImp.cpp - ${OCLTST_DIR}/module/common/OCLGLCommon.cpp - ${OCLTST_DIR}/module/common/OCLGLCommonLinux.cpp ${OCLTST_DIR}/module/common/OCLTestImp.cpp ${OCLTST_DIR}/module/common/OCLTestListImp.cpp ${OCLTST_DIR}/module/common/OCLTestUtils.cpp @@ -9,6 +7,15 @@ add_library(Common OBJECT ${OCLTST_DIR}/module/common/OCLWrapper.cpp ${OCLTST_DIR}/module/common/Timer.cpp) +if(OPENGL_FOUND AND GLEW_FOUND) + set(COMMON_SOURCES + ${COMMON_SOURCES} + ${OCLTST_DIR}/module/common/OCLGLCommon.cpp + ${OCLTST_DIR}/module/common/OCLGLCommonLinux.cpp) +endif() + +add_library(Common OBJECT ${COMMON_SOURCES}) + set_target_properties(Common PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED ON @@ -20,12 +27,23 @@ target_compile_definitions(Common ATI_OS_LINUX CL_TARGET_OPENCL_VERSION=220) +if(OPENGL_FOUND AND GLEW_FOUND) + target_compile_definitions(Common + PUBLIC + USE_OPENGL=1) +endif() + target_include_directories(Common PUBLIC ${OPENCL_ICD_LOADER_HEADERS_DIR} - ${OPENGL_INCLUDE_DIR} - ${GLEW_INCLUDE_DIRS} ${OCLTST_DIR}/include ${OCLTST_DIR}/module/common ${OCLTST_DIR}/module/include ${PROJECT_SOURCE_DIR}/amdocl) #TODO remove cl_profile_amd.h dependency + +if(OPENGL_FOUND AND GLEW_FOUND) + target_include_directories(Common + PUBLIC + ${OPENGL_INCLUDE_DIR} + ${GLEW_INCLUDE_DIRS}) +endif() diff --git a/opencl/tests/ocltst/module/perf/CMakeLists.txt b/opencl/tests/ocltst/module/perf/CMakeLists.txt index deba448506..4fc5a6af04 100644 --- a/opencl/tests/ocltst/module/perf/CMakeLists.txt +++ b/opencl/tests/ocltst/module/perf/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(oclperf SHARED +set(OCLPERF_SOURCES OCLPerf3DImageWriteSpeed.cpp OCLPerfAES256.cpp OCLPerfAtomicSpeed20.cpp @@ -55,7 +55,6 @@ add_library(oclperf SHARED OCLPerfSampleRate.cpp OCLPerfScalarReplArrayElem.cpp OCLPerfSdiP2PCopy.cpp - OCLPerfSepia.cpp OCLPerfSHA256.cpp OCLPerfSVMAlloc.cpp OCLPerfSVMKernelArguments.cpp @@ -69,7 +68,16 @@ add_library(oclperf SHARED OCLPerfUAVWriteSpeedHostMem.cpp OCLPerfUncoalescedRead.cpp OCLPerfVerticalFetch.cpp - TestList.cpp + TestList.cpp) + +if(OPENGL_FOUND AND GLEW_FOUND) + set(OCLPERF_SOURCES + ${OCLPERF_SOURCES} + OCLPerfSepia.cpp) +endif() + +add_library(oclperf SHARED + ${OCLPERF_SOURCES} $) set_target_properties(oclperf PROPERTIES @@ -88,9 +96,14 @@ target_include_directories(oclperf target_link_libraries(oclperf PRIVATE - OpenCL - ${GLEW_LIBRARIES} - ${OPENGL_LIBRARIES}) + OpenCL) + +if(OPENGL_FOUND AND GLEW_FOUND) + target_link_libraries(oclperf + PRIVATE + ${GLEW_LIBRARIES} + ${OPENGL_LIBRARIES}) +endif() add_custom_command( TARGET oclperf POST_BUILD diff --git a/opencl/tests/ocltst/module/perf/TestList.cpp b/opencl/tests/ocltst/module/perf/TestList.cpp index 343471a45d..4ae789e75a 100644 --- a/opencl/tests/ocltst/module/perf/TestList.cpp +++ b/opencl/tests/ocltst/module/perf/TestList.cpp @@ -1,23 +1,23 @@ -/* Copyright (c) 2010-present Advanced Micro Devices, Inc. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. */ - +/* Copyright (c) 2010-present Advanced Micro Devices, Inc. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. */ + #include "OCLTestListImp.h" // @@ -69,7 +69,9 @@ #include "OCLPerfSampleRate.h" #include "OCLPerfScalarReplArrayElem.h" #include "OCLPerfSdiP2PCopy.h" +#if USE_OPENGL #include "OCLPerfSepia.h" +#endif #include "OCLPerfTextureMemLatency.h" #include "OCLPerfUAVReadSpeed.h" #include "OCLPerfUAVReadSpeedHostMem.h" @@ -143,7 +145,9 @@ TestEntry TestList[] = { TEST(OCLPerfImageCopyCorners), TEST(OCLPerfScalarReplArrayElem), TEST(OCLPerfSdiP2PCopy), +#if USE_OPENGL TEST(OCLPerfSepia), +#endif TEST(OCLPerfFlush), TEST(OCLPerfMemCreate), TEST(OCLPerfImageMapUnmap), diff --git a/opencl/tests/ocltst/module/runtime/CMakeLists.txt b/opencl/tests/ocltst/module/runtime/CMakeLists.txt index af46e347ed..5ef6298ec0 100644 --- a/opencl/tests/ocltst/module/runtime/CMakeLists.txt +++ b/opencl/tests/ocltst/module/runtime/CMakeLists.txt @@ -61,9 +61,14 @@ target_include_directories(oclruntime target_link_libraries(oclruntime PRIVATE - OpenCL - ${GLEW_LIBRARIES} - ${OPENGL_LIBRARIES}) + OpenCL) + +if(OPENGL_FOUND AND GLEW_FOUND) + target_link_libraries(oclruntime + PRIVATE + ${GLEW_LIBRARIES} + ${OPENGL_LIBRARIES}) +endif() add_custom_command( TARGET oclruntime POST_BUILD