Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake-build/
*.o
*.a
*.so
*.fsz
*.szgpu
*.dec.f32
*.log
__pycache__/
Expand Down
146 changes: 73 additions & 73 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ cmake_minimum_required(VERSION 3.18)
# automatically when the CUDA toolkit is new enough to know it.
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 80 90)
set(_fsz_default_archs ON)
set(_szgpu_default_archs ON)
endif()

project(fsz LANGUAGES CXX CUDA VERSION 1.0.0)
project(szgpu LANGUAGES CXX CUDA VERSION 1.0.1)

if(_fsz_default_archs AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.8)
if(_szgpu_default_archs AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 12.8)
list(APPEND CMAKE_CUDA_ARCHITECTURES 100)
endif()

Expand All @@ -29,126 +29,126 @@ endif()

find_package(CUDAToolkit REQUIRED)

option(FSZ_BUILD_SHARED "Also build the shared library (libfsz.so)" ON)
option(FSZ_BUILD_TOOLS "Build the fsz command-line tool" ON)
option(FSZ_BUILD_EXAMPLES "Build FSZ examples" ON)
option(FSZ_BUILD_TESTS "Build FSZ tests" ON)
option(SZGPU_BUILD_SHARED "Also build the shared library (libszgpu.so)" ON)
option(SZGPU_BUILD_TOOLS "Build the szgpu command-line tool" ON)
option(SZGPU_BUILD_EXAMPLES "Build SZ-GPU examples" ON)
option(SZGPU_BUILD_TESTS "Build SZ-GPU tests" ON)

set(FSZ_SOURCES src/fsz.cu)
set(SZGPU_SOURCES src/szgpu.cu)

# Static library (the default link target, exported as fsz::fsz).
add_library(fsz STATIC ${FSZ_SOURCES})
add_library(fsz::fsz ALIAS fsz)
# Static library (the default link target, exported as szgpu::szgpu).
add_library(szgpu STATIC ${SZGPU_SOURCES})
add_library(szgpu::szgpu ALIAS szgpu)

# Shared library for dynamic linking and the Python bindings.
if(FSZ_BUILD_SHARED)
add_library(fsz_shared SHARED ${FSZ_SOURCES})
set_target_properties(fsz_shared PROPERTIES OUTPUT_NAME fsz)
if(SZGPU_BUILD_SHARED)
add_library(szgpu_shared SHARED ${SZGPU_SOURCES})
set_target_properties(szgpu_shared PROPERTIES OUTPUT_NAME szgpu)
endif()

