Skip to content

Commit

Permalink
Move RAFT_INLINE_CONDITIONAL to macros.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
ahendriksen committed Apr 27, 2023
1 parent 2937ad6 commit 7cdef04
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 40 deletions.
22 changes: 21 additions & 1 deletion cpp/include/raft/core/detail/macros.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,26 @@
#define RAFT_INLINE_FUNCTION _RAFT_HOST_DEVICE _RAFT_FORCEINLINE
#endif

// The RAFT_INLINE_CONDITIONAL is a conditional inline specifier that removes
// the inline specification when RAFT_COMPILED is defined.
//
// When RAFT_COMPILED is not defined, functions may be defined in multiple
// translation units and we do not want that to lead to linker errors.
//
// When RAFT_COMPILED is defined, this serves two purposes:
//
// 1. It triggers a multiple definition error message when memory_pool-inl.hpp
// (for instance) is accidentally included in multiple translation units.
//
// 2. We function definitions to be non-inline, because non-inline functions
// symbols are always exported in the object symbol table. For inline functions,
// the compiler may elide the external symbol, which results in linker errors.
#ifdef RAFT_COMPILED
#define RAFT_INLINE_CONDITIONAL
#else
#define RAFT_INLINE_CONDITIONAL inline
#endif // RAFT_COMPILED

/**
* Some macro magic to remove optional parentheses of a macro argument.
* See https://stackoverflow.com/a/62984543
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/core/logger-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#define SPDLOG_HEADER_ONLY
#include <raft/core/detail/callback_sink.hpp>
#include <raft/util/inline.hpp> // RAFT_INLINE_CONDITIONAL
#include <raft/core/detail/macros.hpp> // RAFT_INLINE_CONDITIONAL
#include <spdlog/sinks/stdout_color_sinks.h> // NOLINT
#include <spdlog/spdlog.h> // NOLINT

Expand Down
37 changes: 0 additions & 37 deletions cpp/include/raft/util/inline.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/include/raft/util/memory_pool-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <cstddef>
#include <memory>

#include <raft/util/inline.hpp> // RAFT_INLINE_CONDITIONAL
#include <raft/core/detail/macros.hpp> // RAFT_INLINE_CONDITIONAL
#include <rmm/mr/device/managed_memory_resource.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/mr/device/pool_memory_resource.hpp>
Expand Down

0 comments on commit 7cdef04

Please sign in to comment.