forked from rapidsai/kvikio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…pidsai#514) Changes: - Adding Python bindings to `cuFileDriverOpen()` and `cuFileDriverClose()`. - We now [only open the cufile driver explicitly](rapidsai#160) in CUDA versions older than v12.2. - Introducing `kvikio.cufile_driver.initialize()`, which open the cuFile driver and close it again at module exit. - Let CI fail if KvikIO wasn't built with cuFile support. * Except on cuda11.8+arm64; cuFile didn't support arm until cuda v12.4. - Some refactor and clean up! Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) - Vyas Ramasubramani (https://github.com/vyasr) URL: rapidsai#514
- Loading branch information
Showing
17 changed files
with
178 additions
and
38 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
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
File renamed without changes.
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
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
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,62 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# See file LICENSE for terms. | ||
|
||
import atexit | ||
|
||
from kvikio._lib import cufile_driver # type: ignore | ||
|
||
# TODO: Wrap nicely, maybe as a dataclass? | ||
# <https://github.com/rapidsai/kvikio/issues/526> | ||
DriverProperties = cufile_driver.DriverProperties | ||
|
||
|
||
def driver_open() -> None: | ||
"""Open the cuFile driver | ||
cuFile accepts multiple calls to `driver_open()`. Only the first call | ||
opens the driver, but every call must have a matching call to | ||
`driver_close()`. | ||
Normally, it is not required to open and close the cuFile driver since | ||
it is done automatically. | ||
Raises | ||
------ | ||
RuntimeError | ||
If cuFile isn't available. | ||
""" | ||
return cufile_driver.driver_open() | ||
|
||
|
||
def driver_close() -> None: | ||
"""Close the cuFile driver | ||
cuFile accepts multiple calls to `driver_open()`. Only the first call | ||
opens the driver, but every call must have a matching call to | ||
`driver_close()`. | ||
Raises | ||
------ | ||
RuntimeError | ||
If cuFile isn't available. | ||
""" | ||
return cufile_driver.driver_close() | ||
|
||
|
||
def initialize() -> None: | ||
"""Open the cuFile driver and close it again at module exit | ||
Normally, it is not required to open and close the cuFile driver since | ||
it is done automatically. | ||
Notes | ||
----- | ||
Registers an atexit handler that calls :func:`driver_close`. | ||
Raises | ||
------ | ||
RuntimeError | ||
If cuFile isn't available. | ||
""" | ||
driver_open() | ||
atexit.register(driver_close) |
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,12 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# See file LICENSE for terms. | ||
|
||
import pytest | ||
|
||
import kvikio.cufile_driver | ||
|
||
|
||
@pytest.mark.cufile | ||
def test_open_and_close(): | ||
kvikio.cufile_driver.driver_open() | ||
kvikio.cufile_driver.driver_close() |