Skip to content

Commit

Permalink
update zmatlib, use miniz, drop zlib for easy deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Aug 4, 2023
1 parent 4fbb4d6 commit 97fff3e
Show file tree
Hide file tree
Showing 21 changed files with 10,947 additions and 553 deletions.
20 changes: 4 additions & 16 deletions .github/workflows/build_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,6 @@ jobs:
cuda: '9.2.148'
method: 'network'
sub-packages: '["nvcc"]'
- name: Install Zlib Dev (Windows Only)
if: ${{ runner.os == 'Windows' }}
run: |
curl.exe --retry 3 -kL https://www.bruot.org/hp/media/files/libraries/zlib_1_2_11_msvc2017_64.zip --output zlib.zip
unzip zlib.zip -d zlib
mv zlib/msvc2017_64/* zlib/
mv zlib/include/zlib/* zlib/include
mv zlib/lib/zlib/* zlib/lib
perl -pi -e 's/#if 1\s+.*HAVE_UNISTD_H.*/#if 0/g' zlib/include/zconf.h
echo "CMAKE_INCLUDE_PATH=$PWD\zlib\include" >> $GITHUB_ENV
echo "CMAKE_LIBRARY_PATH=$PWD\zlib\lib" >> $GITHUB_ENV
rm zlib.zip
- name: Link libgomp.a (MacOS only)
if: ${{ runner.os == 'macOS' }}
run: |
Expand Down Expand Up @@ -138,7 +126,7 @@ jobs:
run: |
cd src
if [[ "$RUNNER_OS" == "Windows" ]]; then
make mex INCLUDES='-I"${{ env.CMAKE_INCLUDE_PATH }}"' LIBRARIES='../zlib/lib/zlibstatic.lib'
make mex INCLUDES='-I"${{ env.CMAKE_INCLUDE_PATH }}"'
objdump -p ../mcxlab/mcx.mexw* | grep "DLL Name:"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
which mex
Expand All @@ -155,13 +143,13 @@ jobs:
cd src
make clean
if [[ "$RUNNER_OS" == "Linux" ]]; then
make AR=g++ BACKEND=cudastatic USERLINKOPT='libzmat.a -Wl,-Bstatic -lgomp -lz -Wl,-Bdynamic'
make AR=g++ BACKEND=cudastatic USERLINKOPT='libzmat.a -Wl,-Bstatic -lgomp -Wl,-Bdynamic'
ldd ../bin/mcx
elif [[ "$RUNNER_OS" == "macOS" ]]; then
make BACKEND=cudastatic CC=gcc-10 CXX=g++-10
otool -L ../bin/mcx
else
make static INCLUDES='-I"${{ env.CMAKE_INCLUDE_PATH }}"' LIBRARIES='../zlib/lib/zlibstatic.lib' ZLIBFLAG=''
make static INCLUDES='-I"${{ env.CMAKE_INCLUDE_PATH }}"'
#objdump -p ../bin/mcx | grep "DLL Name:"
fi
- name: Build mcxstudio
Expand Down Expand Up @@ -203,7 +191,7 @@ jobs:
cp -a src/mcstudio/mcxshow.app bin
cp -a src/mcstudio/mcxviewer.app bin
elif [[ "$RUNNER_OS" == "Windows" ]]; then
rm -rf octave zlib cuda_installer* bin/mcx.lib bin/mcx.exp
rm -rf octave cuda_installer* bin/mcx.lib bin/mcx.exp
strip -S bin/*
upx/upx-4.0.2-win64/upx -9 bin/*
rm -rf upx
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/build_windows_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ jobs:
$CUDA_PATH=Get-ChildItem "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA" -filter "v*.*" -Directory | % { $_.fullname }
echo "CUDA_PATH=$CUDA_PATH" >> $env:GITHUB_ENV
echo "CUDA_TOOLKIT_ROOT_DIR=$CUDA_PATH" >> $env:GITHUB_ENV
- name: Install Zlib Dev
run: |
curl.exe --retry 3 -kL https://cytranet.dl.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-lib.zip --output zlib.zip
Expand-Archive .\zlib.zip -DestinationPath zlib\
echo "CMAKE_INCLUDE_PATH=$PWD\zlib\include" >> $env:GITHUB_ENV
echo "CMAKE_LIBRARY_PATH=$PWD\zlib\lib" >> $env:GITHUB_ENV
rm zlib.zip
- name: Build Wheels
run: |
cd pmcx/
Expand Down
12 changes: 1 addition & 11 deletions pmcx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Copyright: (C) Matin Raayai Ardakani (2022-2023) <raayaiardakani.m at northeastern.edu>
and Qianqian Fang (2019-2023) <q.fang at neu.edu>
- License: GNU Public License V3 or later
- Version: 0.0.14
- Version: 0.0.15
- URL: https://pypi.org/project/pmcx/
- Github: https://github.com/fangq/mcx

Expand Down Expand Up @@ -87,16 +87,6 @@ The NVIDIA GPU driver of the target system must support the selected CUDA toolki
CMake is also widely available on package managers across all operating systems.
Additionally, on Windows, make sure **Visual Studio's C++ CMake tools for Windows** is also installed by selecting its option
during installation.
* **Zlib Compression Development Headers**: On Linux, this is generally available via the built-in package manager. For
example, on Debian-based distributions like Ubuntu it is available via ```apt``` under the name ```zlib1g-dev```. On
macOS, brew provides it under the name ```zlib```. No packaged versions of Zlib are available for windows, therefore it must be
downloaded manually and added to the CMake environment variables in your working Powershell session:
```powershell
curl.exe --retry 3 -kL https://cytranet.dl.sourceforge.net/project/gnuwin32/zlib/1.2.3/zlib-1.2.3-lib.zip --output zlib.zip
Expand-Archive .\zlib.zip -DestinationPath zlib\
$env:CMAKE_INCLUDE_PATH=$PWD\zlib\include
$env:CMAKE_LIBRARY_PATH=$PWD\zlib\lib
```

### Build Steps
1. Ensure that ```cmake```, ```nvcc``` (NVIDIA CUDA Compiler) and the C/C++ compiler are all located over your ```PATH```.
Expand Down
2 changes: 1 addition & 1 deletion pmcx/pmcx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
# from .files import loadmc2, loadmch, load, save
from .bench import bench

__version__ = "0.0.14"
__version__ = "0.0.15"

__all__ = ("gpuinfo", "run", "bench", "detweight", "cwdref")
2 changes: 1 addition & 1 deletion pmcx/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def build_extension(self, ext):
setup(
name="pmcx",
packages=['pmcx'],
version="0.0.14",
version="0.0.15",
requires=['numpy'],
license='GPLv3+',
author="Matin Raayai Ardakani, Qianqian Fang",
Expand Down
3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ cmake_minimum_required(VERSION 3.3)

project(mcx)

find_package(ZLIB REQUIRED)
find_package(CUDA QUIET REQUIRED)

find_package(OpenMP REQUIRED)
Expand Down Expand Up @@ -50,6 +49,7 @@ set(
set(CMAKE_C_FLAGS "-g -Wall -std=c99 -fPIC")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../lib)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add include directories
include_directories(cjson ubj zmat zmat/easylzma)
Expand Down Expand Up @@ -91,7 +91,6 @@ target_link_libraries(
mcx-exe
mcx OpenMP::OpenMP_CXX
zmat
ZLIB::ZLIB
)

if (BUILD_PYTHON)
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ OUTPUT_DIR=$(MCXDIR)/bin
DOXY := doxygen
DOCDIR := $(MCXDIR)/doc
DOXYCFG=mcx_doxygen.cfg
ZMATLIB :=libzmat.a
ZLIBFLAG :=-lz
ZMATLIB :=lib/libzmat.a
ZLIBFLAG :=
USERLINKOPT?=$(ZMATLIB) $(ZLIBFLAG)

CUDART=-lcudart
Expand Down Expand Up @@ -94,7 +94,7 @@ ifeq ($(findstring _NT-,$(PLATFORM)), _NT-)
CPPFLAGS=-g
CUDA_STATIC=--cudart static $(NVCCOMP) -Xcompiler "-MT"
CPPOPT+=$(NVCCOMP)
ZLIBFLAG?=-lzlib
ZLIBFLAG?=
ZMATLIB :=zmat/zmatlib.obj zmat/lz4/lz4.obj zmat/lz4/lz4hc.obj zmat/easylzma/*.obj zmat/easylzma/pavlov/*.obj
USERLINKOPT:=${LIBRARIES} $(ZMATLIB) $(ZLIBFLAG)
else ifeq ($(findstring Darwin,$(PLATFORM)), Darwin)
Expand Down
7 changes: 6 additions & 1 deletion src/zmat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ find_package(ZLIB REQUIRED)
option(STATIC_LIB "Build static library" ON)

# C Options
set(CMAKE_C_FLAGS "-g -Wall -O3 -fPIC")
set(CMAKE_C_FLAGS "-g -Wall -O3 -fPIC -DNO_BLOSC2 -DNO_ZLIB -DNO_ZSTD -D_LARGEFILE64_SOURCE=1")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../)

# Add include directories
#include_directories(./)
include_directories(lz4)
include_directories(miniz)
include_directories(easylzma)
include_directories(easylzma/pavlov)

Expand All @@ -30,6 +31,8 @@ if(STATIC_LIB)
zmatlib.c
lz4/lz4.c
lz4/lz4hc.c
miniz/miniz.c
miniz/miniz.h
easylzma/compress.c
easylzma/decompress.c
easylzma/lzma_header.c
Expand All @@ -50,6 +53,8 @@ else()
zmatlib.c
lz4/lz4.c
lz4/lz4hc.c
miniz/miniz.c
miniz/miniz.h
easylzma/compress.c
easylzma/decompress.c
easylzma/lzma_header.c
Expand Down
Loading

0 comments on commit 97fff3e

Please sign in to comment.