Skip to content

Commit b9db7c8

Browse files
committed
[fs_connector][feat]: Add storage_offload CUDA kernel and setup config
Signed-off-by: Kfir Toledo <kfir.toledo@ibm.com>
1 parent f8bb304 commit b9db7c8

File tree

3 files changed

+425
-0
lines changed

3 files changed

+425
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from setuptools import setup, find_packages
2+
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
3+
4+
setup(
5+
name="storage_offload",
6+
packages=find_packages("src"),
7+
package_dir={"": "src"},
8+
ext_modules=[
9+
CUDAExtension(
10+
"storage_offload",
11+
sources=[
12+
"src/csrc/storage/storage_offload.cu",
13+
"src/csrc/storage/buffer.cpp",
14+
"src/csrc/storage/file_io.cpp",
15+
"src/csrc/storage/thread_pool.cpp",
16+
"src/csrc/storage/tensor_copy.cu",
17+
],
18+
libraries=['nvidia-ml', 'numa', 'cuda'],
19+
extra_compile_args={
20+
"cxx": ["-O3", "-std=c++17", "-fopenmp"],
21+
"nvcc": ["-O3", "-std=c++17", "-Xcompiler", "-std=c++17","-Xcompiler", "-fopenmp"]
22+
}
23+
),
24+
],
25+
cmdclass={"build_ext": BuildExtension},
26+
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#include <cstdlib>
4+
#include <iostream>
5+
#include <string>
6+
#include <chrono>
7+
8+
// -------------------------------------
9+
// Debugging and timing macros
10+
// -------------------------------------
11+
12+
// Debug print - enabled when STORAGE_CONNECTOR_DEBUG is set and not "0"
13+
#define DEBUG_PRINT(msg) \
14+
do { \
15+
const char* env = std::getenv("STORAGE_CONNECTOR_DEBUG"); \
16+
if (env && std::string(env) != "0") \
17+
std::cout << "[DEBUG] " << msg << std::endl; \
18+
} while (0)
19+
20+
// Timing macro - measures execution time when STORAGE_CONNECTOR_DEBUG is set and not "0"
21+
#define TIME_EXPR(label, expr, info_str) ([&]() { \
22+
const char* env = std::getenv("STORAGE_CONNECTOR_DEBUG"); \
23+
if (!(env && std::string(env) != "0")) { \
24+
return (expr); \
25+
} \
26+
auto __t0 = std::chrono::high_resolution_clock::now(); \
27+
auto __ret = (expr); \
28+
auto __t1 = std::chrono::high_resolution_clock::now(); \
29+
double __ms = std::chrono::duration<double, std::milli>(__t1 - __t0).count(); \
30+
std::cout << "[DEBUG][TIME] " << label << " took " << __ms << " ms | " \
31+
<< info_str << std::endl; \
32+
return __ret; \
33+
})()

0 commit comments

Comments
 (0)