py_ds_aio.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright 2020 The Microsoft DeepSpeed Team
  3. Licensed under the MIT license.
  4. Functionality for swapping optimizer tensors to/from (NVMe) storage devices.
  5. */
  6. #include <torch/extension.h>
  7. #include "deepspeed_py_aio_handle.h"
  8. #include "deepspeed_py_copy.h"
  9. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
  10. {
  11. m.def("aio_read", &deepspeed_py_aio_read, "DeepSpeed Asynchronous I/O Read");
  12. m.def("aio_write", &deepspeed_py_aio_write, "DeepSpeed Asynchronous I/O Write");
  13. m.def("deepspeed_memcpy", &deepspeed_py_memcpy, "DeepSpeed Memory Copy");
  14. py::class_<deepspeed_aio_handle_t>(m, "aio_handle")
  15. .def(py::init<const int, const int, const bool, const bool, const int>())
  16. .def("get_block_size", &deepspeed_aio_handle_t::get_block_size)
  17. .def("get_queue_depth", &deepspeed_aio_handle_t::get_queue_depth)
  18. .def("get_single_submit", &deepspeed_aio_handle_t::get_single_submit)
  19. .def("get_overlap_events", &deepspeed_aio_handle_t::get_overlap_events)
  20. .def("get_thread_count", &deepspeed_aio_handle_t::get_thread_count)
  21. .def("read", &deepspeed_aio_handle_t::read)
  22. .def("write", &deepspeed_aio_handle_t::write)
  23. .def("pread", &deepspeed_aio_handle_t::pread)
  24. .def("pwrite", &deepspeed_aio_handle_t::pwrite)
  25. .def("sync_pread", &deepspeed_aio_handle_t::sync_pread)
  26. .def("sync_pwrite", &deepspeed_aio_handle_t::sync_pwrite)
  27. .def("async_pread", &deepspeed_aio_handle_t::async_pread)
  28. .def("async_pwrite", &deepspeed_aio_handle_t::async_pwrite)
  29. .def("wait", &deepspeed_aio_handle_t::wait);
  30. }