Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize std::filesystem #311

Merged
merged 8 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ endif ()
# -------------------------------------------------------------------------------- #

# -------------------------------------------------------------------------------- #
# Executables
# Set up for building executables
# -------------------------------------------------------------------------------- #

# Requirements for GCC
Expand Down Expand Up @@ -169,12 +169,8 @@ find_package(Threads REQUIRED)


# ---------- filesystem ---------- #
include(include_cxx_filesystem_library)
include_cxx_filesystem_library()

# Xcode 11 Beta Release Notes
# Clang now supports the C++17 <filesystem> library for iOS 13, macOS 10.15, watchOS 6, and tvOS 13. (50988273)
# https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes?language=objc
include(check_cxx_filesystem_library)
check_cxx_filesystem_library()


# ---------- UMap ---------- #
Expand All @@ -198,7 +194,7 @@ set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.64 QUIET)
if (NOT Boost_FOUND)
FetchContent_Declare(Boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.78.0/source/boost_1_78_0.tar.bz2)
URL https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.bz2)
FetchContent_GetProperties(Boost)
if (NOT Boost_POPULATED)
FetchContent_Populate(Boost)
Expand Down Expand Up @@ -258,13 +254,11 @@ function(common_setup_for_metall_executable name)
# --------------------

# ----- CXX17 Filesystem Lib----- #
# include_cxx_filesystem_library module must be executed first
if (FOUND_CXX17_FILESYSTEM_LIB)
if (REQUIRE_LIB_STDCXX_FS)
# GNU compilers prior to 9.1 requires linking with stdc++fs
if (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1)
target_link_libraries(${name} PRIVATE stdc++fs)
endif ()
elseif ()
target_compile_definitions(${name} PRIVATE "METALL_DISABLE_CXX17_FILESYSTEM_LIB")
endif ()
# --------------------

Expand Down
2 changes: 1 addition & 1 deletion bench/bfs/run_bfs_bench_metall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
// metall::logger::set_log_level(metall::logger::level::verbose);

metall::manager manager(metall::open_read_only,
option.graph_file_name_list[0].c_str());
option.graph_file_name_list[0]);
auto adj_list =
manager.find<adjacency_list_type>(option.graph_key_name.c_str()).first;

Expand Down
2 changes: 1 addition & 1 deletion bench/bfs/run_bfs_bench_metall_multiple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
std::vector<metall::manager *> managers;
for (const auto &file_name : option.graph_file_name_list) {
managers.emplace_back(
new metall::manager(metall::open_read_only, file_name.c_str()));
new metall::manager(metall::open_read_only, file_name));
}

auto adj_list = adjacency_list_type(option.graph_key_name, managers.begin(),
Expand Down
2 changes: 1 addition & 1 deletion bench/simple_alloc/run_simple_allocation_bench_metall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
int main(int argc, char *argv[]) {
const auto option = simple_alloc_bench::parse_option(argc, argv);
{
metall::manager manager(metall::create_only, option.datastore_path.c_str());
metall::manager manager(metall::create_only, option.datastore_path);
simple_alloc_bench::run_bench(option, manager.get_allocator<std::byte>());
}
metall::manager::remove(option.datastore_path.c_str());
Expand Down
25 changes: 25 additions & 0 deletions cmake/check_cxx_filesystem_library.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Checks if the C++17 <filesystem> library is available.
function(check_cxx_filesystem_library)

set(FOUND_CXX17_FILESYSTEM_LIB FALSE PARENT_SCOPE)
set(REQUIRE_LIB_STDCXX_FS FALSE PARENT_SCOPE)

# Check if C++17 <filesystem> header files are available
# If not, uses our own implementation.
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX(filesystem FOUND_FILESYSTEM_HEADER)
if (NOT FOUND_FILESYSTEM_HEADER)
message(FATAL_ERROR "Cannot find the C++17 <filesystem> library.")
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang or AppleClang
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") # macOS
include(get_macos_version)
get_macos_version() # Get macOS version
message(VERBOSE "Detected macOS version ${MACOS_VERSION}")
if (MACOS_VERSION VERSION_LESS 10.15) # macOS < 10.15
message(FATAL_ERROR "macOS >= 10.15 is required to use the C++17 <filesystem> library.")
endif ()
endif ()
endif ()
endfunction()
40 changes: 0 additions & 40 deletions cmake/include_cxx_filesystem_library.cmake

This file was deleted.

17 changes: 3 additions & 14 deletions docs/readthedocs/basics/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,11 @@ g++ -std=c++17 your_program.cpp -lstdc++fs -I${BOOST_ROOT}/include -I${METALL_RO

Clang (or Apple clang) could be used instead of GCC to build Metall.
However, we haven't tested it intensively.
To run on macOS, Metall requires macOS >= 10.15.

Also, Boost C++ Libraries 1.69 or more may be required
if one wants to build Metall with Clang + CUDA.

**On macOS >= 10.15 or Linux**

```bash
# Remove "-lstdc++fs" option
clang++ -std=c++17 [tutorial_program.cpp] -I../../include -I${BOOST_ROOT}
```

**On macOS < 10.15**

The C++17 <filesystem> library is not available on macOS < 10.15.
One has to stop using C++17 <filesystem> library in Metall.
If METALL_DISABLE_CXX17_FILESYSTEM_LIB macro is defined, Metall uses its own file system operation implementation.

```bash
clang++ -std=c++17 [tutorial_program.cpp] -I../../include -I${BOOST_ROOT} -DMETALL_DISABLE_CXX17_FILESYSTEM_LIB
```
```
Loading