Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8cea448
update nixlbench/kvbench docs
cheese-head Jul 7, 2025
2350566
updated readme
cheese-head Jul 7, 2025
d63db69
update readme
cheese-head Jul 7, 2025
0a489af
update tutorial for gds
cheese-head Jul 7, 2025
1785ac3
apply lint rules
cheese-head Jul 7, 2025
26dab77
Merge branch 'ai-dynamo:main' into cheese-head/update-nixlbench-docs
cheese-head Jul 8, 2025
3f5eac1
isort fix
cheese-head Jul 8, 2025
b4986b0
Merge pull request #1 from cheese-head/update-nixlbench-docs
cheese-head Jul 8, 2025
4df9a71
Merge branch 'main' into cheese-head/update-nixlbench-docs
cheese-head Jul 8, 2025
08a1e5b
Merge branch 'ai-dynamo:main' into cheese-head/update-nixlbench-docs
cheese-head Jul 9, 2025
a60adbf
enable direct io support in nixlbench
cheese-head Jul 9, 2025
ec689c5
Merge branch 'ai-dynamo:main' into nixlbench/enable_directio
cheese-head Jul 9, 2025
2d558f7
apply clang-format
cheese-head Jul 10, 2025
fdee0c3
Merge branch 'ai-dynamo:main' into nixlbench/enable_directio
cheese-head Jul 10, 2025
44d5cd0
fix clang-formatting
cheese-head Jul 10, 2025
376e41c
check for null pointer
cheese-head Jul 12, 2025
ed24644
merge origin main
cheese-head Jul 14, 2025
5f92228
merge main
cheese-head Jul 14, 2025
d8e472e
Merge branch 'ai-dynamo:main' into nixlbench/enable_directio
cheese-head Jul 14, 2025
e427887
revert clang formatting
cheese-head Jul 14, 2025
9ea9fad
calculate page size during init
cheese-head Jul 15, 2025
7aa0ae3
refactor transfer mem allocation
cheese-head Jul 15, 2025
e45ae7c
add optional param for calloc allocations
cheese-head Jul 15, 2025
4105513
Merge branch 'main' into nixlbench/enable_directio
aranadive Jul 15, 2025
4044503
Merge branch 'main' into nixlbench/enable_directio
aranadive Jul 16, 2025
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
1 change: 1 addition & 0 deletions benchmark/nixlbench/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ int xferBenchConfig::num_files = 0;
std::string xferBenchConfig::posix_api_type = "";
std::string xferBenchConfig::filepath = "";
bool xferBenchConfig::storage_enable_direct = false;
long xferBenchConfig::page_size = sysconf(_SC_PAGESIZE);

