Add sollve_vv external project.

sollve_vv is the OpenMP Validation & Verification suite to test
conformance to with the OpenMP specification.

It is included as an external project, i.e. some work is required before
it is enabled, for instance setting TEST_SUITE_SOLLVEVV_ROOT to the
downloaded source repository. OpenMP is detected using CMake's
find_package(OpenMP) but the offloading flags must be specified manually
in CMake using TEST_SUITE_SOLLVEVV_OFFLOADING_CFLAGS and
TEST_SUITE_SOLLVEVV_OFFLOADING_LDFLAGS.

Differential Revision: https://reviews.llvm.org/D70065
diff --git a/CMakeLists.txt b/CMakeLists.txt
index edb3167..16c7614 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -188,6 +188,7 @@
 include(TestSuite)
 include(SingleMultiSource)
 find_package(TCL)
+find_package(OpenMP)
 
 if(NOT DEFINED TARGET_OS)
   message(STATUS "Check target operating system - ${CMAKE_SYSTEM_NAME}")
diff --git a/External/CMakeLists.txt b/External/CMakeLists.txt
index 3c778d5..fd78f88 100644
--- a/External/CMakeLists.txt
+++ b/External/CMakeLists.txt
@@ -4,3 +4,4 @@
 add_subdirectory(Povray)
 add_subdirectory(SPEC)
 add_subdirectory(skidmarks10)
