Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Aug 31, 2023
1 parent dae437e commit 9426bc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cpp/examples/basic_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ int main()
cout << "The batch API isn't available, requires CUDA 12.2+" << endl;
}
{
cout << "Performing async I/O using file handle" << endl;
cout << "Performing async I/O using by-reference arguments" << endl;
off_t f_off{0};
off_t d_off{0};
// Notice, we have to allocate the `bytes_done_p` argument on the heap and set it to 0.
ssize_t* bytes_done_p{};
check(cudaHostAlloc((void**)&bytes_done_p, SIZE, cudaHostAllocDefault) == cudaSuccess);
*bytes_done_p = 0;

// Let's create a new stream and submit a sync write
// Let's create a new stream and submit an async write
CUstream stream{};
check(cudaStreamCreate(&stream) == cudaSuccess);
kvikio::FileHandle f_handle("/tmp/test-file", "w+");
Expand All @@ -219,15 +219,15 @@ int main()
// use `CUFILE_CHECK_STREAM_IO` to check for errors.
CUFILE_CHECK_STREAM_IO(bytes_done_p);
check(*bytes_done_p == SIZE);
cout << "File async write : " << *bytes_done_p << endl;
cout << "File async write: " << *bytes_done_p << endl;

/* Read */
// Let's async read the data back into device memory
*bytes_done_p = 0;
f_handle.read_async(c_dev, &io_size, &f_off, &d_off, bytes_done_p, stream);
check(cudaStreamSynchronize(stream) == cudaSuccess);
CUFILE_CHECK_STREAM_IO(bytes_done_p);
check(*bytes_done_p == SIZE);
cout << "File async read : " << *bytes_done_p << endl;
cout << "File async read: " << *bytes_done_p << endl;
check(cudaFreeHost((void*)bytes_done_p) == cudaSuccess);
}
}
6 changes: 3 additions & 3 deletions cpp/include/kvikio/file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class FileHandle {
* `devPtr_base` must remain set to the base address used in the `buffer_register` call.
* @param size Size in bytes to write.
* @param file_offset Offset in the file to write from.
* @param devPtr_offset Offset relative to the `devPtr_base` pointer to write into.
* @param devPtr_offset Offset relative to the `devPtr_base` pointer to write from.
* This parameter should be used only with registered buffers.
* @return Size of bytes that were successfully written.
*/
Expand Down Expand Up @@ -510,7 +510,7 @@ class FileHandle {
* the values of `size`, `file_offset` and `devPtr_offset` will not be evaluated until execution
* time. Notice, this behavior can be changed using cuFile's cuFileStreamRegister API.
*
* @param devPtr_base_p Base address of buffer in device memory. For registered buffers,
* @param devPtr_base Base address of buffer in device memory. For registered buffers,
* `devPtr_base` must remain set to the base address used in the `buffer_register` call.
* @param size_p Pointer to size in bytes to read. If the exact size is not known at the time of
* I/O submission, then you must set it to the maximum possible I/O size for that stream I/O.
Expand Down Expand Up @@ -563,7 +563,7 @@ class FileHandle {
* the values of `size`, `file_offset` and `devPtr_offset` will not be evaluated until execution
* time. Notice, this behavior can be changed using cuFile's cuFileStreamRegister API.
*
* @param devPtr_base_p Base address of buffer in device memory. For registered buffers,
* @param devPtr_base Base address of buffer in device memory. For registered buffers,
* `devPtr_base` must remain set to the base address used in the `buffer_register` call.
* @param size_p Pointer to size in bytes to read. If the exact size is not known at the time of
* I/O submission, then you must set it to the maximum possible I/O size for that stream I/O.
Expand Down

0 comments on commit 9426bc1

Please sign in to comment.