Skip to content

Commit

Permalink
add cmake support for precompiled headers
Browse files Browse the repository at this point in the history
  • Loading branch information
vigsterkr committed Dec 24, 2019
1 parent 062d70c commit 1a2c793
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 94 deletions.
6 changes: 1 addition & 5 deletions cmake/FindCCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ endif()

# handle REQUIRED and QUIET options
include(FindPackageHandleStandardArgs)
if (CMAKE_VERSION LESS 2.8.3)
find_package_handle_standard_args(CCache DEFAULT_MSG CCACHE CCACHE_VERSION)
else ()
find_package_handle_standard_args(CCache REQUIRED_VARS CCACHE CCACHE_VERSION)
endif ()
find_package_handle_standard_args(CCache REQUIRED_VARS CCACHE CCACHE_VERSION)

if (CCACHE_FOUND)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
Expand Down
44 changes: 44 additions & 0 deletions src/shogun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,50 @@ IF(MSVC)
target_link_libraries(shogun_deps INTERFACE winmm Shlwapi)
ENDIF()

########################### PCH
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0)
if (CCACHE_FOUND)
if (DEFINED ENV{CCACHE_SLOPPINESS})
if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR
NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros")
MESSAGE (WARNING
"ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"."
)
SET(CCACHE_PCH_READY 0)
else()
SET(CCACHE_PCH_READY 1)
endif()
else()
execute_process(
COMMAND "${COMPILER_CACHE_EXECUTABLE}" "-p"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
RESULT_VARIABLE _result
OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (_result)
MESSAGE (WARNING "ccache configuration cannot be determined.")
SET(CCACHE_PCH_READY 0)
elseif (NOT _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR
NOT _ccacheConfig MATCHES "sloppiness.*=.*pch_defines")
MESSAGE (WARNING
"ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"."
)
SET(CCACHE_PCH_READY 0)
else()
SET(CCACHE_PCH_READY 1)
endif()
endif()

endif()

if (NOT CCACHE_FOUND OR ${CCACHE_PCH_READY})
# FIXME: make sure all the headers are listed that could be precompiled
target_precompile_headers(libshogun
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${LIBSHOGUN_HEADERS}>")
endif()
endif()


########################### compiler capabilities
FIND_PACKAGE(Threads)
IF (CMAKE_USE_PTHREADS_INIT)
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/distributions/DiscreteDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class DiscreteDistribution : public Distribution
*
* @param alpha_k "belongingness" values of various data points
*/
virtual void update_params_em(const SGVector<float64_t> alpha_k)=0;
virtual float64_t update_params_em(const SGVector<float64_t> alpha_k)=0;
};
}
#endif /* _DISCRETEDISTRIBUTION_H__ */
24 changes: 12 additions & 12 deletions src/shogun/io/fs/NullFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,50 @@ namespace shogun

~NullFileSystem() override = default;

std::unique_ptr<RandomAccessFile> new_random_access_file(
const std::string& fname) override
std::error_condition new_random_access_file(
const std::string& fname, std::unique_ptr<RandomAccessFile>*) const override
{
throw ShogunNotImplementedException("new_random_access_file unimplemented");
}

std::unique_ptr<WritableFile> new_writable_file(
const std::string& fname) override
std::error_condition new_writable_file(
const std::string& fname, std::unique_ptr<WritableFile>*) const override
{
throw ShogunNotImplementedException("NewWritableFile new_writable_file");
}

std::unique_ptr<WritableFile> new_appendable_file(
const std::string& fname) override
std::error_condition new_appendable_file(
const std::string& fname, std::unique_ptr<WritableFile>*) const override
{
throw ShogunNotImplementedException("new_appendable_file unimplemented");
}

bool file_exists(const std::string& fname) override
std::error_condition file_exists(const std::string& fname) const override
{
throw ShogunNotImplementedException("file_exists unimplemented");
}