+add_subdirectory(sollve_vv)
diff --git a/External/sollve_vv/CMakeLists.txt b/External/sollve_vv/CMakeLists.txt
new file mode 100644
index 0000000..f729747
--- /dev/null
+++ b/External/sollve_vv/CMakeLists.txt
@@ -0,0 +1,67 @@
+# SOLLVE OpenMP Offloading Validation & Verification Suite
+# https://crpl.cis.udel.edu/ompvvsollve/
+
+set(TEST_SUITE_SOLLVEVV_OFFLOADING_CFLAGS "-fopenmp-targets=nvptx64-nvidia-cuda;-Xopenmp-target;-march=sm_70" CACHE STRING "Compiler arguments for OpenMP offloading")
+set(TEST_SUITE_SOLLVEVV_OFFLOADING_LDFLAGS "-fopenmp-targets=nvptx64-nvidia-cuda;-Xopenmp-target;-march=sm_70;-lopenmptarget" CACHE STRING "Linker arguments for OpenMP offloading")
+
+function (add_sollvevv LANG)
+  set(_includedir "${TEST_SUITE_SOLLVEVV_ROOT}/ompvv" )
+
+  if (NOT OPENMP_${LANG}_FOUND)
+    message(FATAL_ERROR "OpenMP for ${LANG} not found")
+    return ()
+  endif ()
+
+  #if (OpenMP_${LANG}_VERSION VERSION_LESS "4.5")
+  #  message(FATAL_ERROR "OpenMP version ${OpenMP_${LANG}_VERSION} too old")
+  #endif ()
+
+  if ("${LANG}" STREQUAL "C")
+    set(_langext ".c")
+  elseif ("${LANG}" STREQUAL "CXX")
+    set(_langext ".cpp")
+  else ()
+    message(FATAL_ERROR "Unsupported languge ${LANG}")
+  endif ()
+
+  file(GLOB_RECURSE _tests_sources RELATIVE "${TEST_SUITE_SOLLVEVV_ROOT}/tests" "${TEST_SUITE_SOLLVEVV_ROOT}/tests/*${_langext}" )
+  foreach (_file IN LISTS _tests_sources)
+    get_filename_component(_ext "${_file}" EXT)
+    get_filename_component(_basename "${_file}" NAME_WE)
+    get_filename_component(_directory "${_file}" DIRECTORY)
+    string(REPLACE "." "" _ext "${_ext}")
+    string(REPLACE "/" "_" _directory "${_directory}")
+    string(REPLACE "." "" _directory "${_directory}")
+    set(_name "omptargetvv-${_basename}-${_directory}-${_ext}")
+
+    llvm_test_run()
+
+    llvm_test_executable(${_name} "${TEST_SUITE_SOLLVEVV_ROOT}/tests/${_file}")
+    target_include_directories(${_name} PRIVATE "${_includedir}")
+    target_link_libraries(${_name} PUBLIC OpenMP::OpenMP_${_lang})
+
+    # Add -fopenmp to linker command line; for some reason this is not done by target_link_libraries.
+    target_link_options(${_name} PRIVATE ${OpenMP_${LANG}_FLAGS})
+
+    # CMake's find_package(OpenMP) currently does not not introspect flags necessary for offloading.
+    target_compile_options(${_name} PUBLIC ${TEST_SUITE_SOLLVEVV_OFFLOADING_CFLAGS})
+    target_link_options(${_name} PUBLIC ${TEST_SUITE_SOLLVEVV_OFFLOADING_LDFLAGS})
+  endforeach ()
+endfunction ()
+
+
+llvm_externals_find(TEST_SUITE_SOLLVEVV_ROOT "sollve_vv" "OpenMP Offloading Validation & Verification Suite")
+if (TEST_SUITE_SOLLVEVV_ROOT AND NOT TEST_SUITE_BENCHMARKING_ONLY)
+  if (OPENMP_FOUND)
+    message(STATUS "Adding OpenMP Offloading Validiation & Verification")
+  else ()
+    message(STATUS "NOT using OpenMP Validiation & Verification because OpenMP was not found")
+    return ()
+  endif ()
+
+  foreach (_lang in C CXX)
+    if (CMAKE_${_lang}_COMPILER)
+      add_sollvevv(${_lang})
+    endif()
+  endforeach ()
+endif ()
diff --git a/External/sollve_vv/README b/External/sollve_vv/README
new file mode 100644
index 0000000..f4e8b6e
--- /dev/null
+++ b/External/sollve_vv/README
@@ -0,0 +1,54 @@
+SOLLVE OpenMP Offloading Validation & Verification Suite
+https://crpl.cis.udel.edu/ompvvsollve/
+
+This directory contains a CMakeLists.txt for the SOLLVE OpenMP
+Offloading Validation and Verification Suite so it can be built as part
+of the LLVM test-suite. Its sources are not part of the test-suite but
+have to be fetched separately from https://github.com/SOLLVE/sollve_vv.
+
+The sources are expected either in ${TEST_SUITE_SOLLVEVV_ROOT} or
+${TEST_SUITE_EXTERNALS_DIR}/sollve_vv, where TEST_SUITE_SOLLVEVV_ROOT
+and TEST_SUITE_EXTERNALS_DIR are CMake configure variables. If none of
+them are set, it will look into
+${CMAKE_SOURCE_DIR}/test-suite-externals/sollve_vv where
+CMAKE_SOURCE_DIR is the root directory of the test-suite sources.
+
+The CMakeLists.txt will search for all C and C++ source files of the
+OpenMP V&V suite, compile and run them. That is, running llvm-lit
+(or "make check") will require a compatible accelerator on the running
+machine.
+
+OpenMP support is autodetected by CMake, but clang requires additional
+flags to enable offloading. An example run is:
+
+$ cmake ../llvm-test-suite -GNinja -DCMAKE_BUILD_TYPE=Release           \
+  -DTEST_SUITE_SOLLVEVV_ROOT=${HOME}/src/sollve_vv                      \
+  -DTEST_SUITE_LIT=${HOME}/build/llvm-project/release/bin/llvm-lit      \
+  -DCMAKE_C_COMPILER=${HOME}/install/llvm-project/release/bin/clang     \
+  -DCMAKE_CXX_COMPILER=${HOME}/install/llvm-project/release/bin/clang++ \
+  -DTEST_SUITE_SOLLVEVV_OFFLOADING_CFLAGS=-fopenmp-targets=nvptx64-nvidia-cuda;--cuda-path=/soft/compilers/cuda/cuda-10.1.243;-Xopenmp-target;-march=sm_70 \
+  -DTEST_SUITE_SOLLVEVV_OFFLOADING_LDFLAGS=-fopenmp-targets=nvptx64-nvidia-cuda;--cuda-path=/soft/compilers/cuda/cuda-10.1.243;-Xopenmp-target;-march=sm_70;-lopenmptarget \
+  -DTEST_SUITE_LIT_FLAGS=-svj1
+
+$ LD_LIBRARY_PATH=${HOME}/install/llvm-project/release/lib ninja check
+
+
+Clang also needs to be compiled with enabled offloading for the chosen
+target. A configuration compatible for the commands above is:
+
+$ cmake ../llvm-project/llvm -GNinja -DCMAKE_BUILD_TYPE=Release   \
+  -DCMAKE_INSTALL_PREFIX=${HOME}/install/llvm-project/release     \
+  -DLLVM_ENABLE_PROJECTS=clang;openmp                             \
+  -DCUDA_TOOLKIT_ROOT_DIR=/soft/compilers/cuda/cuda-10.1.243      \
+  -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=70
+
+$ cmake install
+
+
+In this example, Clang is not installed into a default search path such
+that the paths have to be specified explicitly. The options
+"-DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=70" and "-march=sm_70" are to
+select the PTX version to compile to. "-DCUDA_TOOLKIT_ROOT_DIR" and
+"--cuda-path" point to the CUDA SDK to use. The option
+"-DTEST_SUITE_LIT_FLAGS=-j1" is required to not run the tests in parallel;
+multiple tests may conflict while running on the same GPU and thus fail.