Skip to content

Commit

Permalink
remove
Browse files Browse the repository at this point in the history
  • Loading branch information
vuule committed Nov 3, 2023
1 parent 8654a3c commit 33e9e49
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 74 deletions.
8 changes: 0 additions & 8 deletions python/kvikio/_lib/libnvcomp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ cdef class _nvcompManager:
<DecompressionConfig&>self._decompression_config.get()[0]
)

def set_scratch_buffer(self, Array new_scratch_buffer):
return self._impl.set_scratch_buffer(
<uint8_t*>new_scratch_buffer.ptr
)

def get_required_scratch_buffer_size(self):
return self._impl.get_required_scratch_buffer_size()

def get_compressed_output_size(self, Array comp_buffer):
return self._impl.get_compressed_output_size(
<uint8_t*>comp_buffer.ptr
Expand Down
4 changes: 0 additions & 4 deletions python/kvikio/_lib/nvcomp_cxx_api.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ cdef extern from "nvcomp/nvcompManager.hpp" namespace 'nvcomp':
uint8_t* decomp_buffer,
const uint8_t* comp_buffer,
const DecompressionConfig& decomp_config)
void set_scratch_buffer(uint8_t* new_scratch_buffer) except +
size_t get_required_scratch_buffer_size() except +
size_t get_compressed_output_size(uint8_t* comp_buffer) except +

cdef cppclass PimplManager "nvcomp::PimplManager":
Expand All @@ -125,8 +123,6 @@ cdef extern from "nvcomp/nvcompManager.hpp" namespace 'nvcomp':
uint8_t* decomp_buffer,
const uint8_t* comp_buffer,
const DecompressionConfig& decomp_config) except +
void set_scratch_buffer(uint8_t* new_scratch_buffer) except +
size_t get_required_scratch_buffer_size() except +
size_t get_compressed_output_size(uint8_t* comp_buffer) except +

# C++ Concrete ANS Manager
Expand Down
28 changes: 0 additions & 28 deletions python/kvikio/nvcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,34 +192,6 @@ def configure_decompression_with_compressed_buffer(
asarray(data)
)

def get_required_scratch_buffer_size(self) -> int:
"""Return the size of the optional scratch buffer.
Returns
-------
int
"""
return self._manager.get_required_scratch_buffer_size()

def set_scratch_buffer(self, new_scratch_buffer: cp.ndarray) -> None:
"""Use a pre-allocated buffer for compression.
Use a GPU-allocated buffer that will be used for compression
temporary storage instead of allowing the library to create the
scratch buffer.
Can reduce memory usage.
Parameters
----------
new_scratch_buffer : cp.ndarray
The buffer that you allocated on the GPU for compressor temporary
storage.
Returns
-------
cp.ndarray
"""
return self._manager.set_scratch_buffer(asarray(new_scratch_buffer))

def get_compressed_output_size(self, comp_buffer: cp.ndarray) -> int:
"""Return the actual size of compression result.
Expand Down
36 changes: 2 additions & 34 deletions python/tests/test_nvcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def test_get_decompression_config_with_default_options(manager, expected):


@pytest.mark.parametrize("manager", managers())
def test_set_scratch_buffer(manager):
def test_set_scratch_alloc(manager):
length = 10000
dtype = cupy.uint8
data = cupy.array(
Expand All @@ -419,9 +419,7 @@ def test_set_scratch_buffer(manager):
)
compressor_instance = manager()
compressor_instance.configure_compression(len(data))
buffer_size = compressor_instance.get_required_scratch_buffer_size()
buffer = cupy.zeros(buffer_size, dtype="int8")
compressor_instance.set_scratch_buffer(buffer)
# TODO set_scratch_allocators
compressor_instance.compress(data)
if isinstance(compressor_instance, libnvcomp.BitcompManager):
# Bitcomp does not use the scratch buffer
Expand All @@ -430,36 +428,6 @@ def test_set_scratch_buffer(manager):
assert (buffer[0:5] != cupy.array([0, 0, 0, 0, 0])).any()


@pytest.mark.parametrize(
"manager,expected",
zip(
managers(),
[
378355712, # ANS
8, # Bitcomp
1641608, # Cascaded
393222400, # Gdeflate
252334080, # LZ4
67311208, # Snappy
],
),
)
def test_get_required_scratch_buffer_size(manager, expected):
length = 10000
dtype = cupy.uint8
data = cupy.array(
np.arange(
0,
length // cupy.dtype(dtype).type(0).itemsize,
dtype=dtype,
)
)
compressor_instance = manager()
compressor_instance.configure_compression(len(data))
buffer_size = compressor_instance.get_required_scratch_buffer_size()
assert_compression_size(buffer_size, expected)


@pytest.mark.parametrize(
"manager, expected",
zip(managers(), list(LEN.values())),
Expand Down

0 comments on commit 33e9e49

Please sign in to comment.