int xferBenchConfig::loadFromFlags() {
runtime_type = FLAGS_runtime_type;
Expand Down
1 change: 1 addition & 0 deletions benchmark/nixlbench/src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class xferBenchConfig {
static int gds_batch_pool_size;
static int gds_batch_limit;
static std::string gpunetio_device_list;
static long page_size;

static int loadFromFlags();
static void printConfig();
Expand Down
95 changes: 86 additions & 9 deletions benchmark/nixlbench/src/worker/nixl/nixl_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <utils/serdes/serdes.h>
#include <omp.h>


#define ROUND_UP(value, granularity) \
((((value) + (granularity) - 1) / (granularity)) * (granularity))

Expand Down Expand Up @@ -210,16 +209,71 @@ iovListToNixlXferDlist(const std::vector<xferBenchIOV> &iov_list, nixl_xfer_dlis
}
}


enum class AllocationType { POSIX_MEMALIGN, CALLOC, MALLOC };

static bool
allocateXferMemory(size_t buffer_size,
void **addr,
Comment thread
aranadive marked this conversation as resolved.
std::optional<AllocationType> allocation_type = std::nullopt,
std::optional<size_t> num = 1) {

if (!addr) {
std::cerr << "Invalid address" << std::endl;
return false;
}
if (buffer_size == 0) {
std::cerr << "Invalid buffer size" << std::endl;
return false;
}
AllocationType type = allocation_type.value_or(AllocationType::MALLOC);

if (type == AllocationType::POSIX_MEMALIGN) {
if (xferBenchConfig::page_size == 0) {
std::cerr << "Error: Invalid page size returned by sysconf" << std::endl;
return false;
}
int rc = posix_memalign(addr, xferBenchConfig::page_size, buffer_size);
if (rc != 0 || !*addr) {
std::cerr << "Failed to allocate " << buffer_size
<< " bytes of page-aligned DRAM memory" << std::endl;
return false;
}
memset(*addr, 0, buffer_size);
} else if (type == AllocationType::CALLOC) {
*addr = calloc(num.value_or(1), buffer_size);
if (!*addr) {
std::cerr << "Failed to allocate " << buffer_size << " bytes of DRAM memory"
<< std::endl;
return false;
}
} else if (type == AllocationType::MALLOC) {
*addr = malloc(buffer_size);
if (!*addr) {
std::cerr << "Failed to allocate " << buffer_size << " bytes of DRAM memory"
<< std::endl;
return false;
}
} else {
std::cerr << "Invalid allocation type" << std::endl;
return false;
}
return true;
}
Comment thread
aranadive marked this conversation as resolved.

std::optional<xferBenchIOV>
xferBenchNixlWorker::initBasicDescDram(size_t buffer_size, int mem_dev_id) {
void *addr;

addr = calloc(1, buffer_size);
if (!addr) {
AllocationType type = AllocationType::CALLOC;
if (xferBenchConfig::storage_enable_direct) {
type = AllocationType::POSIX_MEMALIGN;
}

if (!allocateXferMemory(buffer_size, &addr, type)) {
std::cerr << "Failed to allocate " << buffer_size << " bytes of DRAM memory" << std::endl;
return std::nullopt;
}

if (isInitiator()) {
memset(addr, XFERBENCH_INITIATOR_BUFFER_ELEMENT, buffer_size);
} else if (isTarget()) {
Expand Down Expand Up @@ -349,7 +403,8 @@ createFileFds(std::string name) {

for (int i = 0; i < num_files; i++) {
std::string file_name = file_path + file_name_prefix + name + "_" + std::to_string(i);
std::cout << "Creating " << " file: " << file_name << std::endl;
std::cout << "Creating "
Comment thread
aranadive marked this conversation as resolved.
<< " file: " << file_name << std::endl;
int fd = open(file_name.c_str(), flags, 0744);
if (fd < 0) {
std::cerr << "Failed to open file: " << file_name << " with error: " << strerror(errno)
Expand All @@ -369,13 +424,27 @@ xferBenchNixlWorker::initBasicDescFile(size_t buffer_size, int fd, int mem_dev_i
auto ret =
std::optional<xferBenchIOV>(std::in_place, (uintptr_t)gds_running_ptr, buffer_size, fd);
// Fill up with data
void *buf = (void *)malloc(buffer_size);
if (!buf) {
void *buf;
AllocationType type = AllocationType::MALLOC;

if (xferBenchConfig::storage_enable_direct) {
type = AllocationType::POSIX_MEMALIGN;
}

if (!allocateXferMemory(buffer_size, &buf, type) || !buf) {
std::cerr << "Failed to allocate " << buffer_size << " bytes of memory" << std::endl;
return std::nullopt;
}

// File is always initialized with XFERBENCH_TARGET_BUFFER_ELEMENT
memset(buf, XFERBENCH_TARGET_BUFFER_ELEMENT, buffer_size);
if (xferBenchConfig::storage_enable_direct) {
gds_running_ptr =
((gds_running_ptr + xferBenchConfig::page_size - 1) / xferBenchConfig::page_size) *
xferBenchConfig::page_size;
} else {
gds_running_ptr += (buffer_size * mem_dev_id);
}
int rc = pwrite(fd, buf, buffer_size, gds_running_ptr);
if (rc < 0) {
std::cerr << "Failed to write to file: " << fd << " with error: " << strerror(errno)
Expand All @@ -384,8 +453,6 @@ xferBenchNixlWorker::initBasicDescFile(size_t buffer_size, int fd, int mem_dev_i
}
free(buf);

gds_running_ptr += (buffer_size * mem_dev_id);

return ret;
}

Expand Down Expand Up @@ -428,6 +495,16 @@ xferBenchNixlWorker::allocateMemory(int num_lists) {
}
buffer_size = xferBenchConfig::total_buffer_size / (num_devices * num_lists);

if (xferBenchConfig::storage_enable_direct) {
if (xferBenchConfig::page_size == 0) {
std::cerr << "Error: Invalid page size returned by sysconf" << std::endl;
exit(EXIT_FAILURE);
}
buffer_size =
((buffer_size + xferBenchConfig::page_size - 1) / xferBenchConfig::page_size) *
xferBenchConfig::page_size;
}

opt_args.backends.push_back(backend_engine);

if (xferBenchConfig::isStorageBackend()) {
Expand Down