void delete_file(const std::string& fname) override
std::error_condition delete_file(const std::string& fname) const override
{
throw ShogunNotImplementedException("delete_file unimplemented");
}

void create_dir(const std::string& dirname) override
std::error_condition create_dir(const std::string& dirname) const override
{
throw ShogunNotImplementedException("create_dir unimplemented");
}

void delete_dir(const std::string& dirname) override
std::error_condition delete_dir(const std::string& dirname) const override
{
throw ShogunNotImplementedException("delete_dir unimplemented");
}

int64_t get_file_size(const std::string& fname) override
int64_t get_file_size(const std::string& fname) const override
{
throw ShogunNotImplementedException("get_file_size unimplemented");
}

void rename_file(const std::string& src, const std::string& target) override
std::error_condition rename_file(const std::string& src, const std::string& target) const override
{
throw ShogunNotImplementedException("rename_file unimplemented");
}
Expand Down
97 changes: 50 additions & 47 deletions src/shogun/io/stream/BufferedOutputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,67 @@

namespace shogun
{
IGNORE_IN_CLASSLIST class BufferedOutputStream : public OutputStream
namespace io
{
public:
/**
* Construct a buffered output stream
*
* @param os
* @param buffer_bytes
*/
BufferedOutputStream(std::shared_ptr<OutputStream> os, index_t buffer_bytes = 4096):
OutputStream(), m_os(std::move(os))
IGNORE_IN_CLASSLIST class BufferedOutputStream : public OutputStream
{
public:
/**
* Construct a buffered output stream
*
* @param os
* @param buffer_bytes
*/
BufferedOutputStream(std::shared_ptr<OutputStream> os, index_t buffer_bytes = 4096):
OutputStream(), m_os(std::move(os))
{

}
}

BufferedOutputStream(BufferedOutputStream&& src):
OutputStream(), m_os(std::move(src.m_os))
{
src.m_os = nullptr;
}
BufferedOutputStream(BufferedOutputStream&& src):
OutputStream(), m_os(std::move(src.m_os))
{
src.m_os = nullptr;
}

BufferedOutputStream& operator=(BufferedOutputStream&& src)
{
m_os = std::move(src.m_os);
return *this;
}
BufferedOutputStream& operator=(BufferedOutputStream&& src)
{
m_os = std::move(src.m_os);
return *this;
}

~BufferedOutputStream() override
{
m_os->flush();
m_os->close();
}
~BufferedOutputStream() override
{
m_os->flush();
m_os->close();
}

std::error_condition write(void* buffer, int64_t size) override
{
m_os->write(buffer, size);
}
std::error_condition write(const void* buffer, int64_t size) override
{
m_os->write(buffer, size);
}

std::error_condition close() override
{
m_os->close();
}
std::error_condition close() override
{
m_os->close();
}

std::error_condition flush() override
{
m_os->flush();
}
std::error_condition flush() override
{
m_os->flush();
}

const char* get_name() const override
{
return "BufferedOutputStream";
}
const char* get_name() const override
{
return "BufferedOutputStream";
}

private:
std::shared_ptr<OutputStream> m_os;
private:
std::shared_ptr<OutputStream> m_os;

SG_DELETE_COPY_AND_ASSIGN(BufferedOutputStream);
};
}
SG_DELETE_COPY_AND_ASSIGN(BufferedOutputStream);
};
} // namespace io
} // namespace shogun

#endif /* __BUFFERED_OUTPUT_STREAM_H__ */
4 changes: 4 additions & 0 deletions src/shogun/lib/external/falconn/ffht/fht_impl.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _FHT_IMPL_H
#define _FHT_IMPL_H

#ifdef __AVX__
#include <immintrin.h>
#endif
Expand Down Expand Up @@ -544,3 +547,4 @@ void FHTFloatIterativeLongHelperAVX(float *buffer, int len, int logLen) {
}

#endif
#endif
Loading

0 comments on commit 1a2c793

Please sign in to comment.