From 68177b2fee831fbb6e4edf781ebbca1d287dae28 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Sat, 26 Jan 2019 12:25:05 -0500 Subject: [PATCH] expand os for c++ testing --- .appveyor.yml | 48 ++++++ .travis.yml | 13 +- CMakeLists.txt | 117 ++++++++----- cmake/TBB.txt.in | 2 +- scripts/test_python.js | 4 +- src/cpp/base.cpp | 11 +- src/cpp/compat_impl_win.cpp | 17 +- src/cpp/context_grouped_pkey.cpp | 6 + src/cpp/sparse_tree.cpp | 6 +- src/cpp/storage_impl_win.cpp | 4 - src/include/perspective/base.h | 62 ++++--- .../perspective/context_common_decls.h | 12 +- .../perspective/context_grouped_pkey.h | 3 +- src/include/perspective/first.h | 2 + src/include/perspective/table.h | 2 +- test/CMakeLists.txt | 6 +- test/cpp/psp.cpp | 1 + test/cpp/simple.cpp | 162 +----------------- test/include/perspective/simple.h | 159 +++++++++++++++++ test/include/perspective/test_utils.h | 1 + 20 files changed, 378 insertions(+), 260 deletions(-) create mode 100644 .appveyor.yml create mode 100644 test/include/perspective/simple.h diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000000..e8d8b1e4e4 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,48 @@ +max_jobs: 8 + +image: + - Visual Studio 2015 + - Visual Studio 2017 + +configuration: + - Release + - Debug + +platform: + - x64 + +environment: + matrix: + - arch: Win64 + +matrix: + allow_failures: + - platform: x64 + configuration: Debug + +init: + - set arch= + - if "%arch%"=="Win64" ( set arch= Win64) + - echo %arch% + - echo %APPVEYOR_BUILD_WORKER_IMAGE% + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" ( set generator="Visual Studio 15 2017%arch%" ) + - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" ( set generator="Visual Studio 14 2015%arch%" ) + +before_build: +- cmd: |- + mkdir build + cd build + cmake --version + cmake .. -G %generator% -DPSP_WASM_BUILD=0 -DPSP_CPP_BUILD=1 -DPSP_CPP_BUILD_TESTS=1 -DPSP_CPP_BUILD_STRICT=1 -DBOOST_ROOT=C:\Libraries\boost_1_67_0 -DBoost_INCLUDE_DIRS=C:\Libraries\boost_1_67_0 + +build_script: + - msbuild psp.sln /p:Platform=x64 /m /p:Configuration=%CONFIGURATION% + - cp %CONFIGURATION%\psp.dll test\%CONFIGURATION% + - cp tbb-build\%CONFIGURATION%\tbb.dll test\%CONFIGURATION% + - .\test\%CONFIGURATION%\psp_test.exe + +# to disable automatic tests +test: off + +# to disable deployment +deploy: off diff --git a/.travis.yml b/.travis.yml index 57d7c22a5b..bfcc3a2283 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,22 +3,26 @@ language: node_js node_js: "8" sudo: required -services: - - docker - matrix: include: - node_js: "8" language: node_js env: TEST=WASM + services: docker - language: c++ env: TEST=CPP + services: docker - python: "3.6" language: python env: TEST=PYTHON cache: pip + services: docker + + - language: c++ + env: TEST=CPP_OSX + os: osx cache: yarn: true @@ -37,6 +41,7 @@ env: install: + - if [ "$TEST" = "CPP_OSX" ]; then brew install yarn; fi - yarn script: @@ -48,3 +53,5 @@ script: - if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn build_python; fi - if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn lint_python; fi - if [ "$TEST" = "PYTHON" ]; then PSP_DOCKER=1 yarn test_python; fi + - if [ "$TEST" = "CPP_OSX" ]; then yarn build_cpp; fi + - if [ "$TEST" = "CPP_OSX" ]; then yarn test_cpp; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 84188c0155..eb111dd428 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,41 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH} ) +if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(WIN32 ON) +endif() + +############################## +# helper to grab gtest et al # +############################## +function (psp_build_dep name cmake_file) + if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build) + message(WARNING "${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}") + else() + configure_file(${cmake_file} ${name}-download/CMakeLists.txt) + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) + if(result) + message(FATAL_ERROR "CMake step for ${name} failed: ${result}") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) + if(result) + message(FATAL_ERROR "Build step for ${name} failed: ${result}") + endif() + endif() + add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src + ${CMAKE_BINARY_DIR}/${name}-build + EXCLUDE_FROM_ALL) + + include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/gtest/include) + include_directories(${CMAKE_BINARY_DIR}/${name}-src/include) + include_directories(${CMAKE_BINARY_DIR}/${name}-src) +endfunction() +############################## + ####################### # BUILD CONFIGURATION # @@ -101,7 +136,6 @@ if (PSP_WASM_BUILD) #################### # EMSCRIPTEN BUILD # #################### - add_definitions(-DPSP_ENABLE_WASM) set(CMAKE_C_COMPILER emcc) set(CMAKE_CXX_COMPILER em++) set(CMAKE_TOOLCHAIN_FILE "$ENV{EMSCRIPTEN_ROOT}/cmake/Modules/Platform/Emscripten.cmake") @@ -170,23 +204,29 @@ else() else() message("${Cyan}Found boost in ${Boost_INCLUDE_DIRS} ${Boost_LIBRARY_DIRS} ${ColorReset}") endif() - include_directories(Boost_INCLUDE_DIRS) + include_directories( ${Boost_INCLUDE_DIRS} ) find_package(TBB) if(NOT TBB_FOUND) message("${Red}TBB could not be located${ColorReset}") + psp_build_dep("tbb" "cmake/TBB.txt.in") else() message("${Cyan}Found tbb in ${TBB_INCLUDE_DIRS} ${TBB_LIBRARY_DIRS} ${ColorReset}") + include_directories( ${TBB_INCLUDE_DIRS} ) endif() - include_directories(TBB_INCLUDE_DIRS) - include_directories("/usr/local/include") + if(WIN32) + foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}") + endforeach(warning) + else() + include_directories("/usr/local/include") + endif() if(PSP_PYTHON_BUILD) ######################### # PYTHON BINDINGS BUILD # ######################### - add_definitions(-DPSP_ENABLE_PYTHON) include_directories("/usr/local/include/python3.7m") # FIXME include_directories("${CMAKE_SOURCE_DIR}/python/perspective/include") find_package( PythonInterp 3.7 REQUIRED ) @@ -238,6 +278,7 @@ set (SOURCE_FILES src/cpp/context_two.cpp src/cpp/context_zero.cpp src/cpp/custom_column.cpp + src/cpp/data.cpp src/cpp/date.cpp src/cpp/dense_nodes.cpp src/cpp/dense_tree_context.cpp @@ -287,20 +328,27 @@ set (SOURCE_FILES src/cpp/vocab.cpp ) -set(CMAKE_CXX_FLAGS " -std=c++0x ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") +if (WIN32) + set(CMAKE_CXX_FLAGS " /EHsc") +else() + set(CMAKE_CXX_FLAGS " -std=c++0x ${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") +endif() if (PSP_WASM_BUILD) add_library(psp ${SOURCE_FILES}) + target_compile_definitions(psp PRIVATE PSP_ENABLE_WASM=1) set_target_properties(psp PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}") add_executable(perspective.async src/cpp/emscripten.cpp) target_link_libraries(perspective.async psp "${ASYNC_MODE_FLAGS}") + target_compile_definitions(perspective.async PRIVATE PSP_ENABLE_WASM=1) set_target_properties(perspective.async PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}") set_target_properties(perspective.async PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/") set_target_properties(perspective.async PROPERTIES OUTPUT_NAME "psp.async") add_executable(perspective.sync src/cpp/emscripten.cpp) target_link_libraries(perspective.sync psp "${SYNC_MODE_FLAGS}") + target_compile_definitions(perspective.sync PRIVATE PSP_ENABLE_WASM=1) set_target_properties(perspective.sync PROPERTIES COMPILE_FLAGS "${SYNC_MODE_FLAGS}") set_target_properties(perspective.sync PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/") set_target_properties(perspective.sync PROPERTIES OUTPUT_NAME "psp.sync") @@ -308,6 +356,7 @@ if (PSP_WASM_BUILD) if (NOT CMAKE_BUILD_TYPE_LOWER STREQUAL debug) add_executable(perspective.asm src/cpp/emscripten.cpp) + target_compile_definitions(perspective.asm PRIVATE PSP_ENABLE_WASM=1) target_link_libraries(perspective.asm psp "${ASMJS_MODE_FLAGS}") set_target_properties(perspective.asm PROPERTIES COMPILE_FLAGS "${ASMJS_MODE_FLAGS}") set_target_properties(perspective.asm PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/") @@ -315,17 +364,23 @@ if (PSP_WASM_BUILD) add_dependencies(perspective.asm perspective.sync) endif() else() + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX .dylib) + endif() + if(PSP_PYTHON_BUILD) ######################## # Python extra targets # ######################## add_library(psp SHARED ${SOURCE_FILES} ${CMAKE_SOURCE_DIR}/python/perspective/src/numpy.cpp ${HEADER_FILES}) + target_compile_definitions(psp PRIVATE PSP_ENABLE_PYTHON=1) target_link_libraries(psp ${BOOST_PYTHON}) target_link_libraries(psp ${BOOST_NUMPY}) target_link_libraries(psp ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) set(CMAKE_SHARED_LIBRARY_SUFFIX .so) add_library(binding SHARED ${CMAKE_SOURCE_DIR}/python/perspective/src/python.cpp) + target_compile_definitions(binding PRIVATE PSP_ENABLE_PYTHON=1) target_link_libraries(binding psp) target_link_libraries(binding tbb) target_link_libraries(binding ${BOOST_PYTHON}) @@ -334,64 +389,32 @@ else() ######################## else() add_library(psp SHARED ${SOURCE_FILES} ${HEADER_FILES}) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(CMAKE_SHARED_LIBRARY_SUFFIX .dylib) - endif() endif() - if(PSP_CPP_BUILD_STRICT) + if(PSP_CPP_BUILD_STRICT AND NOT WIN32) target_compile_options(psp PRIVATE -Wall -Werror) + target_compile_options(psp PRIVATE $<$:-fPIC -O0>) + if(PSP_PYTHON_BUILD) + target_compile_options(binding PRIVATE $<$:-fPIC -O0>) + endif() + elseif(WIN32) + target_compile_definitions(psp PRIVATE PERSPECTIVE_EXPORTS=1) + target_compile_definitions(psp PRIVATE WIN32=1) endif() - # target_link_libraries(psp ${TBB_LIBRARIES}) // doesnt work on mac target_link_libraries(psp tbb) set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${TBB_LIBRARY}) - - target_compile_options(psp PRIVATE $<$:-fPIC -O0>) endif() -############################## -# helper to grab gtest et al # -############################## -function (psp_build_dep name cmake_file) - if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build) - message(WARNING "${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}") - - else() - configure_file(${cmake_file} ${name}-download/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) - if(result) - message(FATAL_ERROR "CMake step for ${name} failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) - if(result) - message(FATAL_ERROR "Build step for ${name} failed: ${result}") - endif() - endif() - add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src - ${CMAKE_BINARY_DIR}/${name}-build - EXCLUDE_FROM_ALL) - include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/gtest/include) - include_directories(${CMAKE_BINARY_DIR}/${name}-src/include) - include_directories(${CMAKE_BINARY_DIR}/${name}-src) -endfunction() -############################## - - ############# # CPP TESTS # ############# if (PSP_CPP_BUILD_TESTS) if (WIN32) - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) endif() psp_build_dep("googletest" "cmake/GTest.txt.in") - # psp_build_dep("tbb" "cmake/TBB.txt.in") add_subdirectory(test) add_custom_target(gcov diff --git a/cmake/TBB.txt.in b/cmake/TBB.txt.in index 03b914158f..96dd062c3d 100644 --- a/cmake/TBB.txt.in +++ b/cmake/TBB.txt.in @@ -13,4 +13,4 @@ ExternalProject_Add(tbb INSTALL_COMMAND "" TEST_COMMAND "" CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" -) +) \ No newline at end of file diff --git a/scripts/test_python.js b/scripts/test_python.js index dfae9c1f62..4fb13f06e3 100644 --- a/scripts/test_python.js +++ b/scripts/test_python.js @@ -23,8 +23,8 @@ function docker(image = "emsdk") { // Copy .so in place to perspective package try { - let cmd1 = "cp `find build -name 'libbinding.so'` python/perspective/table/"; - let cmd2 = "cp `find build -name 'libpsp.so'` python/perspective/table/"; + let cmd1 = "cp `find build -name 'libbinding.*'` python/perspective/table/"; + let cmd2 = "cp `find build -name 'libpsp.*'` python/perspective/table/"; if (process.env.PSP_DOCKER) { execute(docker("python") + ' bash -c "' + cmd1 + '"'); execute(docker("python") + ' bash -c "' + cmd2 + '"'); diff --git a/src/cpp/base.cpp b/src/cpp/base.cpp index 73de1e938d..cae91cdd79 100644 --- a/src/cpp/base.cpp +++ b/src/cpp/base.cpp @@ -14,8 +14,7 @@ namespace perspective { -void -psp_abort() { +void psp_abort() { std::raise(SIGINT); } @@ -316,6 +315,14 @@ is_internal_colname(const std::string& c) { return c.compare(std::string("psp_")) == 0; } + +template +t_dtype +type_to_dtype() { + return DTYPE_NONE; +} + + template <> t_dtype type_to_dtype() { diff --git a/src/cpp/compat_impl_win.cpp b/src/cpp/compat_impl_win.cpp index c4b7754a60..62572ee7a7 100644 --- a/src/cpp/compat_impl_win.cpp +++ b/src/cpp/compat_impl_win.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace perspective { @@ -117,12 +118,12 @@ map_file_write(const std::string& fname, t_uindex size, t_rfmapping& out) { CREATE_ALWAYS, PAGE_READWRITE, FILE_MAP_WRITE, false, static_cast(size), out); } -t_int64 +int64_t psp_curtime() { - return GetTickCount() * static_cast(1000000); + return GetTickCount() * static_cast(1000000); } -t_int64 +int64_t psp_curmem() { PROCESS_MEMORY_COUNTERS mem; GetProcessMemoryInfo(GetCurrentProcess(), &mem, sizeof(mem)); @@ -139,7 +140,7 @@ typedef struct t_win_thrstruct { #pragma pack(pop) static void -set_thread_name_win(t_uint32 thrid, const std::string& name) { +set_thread_name_win(uint32_t thrid, const std::string& name) { const DWORD MS_VC_EXCEPTION = 0x406D1388; t_win_thrstruct thrstruct; thrstruct.dwType = 0x1000; @@ -212,7 +213,7 @@ cwd() { return std::string(path); } -t_int64 +int64_t get_page_size() { SYSTEM_INFO info; GetSystemInfo(&info); @@ -224,8 +225,8 @@ psp_dbg_malloc(size_t size) { SYSTEM_INFO sys_info; GetSystemInfo(&sys_info); auto page = 2 * sys_info.dwPageSize; - assert((page & (static_cast(page) - 1)) == 0); - auto rounded_size = (size + static_cast(page) - 1) & (-static_cast(page)); + assert((page & (static_cast(page) - 1)) == 0); + auto rounded_size = (size + static_cast(page) - 1) & (-static_cast(page)); BYTE* start = (BYTE*)VirtualAlloc(NULL, rounded_size + page, MEM_COMMIT, PAGE_READWRITE); DWORD old_protect; BOOL res = VirtualProtect(start + rounded_size, page, PAGE_NOACCESS, &old_protect); @@ -240,7 +241,7 @@ psp_dbg_free(void* mem) { } void* -psp_page_aligned_malloc(t_int64 size) { +psp_page_aligned_malloc(int64_t size) { return _aligned_malloc(static_cast(size), static_cast(get_page_size())); } diff --git a/src/cpp/context_grouped_pkey.cpp b/src/cpp/context_grouped_pkey.cpp index 6ac9381813..937c0b8f38 100644 --- a/src/cpp/context_grouped_pkey.cpp +++ b/src/cpp/context_grouped_pkey.cpp @@ -29,6 +29,12 @@ t_ctx_grouped_pkey::t_ctx_grouped_pkey() : m_depth(0), m_depth_set(false) {} +t_ctx_grouped_pkey::t_ctx_grouped_pkey(t_schema schema, t_config config) + : m_depth(0), + m_depth_set(false) { + PSP_COMPLAIN_AND_ABORT('Not Implemented'); +} + t_ctx_grouped_pkey::~t_ctx_grouped_pkey() {} void diff --git a/src/cpp/sparse_tree.cpp b/src/cpp/sparse_tree.cpp index f4553a253f..355b36aa9c 100644 --- a/src/cpp/sparse_tree.cpp +++ b/src/cpp/sparse_tree.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include namespace perspective { @@ -1011,13 +1011,13 @@ t_stree::update_agg_table(t_uindex nidx, t_agg_update_info& info, t_uindex src_r new_value.set(gstate.reduce&)>>( pkeys, spec.get_dependencies()[0].name(), [this](std::vector& values) { - std::unordered_set vset; + std::set vset; for (const auto& v : values) { vset.insert(v); } std::stringstream ss; - for (std::unordered_set::const_iterator iter = vset.begin(); + for (std::set::const_iterator iter = vset.begin(); iter != vset.end(); ++iter) { ss << *iter << ", "; } diff --git a/src/cpp/storage_impl_win.cpp b/src/cpp/storage_impl_win.cpp index f927b88135..bfa841f634 100644 --- a/src/cpp/storage_impl_win.cpp +++ b/src/cpp/storage_impl_win.cpp @@ -10,14 +10,10 @@ #ifdef WIN32 #include -#define NO_IMPORT_ARRAY -#define PY_ARRAY_UNIQUE_SYMBOL _perspectiveNumpy -#include #include #include #include #include -#include #include #include #include diff --git a/src/include/perspective/base.h b/src/include/perspective/base.h index 5b202ed3b9..d8480d7113 100644 --- a/src/include/perspective/base.h +++ b/src/include/perspective/base.h @@ -16,6 +16,7 @@ #endif #include #include +#include #include #include #include @@ -60,14 +61,16 @@ const t_index INVALID_INDEX = -1; #define CHAR_BIT 8 #endif -void psp_abort(); +PERSPECTIVE_EXPORT void psp_abort(); //#define PSP_TRACE_SENTINEL() t_trace _psp_trace_sentinel; #define PSP_TRACE_SENTINEL() -#define GET_PSP_VERBOSE_ASSERT(_1,_2,_3,NAME,...) NAME +#define _ID(x) \ + x // https://stackoverflow.com/questions/25144589/c-macro-overloading-is-not-working +#define GET_PSP_VERBOSE_ASSERT(_1, _2, _3, NAME, ...) NAME #ifdef PSP_DEBUG -#define PSP_VERBOSE_ASSERT1(COND, MSG) \ +#define PSP_VERBOSE_ASSERT1(COND, MSG) \ { \ if (!(COND)) { \ std::stringstream ss; \ @@ -78,9 +81,9 @@ void psp_abort(); } \ } -#define PSP_VERBOSE_ASSERT2(COND, EXPR, MSG) \ +#define PSP_VERBOSE_ASSERT2(COND, EXPR, MSG) \ { \ - if (!(COND EXPR)) { \ + if (!(COND EXPR)) { \ std::stringstream ss; \ ss << __FILE__ << ":" << __LINE__ << ": " << MSG << " : " \ << perspective::get_error_str(); \ @@ -120,8 +123,16 @@ std::is_pod::value && std::is_standard_layout::value , \ #define LOG_INIT(X) #endif #else -#define PSP_VERBOSE_ASSERT1(COND, MSG) { if(!(COND)) psp_abort(); } -#define PSP_VERBOSE_ASSERT2(EXPR, COND, MSG) { if (!(EXPR COND)) psp_abort(); } +#define PSP_VERBOSE_ASSERT1(COND, MSG) \ + { \ + if (!(COND)) \ + psp_abort(); \ + } +#define PSP_VERBOSE_ASSERT2(EXPR, COND, MSG) \ + { \ + if (!(EXPR COND)) \ + psp_abort(); \ + } #define PSP_COMPLAIN_AND_ABORT(X) psp_abort(); #define PSP_ASSERT_SIMPLE_TYPE(X) #define LOG_CONSTRUCTOR(X) @@ -129,7 +140,9 @@ std::is_pod::value && std::is_standard_layout::value , \ #define LOG_INIT(X) #endif -#define PSP_VERBOSE_ASSERT(...) GET_PSP_VERBOSE_ASSERT(__VA_ARGS__, PSP_VERBOSE_ASSERT2, PSP_VERBOSE_ASSERT1)(__VA_ARGS__) +#define PSP_VERBOSE_ASSERT(...) \ + _ID(GET_PSP_VERBOSE_ASSERT(__VA_ARGS__, PSP_VERBOSE_ASSERT2, PSP_VERBOSE_ASSERT1)( \ + __VA_ARGS__)) // Currently only supporting single ports enum t_gnode_processing_mode { NODE_PROCESSING_SIMPLE_DATAFLOW, NODE_PROCESSING_KERNEL }; @@ -405,55 +418,52 @@ psp_to_str(const DATA_T& s) { } template -t_dtype -type_to_dtype() { - return DTYPE_NONE; -} +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); class t_date; class t_time; template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); template <> -t_dtype type_to_dtype(); +PERSPECTIVE_EXPORT t_dtype type_to_dtype(); } // end namespace perspective diff --git a/src/include/perspective/context_common_decls.h b/src/include/perspective/context_common_decls.h index 869c791a5c..0bcbea9f8e 100644 --- a/src/include/perspective/context_common_decls.h +++ b/src/include/perspective/context_common_decls.h @@ -7,12 +7,12 @@ * */ -t_index get_row_count() const; +perspective::t_index get_row_count() const; -t_index get_column_count() const; +perspective::t_index get_column_count() const; std::vector get_data( - t_index start_row, t_index end_row, t_index start_col, t_index end_col) const; + t_index start_row, t_index end_row, t_index start_col, t_index end_col) const; void sort_by(const std::vector& sortby); @@ -22,7 +22,7 @@ void reset_sortby(); void notify(const t_table& flattened); void notify(const t_table& flattened, const t_table& delta, const t_table& prev, - const t_table& current, const t_table& transitions, const t_table& existed); + const t_table& current, const t_table& transitions, const t_table& existed); void step_begin(); @@ -47,7 +47,7 @@ void set_feature_state(t_ctx_feature feature, bool state); std::vector get_pkeys(const std::vector>& cells) const; std::vector get_cell_data( - const std::vector>& cells) const; + const std::vector>& cells) const; std::vector get_min_max() const; @@ -92,4 +92,4 @@ bool unity_get_column_expanded(t_uindex idx) const; void unity_init_load_step_end(); // TODO -// add unity api for tables +// add unity api for tables \ No newline at end of file diff --git a/src/include/perspective/context_grouped_pkey.h b/src/include/perspective/context_grouped_pkey.h index 6ff8b2fc50..9a87ba4c5c 100644 --- a/src/include/perspective/context_grouped_pkey.h +++ b/src/include/perspective/context_grouped_pkey.h @@ -21,7 +21,8 @@ namespace perspective { class PERSPECTIVE_EXPORT t_ctx_grouped_pkey : public t_ctxbase { public: - t_ctx_grouped_pkey(); + t_ctx_grouped_pkey(); + t_ctx_grouped_pkey(t_schema schema, t_config config); ~t_ctx_grouped_pkey(); diff --git a/src/include/perspective/first.h b/src/include/perspective/first.h index 0af9064042..9f720069a0 100644 --- a/src/include/perspective/first.h +++ b/src/include/perspective/first.h @@ -8,8 +8,10 @@ */ #ifndef PSP_ENABLE_WASM +#ifndef PSP_PARALLEL_FOR #define PSP_PARALLEL_FOR #endif +#endif #if !defined(__linux__) && !defined(__APPLE__) && !defined(WIN32) // default to linux diff --git a/src/include/perspective/table.h b/src/include/perspective/table.h index e8cd05e398..75a8b9b3aa 100644 --- a/src/include/perspective/table.h +++ b/src/include/perspective/table.h @@ -160,7 +160,7 @@ class PERSPECTIVE_EXPORT t_table { bool m_from_recipe; }; -bool operator==(const t_table& lhs, const t_table& rhs); +PERSPECTIVE_EXPORT bool operator==(const t_table& lhs, const t_table& rhs); template void diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 51adc195d5..1a05deeb5f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,5 +6,9 @@ set (TEST_FILES include_directories("include") add_executable(psp_test ${TEST_FILES}) -target_link_libraries(psp_test gtest_main tbb psp) +if(WIN32) + target_compile_definitions(psp_test PRIVATE WIN32=1) +endif() + +target_link_libraries(psp_test psp gtest_main tbb ) add_test(NAME psptest COMMAND psp_test) diff --git a/test/cpp/psp.cpp b/test/cpp/psp.cpp index 1e3932833d..42aa247601 100644 --- a/test/cpp/psp.cpp +++ b/test/cpp/psp.cpp @@ -7,6 +7,7 @@ * */ +#include #include int diff --git a/test/cpp/simple.cpp b/test/cpp/simple.cpp index caf87aed26..824989e413 100644 --- a/test/cpp/simple.cpp +++ b/test/cpp/simple.cpp @@ -6,13 +6,13 @@ * the Apache License 2.0. The full license can be found in the LICENSE file. * */ - #include #include #include #include #include #include +#include #include #include #include @@ -32,158 +32,6 @@ using namespace perspective; -t_tscalar bnull = mknull(DTYPE_BOOL); -t_tscalar snull = mknull(DTYPE_STR); -t_tscalar i64_null = mknull(DTYPE_INT64); - -t_tscalar s_true = mktscalar(true); -t_tscalar s_false = mktscalar(false); -t_tscalar s_none = mktscalar(t_none()); -t_tscalar iop = mktscalar(OP_INSERT); -t_tscalar dop = mktscalar(OP_DELETE); -t_tscalar cop = mktscalar(OP_CLEAR); -t_tscalar s_nan32 = mktscalar(std::numeric_limits::quiet_NaN()); -t_tscalar s_nan64 = mktscalar(std::numeric_limits::quiet_NaN()); -t_tscalar i64_clear = mkclear(DTYPE_INT64); -t_tscalar f64_clear = mkclear(DTYPE_FLOAT64); -t_tscalar str_clear = mkclear(DTYPE_STR); - -std::vector numeric_dtypes{ - DTYPE_INT64, - DTYPE_INT32, - DTYPE_INT16, - DTYPE_INT8, - DTYPE_UINT64, - DTYPE_UINT32, - DTYPE_UINT16, - DTYPE_UINT8, - DTYPE_FLOAT64, - DTYPE_FLOAT32, -}; - -std::vector common_dtypes{ - DTYPE_NONE, - DTYPE_INT64, - DTYPE_INT32, - DTYPE_INT16, - DTYPE_INT8, - DTYPE_UINT64, - DTYPE_UINT32, - DTYPE_UINT16, - DTYPE_UINT8, - DTYPE_FLOAT64, - DTYPE_FLOAT32, - DTYPE_BOOL, - DTYPE_TIME, - DTYPE_DATE, - DTYPE_STR, -}; - -template -struct test_traits -{ - typedef DATA_T t_data; - typedef typename t_accumulation_type::type t_accum_type; - static const perspective::t_dtype dtype; - static const perspective::t_tscalar null; - static const perspective::t_tscalar clear; - static const perspective::t_tscalar zero; - static const perspective::t_tscalar v1; - static const perspective::t_tscalar v2; - - static t_tscalar - acc_s(std::int64_t v) - { - t_accum_type v_(v); - return mktscalar(v); - } -}; - - -// String specializations -template <> -const perspective::t_tscalar test_traits::zero; -template <> -const perspective::t_tscalar test_traits::v1; -template <> -const perspective::t_tscalar test_traits::v2; -// Date specializations -template <> -const perspective::t_tscalar test_traits::zero; -template <> -const perspective::t_tscalar test_traits::v1; -template <> -const perspective::t_tscalar test_traits::v2; -// Time specializations -template <> -const perspective::t_tscalar test_traits::zero; -template <> -const perspective::t_tscalar test_traits::v1; -template <> -const perspective::t_tscalar test_traits::v2; - -template -const perspective::t_dtype test_traits::dtype = type_to_dtype(); - -template -const perspective::t_tscalar test_traits::null = perspective::mknull(test_traits::dtype); - -template -const perspective::t_tscalar test_traits::clear = perspective::mkclear(test_traits::dtype); - -template -const perspective::t_tscalar test_traits::zero - = perspective::mktscalar(0); -template -const perspective::t_tscalar test_traits::v1 - = perspective::mktscalar(1); -template -const perspective::t_tscalar test_traits::v2 - = perspective::mktscalar(2); - -// String specializations -template <> -const t_tscalar test_traits::zero = mktscalar(""); -template <> -const t_tscalar test_traits::v1 = mktscalar("1"); -template <> -const t_tscalar test_traits::v2 = mktscalar("2"); - -// Date specializations -template <> -const t_tscalar test_traits::zero = mktscalar(t_date()); -template <> -const t_tscalar test_traits::v1 = mktscalar(t_date(2018, 1, 1)); -template <> -const t_tscalar test_traits::v2 = mktscalar(t_date(2018, 1, 1)); - -// Time specializations -template <> -const t_tscalar test_traits::zero = mktscalar(t_time(0)); -template <> -const t_tscalar test_traits::v1 = mktscalar(t_time(100000)); -template <> -const t_tscalar test_traits::v2 = mktscalar(t_time(200000)); - -typedef test_traits tr_i64; -typedef test_traits tr_i32; -typedef test_traits tr_i16; -typedef test_traits tr_i8; -typedef test_traits tr_u64; -typedef test_traits tr_u32; -typedef test_traits tr_u16; -typedef test_traits tr_u8; -typedef test_traits tr_float64; -typedef test_traits tr_float32; - -typedef test_traits tr_date; -typedef test_traits tr_time; -typedef test_traits tr_str; -typedef test_traits tr_bool; - -typedef ::testing::Types - tl_numeric_types; - TEST(TABLE, simplest_test) { t_table tbl(t_schema({"a", "b"}, {DTYPE_INT64, DTYPE_FLOAT64}), 5); @@ -196,7 +44,9 @@ TEST(GNODE, explicit_pkey) t_gnode_options options; options.m_gnode_type = GNODE_TYPE_PKEYED; options.m_port_schema = t_schema{{"x"}, {DTYPE_INT64}}; +#ifndef WIN32 EXPECT_EXIT(t_gnode::build(options), ::testing::KilledBySignal(SIGINT), ""); +#endif } @@ -207,7 +57,9 @@ TEST(GNODE, implicit_pkey) options.m_port_schema = t_schema{ {"psp_op", "psp_pkey", "x"}, {DTYPE_UINT8, DTYPE_INT64, DTYPE_INT64}}; - EXPECT_EXIT(t_gnode::build(options), ::testing::KilledBySignal(SIGINT), ""); +#ifndef WIN32 + EXPECT_EXIT(t_gnode::build(options), ::testing::KilledBySignal(SIGINT), ""); +#endif } TEST(SCALAR, scalar_literal_test) @@ -1320,7 +1172,7 @@ TEST_F(F64Ctx1JoinTest, test_2) { { {{iop, 1_ts, 1_ts, 1_ts}, {iop, 2_ts, 1_ts, 2_ts}}, - {"Grand Aggregate"_ts, "2, 1, "_ts, 1_ts, "2, 1, "_ts } + {"Grand Aggregate"_ts, "1, 2, "_ts, 1_ts, "1, 2, "_ts } } }; diff --git a/test/include/perspective/simple.h b/test/include/perspective/simple.h new file mode 100644 index 0000000000..8aae9510cd --- /dev/null +++ b/test/include/perspective/simple.h @@ -0,0 +1,159 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace perspective{ + +t_tscalar bnull = mknull(DTYPE_BOOL); +t_tscalar snull = mknull(DTYPE_STR); +t_tscalar i64_null = mknull(DTYPE_INT64); + +t_tscalar s_true = mktscalar(true); +t_tscalar s_false = mktscalar(false); +t_tscalar s_none = mktscalar(t_none()); +t_tscalar iop = mktscalar(OP_INSERT); +t_tscalar dop = mktscalar(OP_DELETE); +t_tscalar cop = mktscalar(OP_CLEAR); +t_tscalar s_nan32 = mktscalar(std::numeric_limits::quiet_NaN()); +t_tscalar s_nan64 = mktscalar(std::numeric_limits::quiet_NaN()); +t_tscalar i64_clear = mkclear(DTYPE_INT64); +t_tscalar f64_clear = mkclear(DTYPE_FLOAT64); +t_tscalar str_clear = mkclear(DTYPE_STR); + +std::vector numeric_dtypes{ + DTYPE_INT64, + DTYPE_INT32, + DTYPE_INT16, + DTYPE_INT8, + DTYPE_UINT64, + DTYPE_UINT32, + DTYPE_UINT16, + DTYPE_UINT8, + DTYPE_FLOAT64, + DTYPE_FLOAT32, +}; + +std::vector common_dtypes{ + DTYPE_NONE, + DTYPE_INT64, + DTYPE_INT32, + DTYPE_INT16, + DTYPE_INT8, + DTYPE_UINT64, + DTYPE_UINT32, + DTYPE_UINT16, + DTYPE_UINT8, + DTYPE_FLOAT64, + DTYPE_FLOAT32, + DTYPE_BOOL, + DTYPE_TIME, + DTYPE_DATE, + DTYPE_STR, +}; + +template +struct test_traits +{ + typedef DATA_T t_data; + typedef typename t_accumulation_type::type t_accum_type; + static const perspective::t_dtype dtype; + static const perspective::t_tscalar null; + static const perspective::t_tscalar clear; + static const perspective::t_tscalar zero; + static const perspective::t_tscalar v1; + static const perspective::t_tscalar v2; + + static t_tscalar + acc_s(std::int64_t v) + { + t_accum_type v_(v); + return mktscalar(v); + } +}; + + + +template +const perspective::t_dtype test_traits::dtype = type_to_dtype(); + +template +const perspective::t_tscalar test_traits::null = perspective::mknull(test_traits::dtype); + +template +const perspective::t_tscalar test_traits::clear = perspective::mkclear(test_traits::dtype); + +template +const perspective::t_tscalar test_traits::zero + = perspective::mktscalar(0); +template +const perspective::t_tscalar test_traits::v1 + = perspective::mktscalar(1); +template +const perspective::t_tscalar test_traits::v2 + = perspective::mktscalar(2); + +// String specializations +template <> +const t_tscalar test_traits::zero = mktscalar(""); +template <> +const t_tscalar test_traits::v1 = mktscalar("1"); +template <> +const t_tscalar test_traits::v2 = mktscalar("2"); + +// Date specializations +template <> +const t_tscalar test_traits::zero = mktscalar(t_date()); +template <> +const t_tscalar test_traits::v1 = mktscalar(t_date(2018, 1, 1)); +template <> +const t_tscalar test_traits::v2 = mktscalar(t_date(2018, 1, 1)); + +// Time specializations +template <> +const t_tscalar test_traits::zero = mktscalar(t_time(0)); +template <> +const t_tscalar test_traits::v1 = mktscalar(t_time(100000)); +template <> +const t_tscalar test_traits::v2 = mktscalar(t_time(200000)); + +typedef test_traits tr_i64; +typedef test_traits tr_i32; +typedef test_traits tr_i16; +typedef test_traits tr_i8; +typedef test_traits tr_u64; +typedef test_traits tr_u32; +typedef test_traits tr_u16; +typedef test_traits tr_u8; +typedef test_traits tr_float64; +typedef test_traits tr_float32; + +typedef test_traits tr_date; +typedef test_traits tr_time; +typedef test_traits tr_str; +typedef test_traits tr_bool; + +typedef ::testing::Types + tl_numeric_types; +} \ No newline at end of file diff --git a/test/include/perspective/test_utils.h b/test/include/perspective/test_utils.h index db6e0cd06d..41b8cb196e 100644 --- a/test/include/perspective/test_utils.h +++ b/test/include/perspective/test_utils.h @@ -8,6 +8,7 @@ */ #pragma once +#include #include #include #include