| 127 | } |
| 128 | |
| 129 | int deepspeed_io_handle_t::write(const torch::Tensor& buffer, |
| 130 | const char* filename, |
| 131 | const bool validate, |
| 132 | const int64_t file_offset) |
| 133 | { |
| 134 | assert(_aio_ctxt); |
| 135 | |
| 136 | const auto start_time = std::chrono::high_resolution_clock::now(); |
| 137 | |
| 138 | const auto fd = open_file(filename, false); |
| 139 | if (fd == -1) { return -1; } |
| 140 | warn_consumer_ssd_writes(); |
| 141 | |
| 142 | auto write_buffer = (char*)buffer.data_ptr(); |
| 143 | const auto num_write_bytes = static_cast<int64_t>(buffer.nbytes()); |
| 144 | std::unique_ptr<io_xfer_ctxt> xfer_ctxt( |
| 145 | new io_xfer_ctxt(fd, file_offset, 0, num_write_bytes, write_buffer)); |
| 146 | |
| 147 | if (_aio_config._overlap_events) { |
| 148 | do_aio_operation_overlap(false, _aio_ctxt, xfer_ctxt, &_aio_config, nullptr); |
| 149 | } else { |
| 150 | do_aio_operation_sequential(false, _aio_ctxt, xfer_ctxt, &_aio_config, nullptr); |
| 151 | } |
| 152 | const std::chrono::duration<double> aio_time = |
| 153 | std::chrono::high_resolution_clock::now() - start_time; |
| 154 | |
| 155 | close(fd); |
| 156 | |
| 157 | if (validate) { validate_aio_operation(false, filename, write_buffer, num_write_bytes); } |
| 158 | |
| 159 | const std::chrono::duration<double> fn_time = |
| 160 | std::chrono::high_resolution_clock::now() - start_time; |
| 161 | std::cout << "Elapsed time(usec): " << "aio = " << aio_time.count() * 1e6 |
| 162 | << " call = " << fn_time.count() * 1e6 << std::endl; |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | void deepspeed_io_handle_t::_schedule_aio_work_locked( |
| 167 | std::shared_ptr<struct io_op_desc_t> scheduled_op) |
nothing calls this directly
no test coverage detected