<commit_before>cmake_minimum_required (VERSION 3.5.0)

project (bpmf)

# OPTIONS

OPTION(ENABLE_PROFILING "Enable performance counters" OFF)
OPTION(ENABLE_ASAN "Enable address sanitizer" OFF)
OPTION(ENABLE_TSAN "Enable thread sanitizer" OFF)

OPTION(ENABLE_OPENMP "Enable OpenMP Support" ON)
OPTION(ENABLE_REDUCE "Reduce Mu/Lambda version" OFF)

SET(BPMF_NUMLATENT 32 CACHE INT "Number of latent dimensions") 

SET(BPMF_COMM "NO_COMM" CACHE STRING "Communication library used")
SET_PROPERTY(CACHE BPMF_COMM PROPERTY STRINGS 
  GPI_COMM 
  MPI_ISEND_COMM 
  MPI_PUT_COMM 
  MPI_ALLREDUCE_COMM 
  MPI_BCAST_COMM 
  NO_COMM)


set(CMAKE_CXX_STANDARD 14)

# suppress some pesky Eigen 3.3.7 warnings
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-in-bool-context")
endif()

if (ENABLE_ASAN)
  add_compile_options(-fno-omit-frame-pointer -fsanitize=address)
  add_link_options(-fno-omit-frame-pointer -fsanitize=address)
endif()

if (ENABLE_TSAN)
  add_compile_options(-fno-omit-frame-pointer -fsanitize=thread)
  add_link_options(-fno-omit-frame-pointer -fsanitize=thread)
endif()

execute_process(
  COMMAND git describe
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  RESULT_VARIABLE BPMF_VERSION_ERROR
  OUTPUT_VARIABLE BPMF_VERSION
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT "${BPMF_VERSION_ERROR}" STREQUAL "0")
   set(BPMF_VERSION "Unknown")
endif()

message(STATUS "Version from git: ${BPMF_VERSION}")
message(STATUS "num-latent: ${BPMF_NUMLATENT}")
message(STATUS "comm: ${BPMF_COMM}")

add_definitions(-DBPMF_VERSION=\"${BPMF_VERSION}\")
add_definitions(-DBPMF_NUMLATENT=${BPMF_NUMLATENT})
add_definitions(-DBPMF_${BPMF_COMM})
if (ENABLE_REDUCE)
  add_definitions(-DBPMF_REDUCE)
endif()

find_package(Eigen3 REQUIRED)
find_library(z REQUIRED)

if(${ENABLE_PROFILING})
    add_definitions(-DBPMF_PROFILING)
endif()

include_directories(c++)

FILE (GLOB SOURCE_FILES "c++/*.cpp" "c++/*.h")

add_executable (bpmf ${SOURCE_FILES})
target_link_libraries (bpmf Eigen3::Eigen z)

if(ENABLE_OPENMP)
  find_package(OpenMP REQUIRED)
  target_link_libraries(bpmf OpenMP::OpenMP_CXX)
endif()

if(BPMF_COMM MATCHES ^.PI)
  find_package(MPI REQUIRED COMPONENTS CXX)
  set(MPIRUN mpirun -np 4)
  target_link_libraries (bpmf MPI::MPI_CXX)
  if(BPMF_COMM MATCHES ^GPI)
    find_path(GASPI_INCLUDE_DIR GASPI.h REQUIRED)
    include_directories(${GASPI_INCLUDE_DIR})<commit_msg>ENH: use find_package for zlib<commit_after>cmake_minimum_required (VERSION 3.5.0)

project (bpmf)

# OPTIONS

OPTION(ENABLE_PROFILING "Enable performance counters" OFF)
OPTION(ENABLE_ASAN "Enable address sanitizer" OFF)
OPTION(ENABLE_TSAN "Enable thread sanitizer" OFF)

OPTION(ENABLE_OPENMP "Enable OpenMP Support" ON)
OPTION(ENABLE_REDUCE "Reduce Mu/Lambda version" OFF)

SET(BPMF_NUMLATENT 32 CACHE INT "Number of latent dimensions") 

SET(BPMF_COMM "NO_COMM" CACHE STRING "Communication library used")
SET_PROPERTY(CACHE BPMF_COMM PROPERTY STRINGS 
  GPI_COMM 
  MPI_ISEND_COMM 
  MPI_PUT_COMM 
  MPI_ALLREDUCE_COMM 
  MPI_BCAST_COMM 
  NO_COMM)


set(CMAKE_CXX_STANDARD 14)

# suppress some pesky Eigen 3.3.7 warnings
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-in-bool-context")
endif()

if (ENABLE_ASAN)
  add_compile_options(-fno-omit-frame-pointer -fsanitize=address)
  add_link_options(-fno-omit-frame-pointer -fsanitize=address)
endif()

if (ENABLE_TSAN)
  add_compile_options(-fno-omit-frame-pointer -fsanitize=thread)
  add_link_options(-fno-omit-frame-pointer -fsanitize=thread)
endif()

execute_process(
  COMMAND git describe
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  RESULT_VARIABLE BPMF_VERSION_ERROR
  OUTPUT_VARIABLE BPMF_VERSION
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT "${BPMF_VERSION_ERROR}" STREQUAL "0")
   set(BPMF_VERSION "Unknown")
endif()

message(STATUS "Version from git: ${BPMF_VERSION}")
message(STATUS "num-latent: ${BPMF_NUMLATENT}")
message(STATUS "comm: ${BPMF_COMM}")

add_definitions(-DBPMF_VERSION=\"${BPMF_VERSION}\")
add_definitions(-DBPMF_NUMLATENT=${BPMF_NUMLATENT})
add_definitions(-DBPMF_${BPMF_COMM})
if (ENABLE_REDUCE)
  add_definitions(-DBPMF_REDUCE)
endif()

find_package(Eigen3 REQUIRED)
find_package(ZLIB REQUIRED)

if(${ENABLE_PROFILING})
    add_definitions(-DBPMF_PROFILING)
endif()

include_directories(c++)

FILE (GLOB SOURCE_FILES "c++/*.cpp" "c++/*.h")

add_executable (bpmf ${SOURCE_FILES})
target_link_libraries (bpmf Eigen3::Eigen ZLIB::ZLIB)

if(ENABLE_OPENMP)
  find_package(OpenMP REQUIRED)
  target_link_libraries(bpmf OpenMP::OpenMP_CXX)
endif()

if(BPMF_COMM MATCHES ^.PI)
  find_package(MPI REQUIRED COMPONENTS CXX)
  set(MPIRUN mpirun -np 4)
  target_link_libraries (bpmf MPI::MPI_CXX)
  if(BPMF_COMM MATCHES ^GPI)
    find_path(GASPI_INCLUDE_DIR GASPI.h REQUIRED)
    include_directories(${GASPI_INCLUDE_DIR})
{'fraction_non_alphanumeric': 0.10495449949443883, 'fraction_numerical': 0.006471183013144591, 'mean_word_length': 6.93900481540931, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '293515', 'n_tokens_mistral': 2087, 'n_tokens_neox': 1954, 'n_words': 345}