Skip to content

Commit 4205a93

Browse files
committed
use DTO_API define to make API path independent of transparent intercept
1 parent 80aa2ce commit 4205a93

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

cachelib/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,23 @@ if (BUILD_WITH_DTO)
5050
find_package(DTO REQUIRED)
5151
if (DTO_FOUND)
5252
message(STATUS "DTO found, remember to configure DSA devices for acceleration. If no DSA device is found, cachelib will fallback to software path.")
53-
add_compile_definitions(HAVE_DTO)
5453
endif()
5554
endif ()
5655

56+
include(CMakeDependentOption)
57+
# USE_DTO_API is only meaningful if BUILD_WITH_DTO is ON *and* DTO was found
58+
cmake_dependent_option(
59+
USE_DTO_API
60+
"Use DTO library API functions for DSA acceleration."
61+
OFF
62+
"BUILD_WITH_DTO;DTO_FOUND"
63+
OFF
64+
)
65+
if (USE_DTO_API)
66+
message(STATUS "Using DTO API for offloading")
67+
add_compile_definitions(DTO_API)
68+
endif()
69+
5770

5871
set(BIN_INSTALL_DIR bin CACHE STRING
5972
"The subdirectory where binaries should be installed")

cachelib/cachebench/runner/CacheStressor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <thread>
2929
#include <unordered_set>
3030

31-
#ifdef HAVE_DTO
31+
#ifdef DTO_API
3232
#include <dto.h>
3333
#define DTO_DSA_MIN_THRESHOLD (32 * 1024)
3434
#endif
@@ -48,7 +48,7 @@ namespace cachebench {
4848

4949
constexpr uint32_t kNvmCacheWarmUpCheckRate = 1000;
5050

51-
#ifdef HAVE_DTO
51+
#ifdef DTO_API
5252
void async_memcpy_callback(void *arg) {
5353
auto &fn = *reinterpret_cast<std::function<void(void)>*>(arg);
5454
fn();
@@ -505,7 +505,7 @@ class CacheStressor : public Stressor {
505505
++stats.setFailure;
506506
return OpResultType::kSetFailure;
507507
} else {
508-
#ifdef HAVE_DTO
508+
#ifdef DTO_API
509509
if (config_.useDTOAsync && size >= DTO_DSA_MIN_THRESHOLD) {
510510
auto insertToCache = [&] {
511511
cache_->insertOrReplace(it);

cachelib/navy/block_cache/BlockCache.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <cstring>
2424
#include <utility>
2525

26-
#ifdef HAVE_DTO
26+
#ifdef DTO_API
2727
#include <dto.h>
2828
#endif
2929

@@ -35,7 +35,7 @@
3535

3636
namespace facebook::cachelib::navy {
3737

38-
#ifdef HAVE_DTO
38+
#ifdef DTO_API
3939
void async_memcpy_crc_cb(void *arg) {
4040
auto &fn = *reinterpret_cast<std::function<void(void)>*>(arg);
4141
fn();
@@ -714,7 +714,7 @@ Status BlockCache::writeEntry(RelAddress addr,
714714
auto desc = new (buffer.data() + descOffset)
715715
EntryDesc(hk.key().size(), value.size(), hk.keyHash());
716716
if (checksumData_) {
717-
#ifdef HAVE_DTO
717+
#ifdef DTO_API
718718
auto keyCopy = [hk, descOffset, &buffer]() {
719719
// Copy the key to the buffer at the end
720720
buffer.copyFrom(descOffset - hk.key().size(), makeView(hk.key()));

cachelib/navy/common/Hash.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "cachelib/navy/common/Hash.h"
1818

1919
#include <folly/hash/Checksum.h>
20-
#ifdef HAVE_DTO
20+
#ifdef DTO_API
2121
#include <dto.h>
2222
#endif
2323

@@ -27,7 +27,7 @@ uint64_t hashBuffer(BufferView key, uint64_t seed) {
2727
}
2828

2929
uint32_t checksum(BufferView data, uint32_t startingChecksum) {
30-
#ifdef HAVE_DTO
30+
#ifdef DTO_API
3131
return dto_crc(data.data(), data.size(), nullptr, nullptr);
3232
#else
3333
return folly::crc32(data.data(), data.size(), startingChecksum);

0 commit comments

Comments
 (0)