|
28 | 28 | /* eviction */ |
29 | 29 | #include "libCacheSim/evictionAlgo.h" |
30 | 30 |
|
31 | | -/* sampling */ |
32 | | -#include "libCacheSim/sampling.h" |
33 | | - |
34 | 31 | /* cache simulator */ |
35 | 32 | #include "libCacheSim/profilerLRU.h" |
36 | 33 | #include "libCacheSim/simulator.h" |
@@ -164,6 +161,8 @@ struct ReaderDeleter { |
164 | 161 | } |
165 | 162 | }; |
166 | 163 |
|
| 164 | +namespace py = pybind11; |
| 165 | + |
167 | 166 | PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter) |
168 | 167 | m.doc() = R"pbdoc( |
169 | 168 | libCacheSim Python bindings |
@@ -364,6 +363,29 @@ PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter) |
364 | 363 | Reader: A new reader instance for the trace. |
365 | 364 | )pbdoc"); |
366 | 365 |
|
| 366 | + /** |
| 367 | + * @brief Generic function to create a cache instance. |
| 368 | + */ |
| 369 | + m.def( |
| 370 | + "create_cache", |
| 371 | + [](const std::string& eviction_algo, const uint64_t cache_size, |
| 372 | + const std::string& eviction_params, |
| 373 | + bool consider_obj_metadata) { return nullptr; }, |
| 374 | + py::arg("eviction_algo"), py::arg("cache_size"), |
| 375 | + py::arg("eviction_params"), py::arg("consider_obj_metadata"), |
| 376 | + R"pbdoc( |
| 377 | + Create a cache instance. |
| 378 | +
|
| 379 | + Args: |
| 380 | + eviction_algo (str): Eviction algorithm to use (e.g., "LRU", "FIFO", "Random"). |
| 381 | + cache_size (int): Size of the cache in bytes. |
| 382 | + eviction_params (str): Additional parameters for the eviction algorithm. |
| 383 | + consider_obj_metadata (bool): Whether to consider object metadata in eviction decisions. |
| 384 | +
|
| 385 | + Returns: |
| 386 | + Cache: A new cache instance. |
| 387 | + )pbdoc"); |
| 388 | + |
367 | 389 | /* TODO(haocheng): should we support all parameters in the |
368 | 390 | * common_cache_params_t? (hash_power, etc.) */ |
369 | 391 |
|
@@ -592,8 +614,7 @@ PYBIND11_MODULE(_libcachesim, m) { // NOLINT(readability-named-parameter) |
592 | 614 | /** |
593 | 615 | * @brief Create a TinyLFU cache instance. |
594 | 616 | */ |
595 | | - // TODO: Review and update the eviction parsing logic in TinyLFU_init if |
596 | | - // necessary. |
| 617 | + // mark evivtion parsing need change |
597 | 618 | m.def( |
598 | 619 | "TinyLFU_init", |
599 | 620 | [](uint64_t cache_size, std::string main_cache, double window_size) { |
|
0 commit comments