Skip to content

Commit

Permalink
began gtest
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorySchwing committed Aug 12, 2021
1 parent 893329c commit 4997fae
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 50 deletions.
4 changes: 2 additions & 2 deletions CMake/CPUParallel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set(CPU_PARALLEL_name "K_VC_CPU_PARALLEL")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED true)
#add_executable(CPUParallel ${sources_cpu_parallel} ${headers_cpu_parallel} ${libHeaders} ${libSources} ${BOOST_INCLUDE_DIRS})
add_executable(CPUParallel ${headers_common} ${sources_common} ${sources_simple_parallel} ${headers_simple_parallel})
add_executable(CPUParallel ${headers_lib} ${sources_lib} ${sources_simple_parallel} ${headers_simple_parallel})
set_target_properties(CPUParallel PROPERTIES OUTPUT_NAME ${CPU_PARALLEL_name})
if(WIN32)
#needed for hostname
target_link_libraries(CPUParallel ws2_32)
endif()
endif()
60 changes: 18 additions & 42 deletions CMake/FileLists.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
set(sources_common
common/CSVIterator.cpp
common/CSVRange.cpp
common/CSVRow.cpp
)

set(headers_common
common/CSVIterator.h
common/CSVRange.h
common/CSVRow.h
)

set(sources_cpu_serial
MainSerial.cpp
Expand All @@ -23,18 +12,6 @@ set(sources_cpu_serial
serial/SparseMatrix.cpp
)

set(sources_cpu_parallel
MainOpenMP.cpp
openmp/COO.cpp
openmp/CSR.cpp
openmp/Graph.cpp
openmp/LinearTimeDegreeSort.cpp
openmp/ParallelB1.cpp
openmp/ParallelKernelization.cpp
openmp/SparseMatrix.cpp
)


set(sources_simple_parallel
MainSimpleParallel.cpp
simpleParallel/COO.cpp
Expand Down Expand Up @@ -68,16 +45,6 @@ set(headers_cpu_serial
serial/SparseMatrix.h
)

set(headers_cpu_parallel
openmp/COO.h
openmp/CSR.h
openmp/Graph.h
openmp/LinearTimeDegreeSort.h
openmp/ParallelB1.h
openmp/ParallelKernelization.h
openmp/SparseMatrix.h
)

set(headers_simple_parallel
simpleParallel/COO.h
simpleParallel/CSR.h
Expand All @@ -97,15 +64,24 @@ set(headers_gpu
gpu/SparseMatrix.cuh
)

set(libHeaders
lib/boost/include/dynamic_bitset.hpp
lib/boost/include/dynamic_bitset_fwd.hpp
lib/boost/include/dynamic_bitset/dynamic_bitset.hpp
lib/boost/include/dynamic_bitset/config.hpp
)
#set(libHeaders
# lib/boost/include/dynamic_bitset.hpp
# lib/boost/include/dynamic_bitset_fwd.hpp
# lib/boost/include/dynamic_bitset/dynamic_bitset.hpp
# lib/boost/include/dynamic_bitset/config.hpp
# )

set(sources_lib
lib/CSVIterator.cpp
lib/CSVRange.cpp
lib/CSVRow.cpp
)

set(libSources
)
set(headers_lib
lib/CSVIterator.h
lib/CSVRange.h
lib/CSVRow.h
)

set(cudaHeaders
)
Expand All @@ -116,4 +92,4 @@ set(cudaSources
source_group("Header Files" FILES ${headers})
source_group("Lib Headers" FILES ${libHeaders})
source_group("CUDA Header Files" FILES ${cudaHeaders})
source_group("CUDA Source Files" FILES ${cudaSources})
source_group("CUDA Source Files" FILES ${cudaSources})
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ project(FPT)
#include_directories(serial)
#include_directories(lib/boost/include)
#include_directories(lib/boost)
#include_directories(lib)

include_directories(simpleParallel)
include_directories(test/src)

#Out-of-source build
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand Down Expand Up @@ -67,8 +67,19 @@ if (CMAKE_CUDA_COMPILER)
# include(${PROJECT_SOURCE_DIR}/CMake/GPU.cmake)
endif()


#Optional CMake Argument
option(GTEST "Build unit tests " OFF)
option(GTEST_MPI "Build unit tests - MPI Enabled" OFF)

# Enable google test, for now these vars of exclusive
if(GTEST OR GTEST_MPI)
enable_testing()
include(${PROJECT_SOURCE_DIR}/test/GoogleTest.cmake)
endif()


# Setup Serial version
#include(${PROJECT_SOURCE_DIR}/CMake/CPUSerial.cmake)
include(${PROJECT_SOURCE_DIR}/CMake/CPUParallel.cmake)

# find OpenMP and set it up
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions simpleParallel/COO.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>
#include <string>
#include <iostream>
#include "../common/CSVRange.h"
#include "../lib/CSVRange.h"
#include <iterator>
#include <algorithm> /* rand */
#include <map>
Expand Down Expand Up @@ -46,4 +46,4 @@ class COO final : public SparseMatrix
std::map< std::pair<int, int>, int > orderedMap;
bool isSorted;
};
#endif
#endif
2 changes: 1 addition & 1 deletion simpleParallel/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <random>
#include <iterator>
#include "ConnectednessTest.h"
#include "../common/CSVRange.h"
#include "../lib/CSVRange.h"

class Graph {
public:
Expand Down
15 changes: 15 additions & 0 deletions test/CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.8)

project(googletest-download NONE)

include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
23 changes: 23 additions & 0 deletions test/FileList.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(TestSources
test/src/ParallelKernelizationTest.cpp
)

set(TestHeaders
)

#set(headers
#)

#set(libHeaders
#)

#set(cudaSources
#)

#set(cudaHeaders
#)

#source_group("Header Files" FILES ${headers})
#source_group("Lib Headers" FILES ${libHeaders})
#source_group("CUDA Header Files" FILES ${cudaHeaders})
#source_group("CUDA Source Files" FILES ${cudaSources})
42 changes: 42 additions & 0 deletions test/GoogleTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Download and unpack googletest at configure time
configure_file(${PROJECT_SOURCE_DIR}/test/CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()
# Include file lists
include(${PROJECT_SOURCE_DIR}/test/FileList.cmake)
#MESSAGE(STATUS "Cuda version: ${PROJECT_SOURCE_DIR}/CMake/FileList.cmake")
#include(${PROJECT_SOURCE_DIR}/CMake/FileList.cmake)

# Now simply link against gtest or gtest_main as needed. Eg
add_executable(FPT_Test ${headers_simple_parallel} ${headers_lib} ${sources_lib} ${TestHeaders} ${TestSources})
#add_executable(FPT_Test ${sources_simple_parallel} ${headers_simple_parallel} ${headers_lib} ${sources_lib} ${TestHeaders} ${TestSources})
target_link_libraries(FPT_Test gtest_main)
add_test(NAME PKTest COMMAND PKTest)
#set(GOMC_GTEST 1)
7 changes: 7 additions & 0 deletions test/src/ParallelKernelizationTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <gtest/gtest.h>
#include "ParallelKernelization.h"
TEST(PKTest, DegreeKernelTester) {

EXPECT_EQ(true, true);

}

0 comments on commit 4997fae

Please sign in to comment.