[med-svn] [Git][med-team/scrappie][master] 3 commits: ignore the root Makefile, use cmake
Nilesh Patra
gitlab at salsa.debian.org
Mon Dec 7 16:22:38 GMT 2020
Nilesh Patra pushed to branch master at Debian Med / scrappie
Commits:
267251cf by Michael R. Crusoe at 2020-12-07T18:33:37+05:30
ignore the root Makefile, use cmake
- - - - -
67136c72 by Nilesh Patra at 2020-12-07T18:38:57+05:30
Tweak simde.patch
- - - - -
1fc19f01 by Nilesh Patra at 2020-12-07T16:22:16+00:00
Attempt enabling simde-dispatch
- - - - -
4 changed files:
- + debian/bin/simd-dispatch
- debian/patches/simde.patch
- debian/rules
- − debian/scrappie.install
Changes:
=====================================
debian/bin/simd-dispatch
=====================================
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+BASE=/usr/bin/scrappie
+
+function test_and_run () {
+ if grep -q "$1" /proc/cpuinfo && [ -x "${BASE}-$1" ]; then
+ cmd="${BASE}-$1"
+ shift
+ # echo "${cmd}" "$@"
+ "${cmd}" "$@"
+ exit
+ fi
+}
+
+for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 sse ; do test_and_run ${SIMD} "$@" ; done
+
+# fallback to plain option
+$BASE-plain "$@"
+
=====================================
debian/patches/simde.patch
=====================================
@@ -24,32 +24,32 @@
# include <stdio.h>
--- a/src/sse_mathfun.h
+++ b/src/sse_mathfun.h
-@@ -40,8 +40,6 @@
+@@ -38,9 +38,8 @@
+ #pragma once
+ #ifndef SSE_MATHFUN_H
#define SSE_MATHFUN_H
-
-
--#include <xmmintrin.h>
-
+-
+-#include <xmmintrin.h>
++#define SIMDE_ENABLE_NATIVE_ALIASES
++#include <simde/x86/sse2.h>
+
/* yes I know, the top of this file is quite ugly */
- #ifdef _MSC_VER /* visual c++ */
-@@ -55,12 +53,10 @@
+@@ -55,12 +54,7 @@
/* __m128 is ugly to write */
typedef __m128 v4sf; // vector of 4 float (sse1)
-#ifdef USE_SSE2
-# include <emmintrin.h>
-+#define SIMDE_ENABLE_NATIVE_ALIASES
-+#include <simde/x86/sse2.h>
typedef __m128i v4si; // vector of 4 int (sse2)
-#else
-typedef __m64 v2si; // vector of 2 int (mmx)
-#endif
-+typedef float __v4sf __attribute__ ((__vector_size__ (16)));
/* declare some SSE constants -- why can't I figure a better way to do that? */
#define _PS_CONST(Name, Val) \
-@@ -99,61 +95,24 @@
+@@ -99,61 +93,24 @@
_PS_CONST(cephes_log_q1, -2.12194440e-4);
_PS_CONST(cephes_log_q2, 0.693359375);
@@ -111,7 +111,7 @@
e = _mm_add_ps(e, one);
-@@ -224,11 +183,7 @@
+@@ -224,11 +181,7 @@
static inline __attribute__((__always_inline__)) v4sf exp_ps(v4sf x) {
v4sf tmp = _mm_setzero_ps(), fx;
@@ -123,7 +123,7 @@
v4sf one = *(v4sf*)_ps_1;
x = _mm_min_ps(x, *(v4sf*)_ps_exp_hi);
-@@ -239,17 +194,9 @@
+@@ -239,17 +192,9 @@
fx = _mm_add_ps(fx, *(v4sf*)_ps_0p5);
/* how to perform a floorf with SSE: just below */
@@ -142,7 +142,7 @@
/* if greater, substract 1 */
v4sf mask = _mm_cmpgt_ps(tmp, fx);
mask = _mm_and_ps(mask, one);
-@@ -278,24 +225,10 @@
+@@ -278,24 +223,10 @@
y = _mm_add_ps(y, one);
/* build 2^n */
@@ -167,7 +167,7 @@
y = _mm_mul_ps(y, pow2n);
return y;
}
-@@ -342,12 +275,8 @@
+@@ -342,12 +273,8 @@
*/
static v4sf sin_ps(v4sf x) { // any x
v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, sign_bit, y;
@@ -181,7 +181,7 @@
sign_bit = x;
/* take the absolute value */
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
-@@ -357,7 +286,6 @@
+@@ -357,7 +284,6 @@
/* scale by 4/Pi */
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
@@ -189,7 +189,7 @@
/* store the integer part of y in mm0 */
emm2 = _mm_cvttps_epi32(y);
/* j=(j+1) & (~1) (see the cephes sources) */
-@@ -381,34 +309,6 @@
+@@ -381,34 +307,6 @@
v4sf poly_mask = _mm_castsi128_ps(emm2);
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
@@ -224,7 +224,7 @@
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
-@@ -459,18 +359,14 @@
+@@ -459,18 +357,14 @@
/* almost the same as sin_ps */
static v4sf cos_ps(v4sf x) { // any x
v4sf xmm1, xmm2 = _mm_setzero_ps(), xmm3, y;
@@ -244,7 +244,7 @@
/* store the integer part of y in mm0 */
emm2 = _mm_cvttps_epi32(y);
/* j=(j+1) & (~1) (see the cephes sources) */
-@@ -489,43 +385,7 @@
+@@ -489,43 +383,7 @@
v4sf sign_bit = _mm_castsi128_ps(emm0);
v4sf poly_mask = _mm_castsi128_ps(emm2);
@@ -288,7 +288,7 @@
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
-@@ -578,11 +438,8 @@
+@@ -578,11 +436,8 @@
it is almost as fast, and gives you a free cosine with your sine */
static void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
v4sf xmm1, xmm2, xmm3 = _mm_setzero_ps(), sign_bit_sin, y;
@@ -301,7 +301,7 @@
sign_bit_sin = x;
/* take the absolute value */
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
-@@ -592,7 +449,6 @@
+@@ -592,7 +447,6 @@
/* scale by 4/Pi */
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
@@ -309,7 +309,7 @@
/* store the integer part of y in emm2 */
emm2 = _mm_cvttps_epi32(y);
-@@ -612,40 +468,6 @@
+@@ -612,40 +466,6 @@
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
v4sf poly_mask = _mm_castsi128_ps(emm2);
@@ -350,7 +350,7 @@
/* The magic pass: "Extended precision modular arithmetic"
x = ((x - y * DP1) - y * DP2) - y * DP3; */
-@@ -659,23 +481,10 @@
+@@ -659,23 +479,10 @@
x = _mm_add_ps(x, xmm2);
x = _mm_add_ps(x, xmm3);
@@ -376,13 +376,14 @@
--- a/src/util.h
+++ b/src/util.h
-@@ -1,7 +1,8 @@
+@@ -1,7 +1,9 @@
#pragma once
#ifndef UTIL_H
# define UTIL_H
-# include <immintrin.h>
+# define SIMDE_ENABLE_NATIVE_ALIASES
+# include <simde/x86/avx.h>
++typedef simde_float32 __v4sf SIMDE_VECTOR(16);
# include <math.h>
# include <stdbool.h>
# include <stdint.h>
@@ -430,4 +431,28 @@
float viterbi_backtrace(float const *score, size_t n, const_scrappie_imatrix traceback, int * seq){
RETURN_NULL_IF(NULL == score, NAN);
RETURN_NULL_IF(NULL == seq, NAN);
-
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -94,9 +94,9 @@
+ ##
+ # Check whether compiler supports openmp.
+ ##
+-set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -Wall -Wno-unused-function -fstack-protector-all -fgnu89-inline -O3 -march=native -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE -DNDEBUG")
+-set (CMAKE_C_FLAGS_CHAOS "${CMAKE_C_FLAGS} -Wall -Wno-unused-function -fstack-protector-all -fgnu89-inline -g -march=native -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE -DNDEBUG -DCHAOSMONKEY=${CHAOSMONKEY}")
+-set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -Werror -Wall -Wno-cpp -DABORT_ON_NULL -Wno-unused-function -fstack-protector-all -fgnu89-inline -g -march=native -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE")
++set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -Wall -Wno-unused-function -fstack-protector-all -fgnu89-inline -O3 -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE -DNDEBUG")
++set (CMAKE_C_FLAGS_CHAOS "${CMAKE_C_FLAGS} -Wall -Wno-unused-function -fstack-protector-all -fgnu89-inline -g -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE -DNDEBUG -DCHAOSMONKEY=${CHAOSMONKEY}")
++set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -Werror -Wall -Wno-cpp -DABORT_ON_NULL -Wno-unused-function -fstack-protector-all -fgnu89-inline -g -std=c99 -DUSE_SSE2 -D__USE_MISC -D_POSIX_SOURCE")
+ # Check for OpenMP support in compiler
+ include (CheckCCompilerFlag)
+ check_c_compiler_flag ("-fopenmp" HAS_OPENMP)
+--- a/src/test/Makefile
++++ b/src/test/Makefile
+@@ -1,6 +1,6 @@
+ INCLUDE=-I..
+ LIBRARY=-lblas -lm
+-CFLAGS=-std=c11 -O3 -march=native
++CFLAGS=-std=c11 -O3
+
+ .PHONY: all
+ all: read_crp write_random_crp
=====================================
debian/rules
=====================================
@@ -7,5 +7,92 @@ export DEB_CXXFLAGS_MAINT_APPEND+=-DSIMDE_ENABLE_OPENMP -fopenmp-simd -O3
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
+binprefix=$(CURDIR)/debian/scrappie/usr/bin
+libexecdir=$(prefix)/lib/scrappie
+
%:
- dh $@
+ dh $@ --buildsystem=cmake
+
+override_dh_auto_configure:
+ifeq (amd64,$(DEB_HOST_ARCH))
+ for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 ; do \
+ export CXXFLAGS="$(CXXFLAGS) -m$${SIMD}" && export CFLAGS="$(CFLAGS) -m$${SIMD}" && \
+ dh_auto_configure --builddirectory build_$${SIMD} -- -DEXE_SUFFIX=-$${SIMD} ; \
+ done
+ export CXXFLAGS="$(CXXFLAGS)" && export CFLAGS="$(CFLAGS)" && \
+ dh_auto_configure --builddirectory build_plain -- -DEXE_SUFFIX=-plain
+else ifeq (i386,$(DEB_HOST_ARCH))
+ for SIMD in ssse3 sse3 sse2 ; do \
+ export CXXFLAGS="$(CXXFLAGS)" && export CFLAGS="$(CFLAGS) -m$${SIMD}" && \
+ dh_auto_configure --builddirectory build_$${SIMD} -- -DEXE_SUFFIX=-$${SIMD} ; \
+ done
+ export CXXFLAGS="$(CXXFLAGS)" && export CFLAGS="$(CFLAGS)" && \
+ dh_auto_configure --builddirectory build_plain -- -DEXE_SUFFIX=-plain
+else
+ dh_auto_configure
+endif
+
+override_dh_auto_build:
+ifeq (amd64,$(DEB_HOST_ARCH))
+ mkdir -p $(binprefix)
+ for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 ; do \
+ dh_auto_build --builddirectory build_$${SIMD} && \
+ cp build_$${SIMD}/scrappie build_$${SIMD}/scrappie-$${SIMD} ; \
+ done
+ dh_auto_build --builddirectory build_plain && \
+ cp build_plain/scrappie build_plain/scrappie-plain
+else ifeq (i386,$(DEB_HOST_ARCH))
+ mkdir -p $(binprefix)
+ for SIMD in ssse3 sse3 sse2 ; do \
+ dh_auto_build --builddirectory build_$${SIMD} && \
+ cp build_$${SIMD}/scrappie build_$${SIMD}/scrappie-$${SIMD} ; \
+ done
+ dh_auto_build --builddirectory build_plain && \
+ cp build_plain/scrappie build_plain/scrappie-plain
+else
+ dh_auto_build
+endif
+
+override_dh_auto_test:
+ifeq (amd64,$(DEB_HOST_ARCH))
+ for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 ; do \
+ dh_auto_test --builddirectory build_$${SIMD} ; \
+ done
+ dh_auto_test --builddirectory build_plain
+else ifeq (i386,$(DEB_HOST_ARCH))
+ for SIMD in ssse3 sse3 sse2 ; do \
+ dh_auto_test --builddirectory build_$${SIMD} ; \
+ done
+ dh_auto_test --builddirectory build_plain
+else
+ dh_auto_test
+endif
+
+override_dh_auto_install:
+ifeq (amd64,$(DEB_HOST_ARCH))
+ dh_install debian/bin/simd-dispatch /usr/lib/$(DEB_SOURCE)/
+ for SIMD in avx2 avx sse4.1 ssse3 sse3 sse2 ; do \
+ dh_auto_install --builddirectory build_$${SIMD} ; \
+ done
+ dh_install debian/bin/simd-dispatch /usr/lib/$(DEB_SOURCE)
+ dh_install build_*/scrappie-* /usr/bin/$(DEB_SOURCE)/
+ cd $(binprefix) && \
+ rm -rf scrappie && ln -s ../lib/$(DEB_SOURCE)/simd-dispatch scrappie
+else ifeq (i386,$(DEB_HOST_ARCH))
+ dh_install debian/bin/simd-dispatch /usr/lib/$(DEB_SOURCE)/
+ for SIMD in ssse3 sse3 sse2 ; do \
+ dh_auto_install --builddirectory build_$${SIMD} ; \
+ done
+ dh_install debian/bin/simd-dispatch /usr/lib/$(DEB_SOURCE)
+ dh_install build_*/scrappie-* /usr/bin/$(DEB_SOURCE)/
+ cd $(binprefix) && \
+ rm -rf scrappie && ln -s ../lib/$(DEB_SOURCE)/simd-dispatch scrappie
+else
+ dh_auto_install
+ dh_install usr/bin/scrappie usr/bin/
+endif
+
+override_dh_auto_clean:
+ dh_auto_clean
+ rm -Rf build_*
+
=====================================
debian/scrappie.install deleted
=====================================
@@ -1 +0,0 @@
-build/scrappie usr/bin
View it on GitLab: https://salsa.debian.org/med-team/scrappie/-/compare/d47c7b0f8d7e908cd3aefa2711f8c3f613e871fd...1fc19f0142a97a79d9eec52474ee76f9167be7a7
--
View it on GitLab: https://salsa.debian.org/med-team/scrappie/-/compare/d47c7b0f8d7e908cd3aefa2711f8c3f613e871fd...1fc19f0142a97a79d9eec52474ee76f9167be7a7
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20201207/57206248/attachment-0001.html>
More information about the debian-med-commit
mailing list