foreach(_fsz_lib IN ITEMS fsz fsz_shared)
if(NOT TARGET ${_fsz_lib})
foreach(_szgpu_lib IN ITEMS szgpu szgpu_shared)
if(NOT TARGET ${_szgpu_lib})
continue()
endif()
target_include_directories(${_fsz_lib}
target_include_directories(${_szgpu_lib}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(${_fsz_lib} PUBLIC CUDA::cudart)
set_target_properties(${_fsz_lib} PROPERTIES
target_link_libraries(${_szgpu_lib} PUBLIC CUDA::cudart)
set_target_properties(${_szgpu_lib} PROPERTIES
CUDA_SEPARABLE_COMPILATION OFF
POSITION_INDEPENDENT_CODE ON)
target_compile_options(${_fsz_lib} PRIVATE
target_compile_options(${_szgpu_lib} PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:-O3>)
endforeach()

# Command-line tool: the binary is named `fsz`.
if(FSZ_BUILD_TOOLS)
add_executable(fsz_cli tools/fsz.cu)
set_target_properties(fsz_cli PROPERTIES OUTPUT_NAME fsz)
target_include_directories(fsz_cli PRIVATE tools)
target_link_libraries(fsz_cli PRIVATE fsz::fsz)
# Command-line tool: the binary is named `szgpu`.
if(SZGPU_BUILD_TOOLS)
add_executable(szgpu_cli tools/szgpu.cu)
set_target_properties(szgpu_cli PROPERTIES OUTPUT_NAME szgpu)
target_include_directories(szgpu_cli PRIVATE tools)
target_link_libraries(szgpu_cli PRIVATE szgpu::szgpu)
endif()

if(FSZ_BUILD_EXAMPLES)
add_executable(fsz_example_roundtrip examples/example_roundtrip.cu)
target_link_libraries(fsz_example_roundtrip PRIVATE fsz::fsz)
if(SZGPU_BUILD_EXAMPLES)
add_executable(szgpu_example_roundtrip examples/example_roundtrip.cu)
target_link_libraries(szgpu_example_roundtrip PRIVATE szgpu::szgpu)

add_executable(fsz_example_hostptr examples/example_hostptr.cu)
target_link_libraries(fsz_example_hostptr PRIVATE fsz::fsz)
add_executable(szgpu_example_hostptr examples/example_hostptr.cu)
target_link_libraries(szgpu_example_hostptr PRIVATE szgpu::szgpu)
endif()

if(FSZ_BUILD_TESTS)
if(SZGPU_BUILD_TESTS)
enable_testing()
add_executable(fsz_test_roundtrip tests/test_roundtrip.cu)
target_link_libraries(fsz_test_roundtrip PRIVATE fsz::fsz)
add_test(NAME roundtrip COMMAND fsz_test_roundtrip)

add_executable(fsz_test_hostptr tests/test_hostptr.cu)
target_include_directories(fsz_test_hostptr PRIVATE src)
target_link_libraries(fsz_test_hostptr PRIVATE fsz::fsz)
add_test(NAME hostptr COMMAND fsz_test_hostptr)
add_executable(szgpu_test_roundtrip tests/test_roundtrip.cu)
target_link_libraries(szgpu_test_roundtrip PRIVATE szgpu::szgpu)
add_test(NAME roundtrip COMMAND szgpu_test_roundtrip)

add_executable(szgpu_test_hostptr tests/test_hostptr.cu)
target_include_directories(szgpu_test_hostptr PRIVATE src)
target_link_libraries(szgpu_test_hostptr PRIVATE szgpu::szgpu)
add_test(NAME hostptr COMMAND szgpu_test_hostptr)
endif()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Fortran interface: built whenever a Fortran compiler is available.
option(FSZ_BUILD_FORTRAN "Build the Fortran interface" ON)
if(FSZ_BUILD_FORTRAN)
option(SZGPU_BUILD_FORTRAN "Build the Fortran interface" ON)
if(SZGPU_BUILD_FORTRAN)
include(CheckLanguage)
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
add_library(fsz_fortran STATIC fortran/fsz.f90)
target_link_libraries(fsz_fortran PUBLIC fsz::fsz stdc++)
set_target_properties(fsz_fortran PROPERTIES
add_library(szgpu_fortran STATIC fortran/szgpu.f90)
target_link_libraries(szgpu_fortran PUBLIC szgpu::szgpu stdc++)
set_target_properties(szgpu_fortran PROPERTIES
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fortran_modules)
target_include_directories(fsz_fortran INTERFACE
target_include_directories(szgpu_fortran INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/fortran_modules>)
if(FSZ_BUILD_EXAMPLES)
add_executable(fsz_example_fortran fortran/example_fsz.f90)
target_link_libraries(fsz_example_fortran PRIVATE fsz_fortran)
if(SZGPU_BUILD_EXAMPLES)
add_executable(szgpu_example_fortran fortran/example_szgpu.f90)
target_link_libraries(szgpu_example_fortran PRIVATE szgpu_fortran)
endif()
if(FSZ_BUILD_TESTS)
add_executable(fsz_test_fortran fortran/test_fsz.f90)
target_link_libraries(fsz_test_fortran PRIVATE fsz_fortran)
add_test(NAME fortran COMMAND fsz_test_fortran)
if(SZGPU_BUILD_TESTS)
add_executable(szgpu_test_fortran fortran/test_szgpu.f90)
target_link_libraries(szgpu_test_fortran PRIVATE szgpu_fortran)
add_test(NAME fortran COMMAND szgpu_test_fortran)
endif()
install(TARGETS fsz_fortran
install(TARGETS szgpu_fortran
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fortran_modules/fsz.mod
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fsz)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fortran_modules/szgpu.mod
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/szgpu)
else()
message(STATUS "FSZ: no Fortran compiler found; skipping the Fortran interface")
message(STATUS "SZ-GPU: no Fortran compiler found; skipping the Fortran interface")
endif()
endif()

install(TARGETS fsz EXPORT fszTargets
install(TARGETS szgpu EXPORT szgpuTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(FSZ_BUILD_SHARED)
install(TARGETS fsz_shared EXPORT fszTargets
if(SZGPU_BUILD_SHARED)
install(TARGETS szgpu_shared EXPORT szgpuTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(FSZ_BUILD_TOOLS)
install(TARGETS fsz_cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if(SZGPU_BUILD_TOOLS)
install(TARGETS szgpu_cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(EXPORT fszTargets
FILE fszTargets.cmake
NAMESPACE fsz::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fsz)
install(EXPORT szgpuTargets
FILE szgpuTargets.cmake
NAMESPACE szgpu::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/szgpu)

configure_package_config_file(cmake/fszConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/fszConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fsz)
configure_package_config_file(cmake/szgpuConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/szgpuConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/szgpu)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/fszConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/szgpuConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/fszConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/fszConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fsz)
${CMAKE_CURRENT_BINARY_DIR}/szgpuConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/szgpuConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/szgpu)
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to FSZ
# Contributing to SZ-GPU

Bug reports, questions, and patches are welcome.

Expand All @@ -8,12 +8,12 @@ Please include:

- the GPU and its compute capability (`nvidia-smi --query-gpu=name,compute_cap --format=csv`),
- the CUDA toolkit version (`nvcc --version`),
- how FSZ was built (CMake or Makefile, and any options),
- how SZ-GPU was built (CMake or Makefile, and any options),
- the element count, dimensions, element type, and error bound,
- what you expected and what happened.

A reproducer that runs from the `fsz` tool is the most useful form, for example
`fsz -i field.f32 -eb rel 1e-3 -d 512 512 512`. If the data cannot be shared, a
A reproducer that runs from the `szgpu` tool is the most useful form, for example
`szgpu -i field.f32 -eb rel 1e-3 -d 512 512 512`. If the data cannot be shared, a
synthetic array that shows the same behavior works just as well.

For anything that looks like wrong output, please say whether the error bound
Expand All @@ -32,12 +32,12 @@ The suites cover the C and C++ APIs (`roundtrip`, `hostptr`) and the Fortran
interface (`fortran`). The Python tests run separately:

```bash
PYTHONPATH=python python3 python/tests/test_fsz.py
PYTHONPATH=python python3 python/tests/test_szgpu.py
```

## What a change needs

FSZ is an error-bounded compressor, so correctness has a specific meaning and
SZ-GPU is an error-bounded compressor, so correctness has a specific meaning and
patches are held to it:

1. **The bound holds.** Every reconstructed value must be within
Expand All @@ -46,9 +46,9 @@ patches are held to it:
2. **The stream does not move unintentionally.** A change meant to affect only
performance, memory, or the build must leave the compressed bytes identical.
The quickest check is to compress a field before and after and compare
checksums; `fsz -z -i field.f32 -o out.fsz -eb rel 1e-3` then `md5sum`.
checksums; `szgpu -z -i field.f32 -o out.szgpu -eb rel 1e-3` then `md5sum`.
3. **Deliberate format changes are versioned.** The container carries a version
field, and an existing `.fsz` file must keep decompressing. If it cannot,
field, and an existing `.szgpu` file must keep decompressing. If it cannot,
that is a major version.
4. **New behavior comes with a test.** Add the case to the suite that covers the
affected interface, and prefer a case that fails before the change.
Expand All @@ -61,7 +61,7 @@ patches are held to it:
- Follow the surrounding code: four-space indent, and the naming already in
each file.
- Comments explain why something is done, not what the line does.
- Keep the public headers free of implementation detail; `src/fsz_internal.cuh`
- Keep the public headers free of implementation detail; `src/szgpu_internal.cuh`
is where format constants live.

## License
Expand Down
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ GENCODE += -maxrregcount=96
endif

INCLUDE := -Iinclude -Isrc
SRC := src/fsz.cu
HDRS := include/fsz/fsz.h include/fsz/fsz.hpp src/fsz_internal.cuh src/fsz_kernels.cuh
SRC := src/szgpu.cu
HDRS := include/szgpu/szgpu.h include/szgpu/szgpu.hpp src/szgpu_internal.cuh src/szgpu_kernels.cuh

BUILD ?= build
LIB := $(BUILD)/libfsz.a
SHLIB := $(BUILD)/libfsz.so
TOOL := $(BUILD)/fsz
LIB := $(BUILD)/libszgpu.a
SHLIB := $(BUILD)/libszgpu.so
TOOL := $(BUILD)/szgpu
EXAMPLES := $(BUILD)/example_roundtrip $(BUILD)/example_hostptr
TESTS := $(BUILD)/test_roundtrip $(BUILD)/test_hostptr

Expand All @@ -45,10 +45,10 @@ all: lib tool examples tests
$(BUILD):
mkdir -p $(BUILD)

$(BUILD)/fsz.o: $(SRC) $(HDRS) | $(BUILD)
$(BUILD)/szgpu.o: $(SRC) $(HDRS) | $(BUILD)
$(NVCC) $(CXXFLAGS) $(GENCODE) -c $(SRC) -o $@ $(INCLUDE) -Xcompiler -fPIC

$(LIB): $(BUILD)/fsz.o
$(LIB): $(BUILD)/szgpu.o
ar rcs $@ $<

$(SHLIB): $(SRC) $(HDRS) | $(BUILD)
Expand All @@ -57,7 +57,7 @@ $(SHLIB): $(SRC) $(HDRS) | $(BUILD)
lib: $(LIB)
shared: $(SHLIB)

$(TOOL): tools/fsz.cu tools/fsz_file_format.hpp $(LIB)
$(TOOL): tools/szgpu.cu tools/szgpu_file_format.hpp $(LIB)
$(NVCC) $(CXXFLAGS) $(GENCODE) $< -o $@ $(INCLUDE) -Itools $(LIB)

tool: $(TOOL)
Expand All @@ -71,26 +71,26 @@ $(BUILD)/test_%: tests/test_%.cu $(LIB)
examples: $(EXAMPLES)
tests: $(TESTS)

# Fortran interface (optional): builds the fsz module plus its example and
# Fortran interface (optional): builds the szgpu module plus its example and
# test against the static library. Requires gfortran or a compatible FC.
ifeq ($(origin FC),default)
FC := gfortran
endif
CUDA_HOME ?= $(shell dirname $$(dirname $$(command -v nvcc)))

fortran: $(LIB) | $(BUILD)
$(FC) -O2 -J$(BUILD) -c fortran/fsz.f90 -o $(BUILD)/fsz_mod.o
$(FC) -O2 -I$(BUILD) fortran/example_fsz.f90 $(BUILD)/fsz_mod.o $(LIB) \
$(FC) -O2 -J$(BUILD) -c fortran/szgpu.f90 -o $(BUILD)/szgpu_mod.o
$(FC) -O2 -I$(BUILD) fortran/example_szgpu.f90 $(BUILD)/szgpu_mod.o $(LIB) \
-o $(BUILD)/example_fortran -L$(CUDA_HOME)/lib64 -lcudart -lstdc++
$(FC) -O2 -I$(BUILD) fortran/test_fsz.f90 $(BUILD)/fsz_mod.o $(LIB) \
$(FC) -O2 -I$(BUILD) fortran/test_szgpu.f90 $(BUILD)/szgpu_mod.o $(LIB) \
-o $(BUILD)/test_fortran -L$(CUDA_HOME)/lib64 -lcudart -lstdc++

PREFIX ?= /usr/local
install: $(LIB) $(TOOL)
install -d $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/include/fsz
install -d $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/include/szgpu
install -m 755 $(TOOL) $(PREFIX)/bin/
install -m 644 $(LIB) $(PREFIX)/lib/
install -m 644 include/fsz/fsz.h include/fsz/fsz.hpp $(PREFIX)/include/fsz/
install -m 644 include/szgpu/szgpu.h include/szgpu/szgpu.hpp $(PREFIX)/include/szgpu/

clean:
rm -rf $(BUILD)
Loading
Loading