Skip to content

Commit

Permalink
initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Oct 24, 2024
1 parent 9f1a21d commit 47a0452
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions python/kvikio/kvikio/cufile_driver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 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?
Expand All @@ -14,6 +16,9 @@ def driver_open() -> None:
opens the driver, but every call should 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
Expand All @@ -35,3 +40,18 @@ def driver_close() -> None:
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.
Raises
------
RuntimeError
If cuFile isn't available.
"""
driver_open()
atexit.register(driver_close)
2 changes: 1 addition & 1 deletion python/kvikio/tests/test_cufile_driver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
# See file LICENSE for terms.

import pytest
Expand Down

0 comments on commit 47a0452

Please sign in to comment.