Skip to content

Commit

Permalink
* Add presets for Hyperscan 5.2.1 (pull #849)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulDefender authored Mar 12, 2020
1 parent 14d34ae commit c181c45
Show file tree
Hide file tree
Showing 32 changed files with 3,609 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ environment:
OS: windows-x86_64
- PROJ: "hdf5"
OS: windows-x86_64
- PROJ: "hyperscan"
OS: windows-x86_64
- PROJ: "mkl"
OS: windows-x86_64
- PROJ: "mkl-dnn,dnnl"
Expand Down
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ matrix:
env: PROJ=hdf5 OS=linux-x86_64
install: true
script: ./ci/install-travis.sh
- os: linux
env: PROJ=hyperscan OS=linux-x86_64
install: true
script: ./ci/install-travis.sh
- os: linux
env: PROJ=mkl OS=linux-x86_64
install: true
Expand Down Expand Up @@ -486,6 +490,11 @@ matrix:
env: PROJ=hdf5 OS=macosx-x86_64
install: true
script: ./ci/install-travis.sh
- os: osx
osx_image: xcode9.3
env: PROJ=hyperscan OS=macosx-x86_64
install: true
script: ./ci/install-travis.sh
- os: osx
osx_image: xcode9.3
env: PROJ=mkl OS=macosx-x86_64
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Make sure `clone()` actually returns new `PIX`, `FPIX`, or `DPIX` objects with presets for Leptonica
* Add `opencv_python3` module and corresponding loader class with sample code to the presets for OpenCV
* Bundle OpenSSL in the presets for CPython for consistency across platforms ([issue #796](https://github.com/bytedeco/javacpp-presets/issues/796))
* Add presets for Arrow 0.16.0, SciPy 1.4.1 ([issue #747](https://github.com/bytedeco/javacpp-presets/issues/747)), Gym 0.17.1
* Add presets for Arrow 0.16.0, SciPy 1.4.1 ([issue #747](https://github.com/bytedeco/javacpp-presets/issues/747)), Gym 0.17.1, Hyperscan 5.2.1 ([pull #849](https://github.com/bytedeco/javacpp-presets/pull/849))
* Upgrade presets for OpenCV 4.2.0, FFmpeg 4.2.2, Spinnaker 1.27.0.48, HDF5 1.12.0, MKL 2020.0, MKL-DNN 0.21.4, DNNL 1.2.1, OpenBLAS 0.3.9, CPython 3.7.6, NumPy 1.18.1, LLVM 9.0.1, CUDA 10.2, cuDNN 7.6.5, NCCL 2.5.6, MXNet 1.6.0, TensorFlow 1.15.2, TensorRT 7.0, ALE 0.6.1, Leptonica 1.79.0, Tesseract 4.1.1, ONNX Runtime 1.1.2, Qt 5.14.1, Skia 1.68.1, and their dependencies

### November 5, 2019 version 1.5.2
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip
* flandmark 1.07 http://cmp.felk.cvut.cz/~uricamic/flandmark/#download
* Arrow 0.16.x https://arrow.apache.org/install/
* HDF5 1.12.0 https://www.hdfgroup.org/downloads/
* Hyperscan 5.2.x https://github.com/intel/hyperscan
* MKL 2020.0 https://software.intel.com/intel-mkl
* MKL-DNN 0.21.x https://github.com/intel/mkl-dnn
* DNNL 1.2.x https://github.com/intel/mkl-dnn
Expand Down
2 changes: 1 addition & 1 deletion ci/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if "%APPVEYOR_PULL_REQUEST_NUMBER%" == "" if "%APPVEYOR_REPO_BRANCH%" == "releas
rem C:\msys64\usr\bin\bash -lc "pacman -Syu --noconfirm"
rem C:\msys64\usr\bin\bash -lc "pacman -Su --noconfirm"
C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm base-devel git tar nasm yasm pkg-config unzip p7zip zip autoconf autoconf-archive automake libtool make patch gnupg"
C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-toolchain mingw-w64-x86_64-libtool mingw-w64-x86_64-gcc mingw-w64-i686-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-i686-gcc-fortran mingw-w64-x86_64-libwinpthread-git mingw-w64-i686-libwinpthread-git mingw-w64-x86_64-SDL mingw-w64-i686-SDL"
C:\msys64\usr\bin\bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-toolchain mingw-w64-x86_64-libtool mingw-w64-x86_64-gcc mingw-w64-i686-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-i686-gcc-fortran mingw-w64-x86_64-libwinpthread-git mingw-w64-i686-libwinpthread-git mingw-w64-x86_64-SDL mingw-w64-i686-SDL mingw-w64-x86_64-ragel"

SET "PATH=C:\Program Files\Python37;C:\Program Files (x86)\CMake\bin;C:\msys64\usr\bin\core_perl;C:\msys64\%MSYSTEM%\bin;C:\msys64\usr\bin;%PATH%"
C:\msys64\usr\bin\bash -c "ci/install-windows.sh %PROJ%"
Expand Down
7 changes: 4 additions & 3 deletions ci/install-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then export JAVA_HOME=$(/usr/libexec/java_hom
if [[ "$OS" == "linux-x86" ]] || [[ "$OS" == "linux-x86_64" ]] || [[ "$OS" =~ android ]]; then
CENTOS_VERSION=6
SCL_ENABLE="devtoolset-7 python27 rh-git29"
if [[ "mxnet tensorflow onnx ngraph onnxruntime qt skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then
if [[ "mxnet hyperscan tensorflow onnx ngraph onnxruntime qt skia " =~ "$PROJ " ]] || [[ "$OS" =~ android ]]; then
CENTOS_VERSION=7
SCL_ENABLE="devtoolset-7 rh-git218"
fi
Expand All @@ -58,7 +58,8 @@ if [[ "$OS" == "linux-x86" ]] || [[ "$OS" == "linux-x86_64" ]] || [[ "$OS" =~ an
DOCKER_CONTAINER_ID=$(docker ps | grep centos | awk '{print $1}')
echo "Container id is $DOCKER_CONTAINER_ID please wait while updates applied"
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install centos-release-scl-rh epel-release"
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install rh-java-common-ant $SCL_ENABLE ccache clang gcc-c++ gcc-gfortran java-1.8.0-openjdk-devel ant python python36-devel python36-pip swig git file which wget unzip tar bzip2 gzip xz patch make cmake3 autoconf-archive libtool bison flex perl nasm yasm alsa-lib-devel freeglut-devel gtk2-devel libusb-devel libusb1-devel zlib-devel SDL-devel libva-devel libxkbcommon-devel fontconfig-devel libffi-devel"
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -y repolist"
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -q -y --disablerepo=cuda install rh-java-common-ant $SCL_ENABLE ccache clang gcc-c++ gcc-gfortran java-1.8.0-openjdk-devel ant python python36-devel python36-pip swig git file which wget unzip tar bzip2 gzip xz patch make cmake3 autoconf-archive libtool bison flex perl nasm yasm alsa-lib-devel freeglut-devel gtk2-devel libusb-devel libusb1-devel zlib-devel SDL-devel libva-devel libxkbcommon-devel fontconfig-devel libffi-devel ragel"
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "yum -y --disablerepo=cuda update"
if [ "$OS" == "linux-x86" ]; then
docker exec -ti $DOCKER_CONTAINER_ID /bin/bash -xec "rpm -qa | sed s/.x86_64$/.i686/ | xargs yum -q -y --disablerepo=cuda install"
Expand Down Expand Up @@ -203,7 +204,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
echo "performing brew update and install of dependencies, please wait.."
brew update
brew upgrade cmake maven
brew install ccache swig autoconf-archive libtool libusb xz sdl gpg1 bison flex perl nasm yasm
brew install ccache swig autoconf-archive libtool libusb xz sdl gpg1 bison flex perl nasm yasm ragel

# Try to use ccache to speed up the build
export PATH=/usr/local/opt/ccache/libexec/:/usr/local/opt/gpg1/libexec/gpgbin/:/usr/local/opt/bison/bin/:/usr/local/opt/flex/bin/:$PATH
Expand Down
2 changes: 1 addition & 1 deletion cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function sedinplace {
}

if [[ -z ${PROJECTS:-} ]]; then
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems)
PROJECTS=(opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libpostal leptonica tesseract caffe cuda mxnet tensorflow tensorrt ale onnx ngraph onnxruntime liquidfun qt skia cpu_features systems)
fi

for PROJECT in ${PROJECTS[@]}; do
Expand Down
116 changes: 116 additions & 0 deletions hyperscan/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
Hyperscan is licensed under the BSD License.

Copyright (c) 2015, Intel Corporation

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------

This product also contains code from third parties, under the following
licenses:

Intel's Slicing-by-8 CRC32 implementation
-----------------------------------------

Copyright (c) 2004-2006, Intel Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Boost C++ Headers Library
-------------------------

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.


The Google C++ Testing Framework (Google Test)
----------------------------------------------

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
135 changes: 135 additions & 0 deletions hyperscan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
JavaCPP Presets for Hyperscan
=============================

Introduction
------------
This directory contains the JavaCPP Presets module for:

* Hyperscan 5.2.1 https://www.hyperscan.io

Please refer to the parent README.md file for more detailed information about the JavaCPP Presets.


Documentation
-------------
Java API documentation is available here:

* http://bytedeco.org/javacpp-presets/hyperscan/apidocs/


Sample Usage
------------
Here is a simple example of Hyperscan

We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `HyperscanTest.java` source files below, simply execute on the command line:
```bash
$ mvn compile exec:java
```

Be aware that flag `-Djavacpp.platform` can be used to specify the target platform when running the maven command above, for example:
```bash
$ mvn compile exec:java -Djavacpp.platform=linux-x86_64
```

### The `pom.xml` build file
```xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.bytedeco.hyperscan</groupId>
<artifactId>HyperscanTest</artifactId>
<version>1.5.3-SNAPSHOT</version>
<properties>
<exec.mainClass>HyperscanTest</exec.mainClass>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>hyperscan-platform</artifactId>
<version>5.2.1-1.5.3-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>.</sourceDirectory>
</build>
</project>
```

### The `HyperscanTest.java` source file
```java
import org.bytedeco.hyperscan.global.hyperscan;
import org.bytedeco.hyperscan.hs_compile_error_t;
import org.bytedeco.hyperscan.hs_database_t;
import org.bytedeco.hyperscan.hs_scratch_t;
import org.bytedeco.hyperscan.match_event_handler;
import org.bytedeco.javacpp.BytePointer;
import org.bytedeco.javacpp.IntPointer;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.PointerPointer;
import org.bytedeco.javacpp.annotation.Cast;

import static org.bytedeco.hyperscan.global.hyperscan.HS_FLAG_SINGLEMATCH;
import static org.bytedeco.hyperscan.global.hyperscan.HS_MODE_BLOCK;

public class HyperscanTest {

public static void main(String[] args) {
Loader.load(hyperscan.class);

String[] patterns = { "abc1", "asa", "dab" };
hs_database_t database_t = null;
match_event_handler matchEventHandler = null;
hs_scratch_t scratchSpace = new hs_scratch_t();
hs_compile_error_t compile_error_t;

try(PointerPointer<hs_database_t> database_t_p = new PointerPointer<hs_database_t>(1);
PointerPointer<hs_compile_error_t> compile_error_t_p = new PointerPointer<hs_compile_error_t>(1);
IntPointer compileFlags = new IntPointer(HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH, HS_FLAG_SINGLEMATCH);
IntPointer patternIds = new IntPointer(1, 1, 1);
PointerPointer expressionsPointer = new PointerPointer<BytePointer>(patterns)
) {

matchEventHandler = new match_event_handler() {
@Override
public int call(@Cast("unsigned int") int id,
@Cast("unsigned long long") long from,
@Cast("unsigned long long") long to,
@Cast("unsigned int") int flags, Pointer context) {
System.out.println(from + "-" + to);
System.out.println(id);
return 0;
}
};

int result = hyperscan.hs_compile_multi(expressionsPointer, compileFlags, patternIds, 3, HS_MODE_BLOCK,
null, database_t_p, compile_error_t_p);

database_t = new hs_database_t(database_t_p.get(0));
compile_error_t = new hs_compile_error_t(compile_error_t_p.get(0));
if (result != 0) {
System.out.println(compile_error_t.message().getString());
System.exit(1);
}
result = hyperscan.hs_alloc_scratch(database_t, scratchSpace);
if (result != 0) {
System.out.println("Error during scratch space allocation");
System.exit(1);
}

String textToSearch = "-21dasaaadabcaaa";
hyperscan.hs_scan(database_t, textToSearch, textToSearch.length(), 0, scratchSpace, matchEventHandler, expressionsPointer);

} finally {
hyperscan.hs_free_scratch(scratchSpace);
if (database_t != null) {
hyperscan.hs_free_database(database_t);
}
if (matchEventHandler != null) {
matchEventHandler.close();
}
}
}
}
```
Loading

0 comments on commit c181c45

Please sign in to comment.