-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Convert sizes to `Py_ssize_t`, which Python uses for this info * Type file offsets with `off_t` * Update default values to work with typing * Simplify and optimize `parse_buffer_argument` * Add `.pxd` file for `RemoteHandle` to allow leveraging it in Cython
- Loading branch information
Showing
7 changed files
with
125 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved. | ||
# See file LICENSE for terms. | ||
|
||
# distutils: language = c++ | ||
# cython: language_level=3 | ||
|
||
import pathlib | ||
from typing import Optional | ||
|
||
from posix cimport fcntl | ||
|
||
from libc.stdint cimport uintptr_t | ||
from libcpp cimport bool | ||
from libcpp.string cimport string | ||
from libcpp.utility cimport move, pair | ||
|
||
from kvikio._lib.arr cimport parse_buffer_argument | ||
from kvikio._lib.future cimport ( | ||
IOFuture, | ||
IOFutureStream, | ||
_wrap_io_future, | ||
_wrap_stream_future, | ||
cpp_StreamFuture, | ||
future, | ||
) | ||
|
||
from kvikio._lib import defaults | ||
|
||
ctypedef int c_int | ||
|
||
|
||
cdef class CuFile: | ||
"""File handle for GPUDirect Storage (GDS)""" | ||
cdef FileHandle _handle | ||
|
||
cpdef close(self) | ||
cpdef bint closed(self) | ||
cpdef c_int fileno(self) | ||
cpdef c_int open_flags(self) | ||
cpdef IOFuture pread(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0, | ||
Py_ssize_t task_size=0) | ||
cpdef IOFuture pwrite(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0, | ||
Py_ssize_t task_size=0) | ||
cpdef Py_ssize_t read(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0, | ||
Py_ssize_t dev_offset=0) | ||
cpdef Py_ssize_t write(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0, | ||
Py_ssize_t dev_offset=0) | ||
cpdef IOFutureStream read_async(self, buf, Py_ssize_t size=-1, | ||
Py_ssize_t file_offset=0, Py_ssize_t dev_offset=0, uintptr_t st=0) | ||
cpdef IOFutureStream write_async(self, buf, Py_ssize_t size=-1, | ||
Py_ssize_t file_offset=0, Py_ssize_t dev_offset=0, uintptr_t st=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# See file LICENSE for terms. | ||
|
||
# distutils: language = c++ | ||
# cython: language_level=3 | ||
|
||
from cython cimport Py_ssize_t | ||
from libcpp.memory cimport unique_ptr | ||
|
||
from kvikio._lib.future cimport IOFuture | ||
|
||
|
||
cdef class RemoteFile: | ||
cdef unique_ptr[cpp_RemoteHandle] _handle | ||
|
||
@classmethod | ||
cpdef RemoteFile open_http(cls, str url, Py_ssize_t nbytes=-1) | ||
|
||
cpdef Py_ssize_t nbytes(self) | ||
|
||
cpdef Py_ssize_t read(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0) | ||
cpdef IOFuture pread(self, buf, Py_ssize_t size=-1, Py_ssize_t file_offset=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters