[med-svn] [Git][med-team/kmc][master] 2 commits: Support non-x86 systems via libsimde-dev

Michael R. Crusoe gitlab at salsa.debian.org
Fri Jan 22 11:39:17 GMT 2021



Michael R. Crusoe pushed to branch master at Debian Med / kmc


Commits:
81f0b3e6 by Michael R. Crusoe at 2021-01-22T12:38:42+01:00
Support non-x86 systems via libsimde-dev

- - - - -
63615ec8 by Michael R. Crusoe at 2021-01-22T12:38:42+01:00
release 3.1.1+dfsg-2 to unstable

- - - - -


5 changed files:

- debian/changelog
- debian/control
- debian/patches/series
- + debian/patches/simde
- debian/rules


Changes:

=====================================
debian/changelog
=====================================
@@ -1,8 +1,14 @@
-kmc (3.1.1+dfsg-2) UNRELEASED; urgency=medium
+kmc (3.1.1+dfsg-2) unstable; urgency=medium
 
+  * Team upload.
+
+  [ Étienne Mollier ]
   * Remove non-portable -m64 flag put back by error.
 
- -- Étienne Mollier <etienne.mollier at mailoo.org>  Fri, 11 Dec 2020 00:07:16 +0100
+  [ Michael R. Crusoe ]
+  * Support non-x86 systems via libsimde-dev. Closes: #977498
+
+ -- Michael R. Crusoe <crusoe at debian.org>  Fri, 22 Jan 2021 11:53:55 +0100
 
 kmc (3.1.1+dfsg-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -13,7 +13,8 @@ Build-Depends: debhelper-compat (= 13),
                libbz2-dev,
                help2man,
                asciidoctor,
-               d-shlibs
+               d-shlibs,
+               libsimde-dev
 Standards-Version: 4.5.1
 Vcs-Browser: https://salsa.debian.org/med-team/kmc
 Vcs-Git: https://salsa.debian.org/med-team/kmc.git
@@ -22,6 +23,7 @@ Rules-Requires-Root: no
 
 Package: kmc
 Architecture: any
+Built-Using: ${simde:Built-Using}
 Depends: ${shlibs:Depends},
          ${misc:Depends}
 Description: count kmers in genomic sequences
@@ -48,6 +50,7 @@ Description: count kmers in genomic sequences
  order of the size of input data (usually it is smaller).
 
 Package: libkmc-dev
+Built-Using: ${simde:Built-Using}
 Architecture: any
 Section: libdevel
 Depends: ${shlibs:Depends},


=====================================
debian/patches/series
=====================================
@@ -4,3 +4,4 @@ makefile.patch
 newish_gcc_build_fix.patch
 disable-python-bindings.patch
 spelling.patch
+simde


=====================================
debian/patches/simde
=====================================
@@ -0,0 +1,179 @@
+Author: Michael R. Crusoe <crusoe at debian.org>
+Description: support non-x86 systems via libsimde-dev
+--- kmc.orig/kmer_counter/cpu_info.cpp
++++ kmc/kmer_counter/cpu_info.cpp
+@@ -38,6 +38,7 @@
+ 	string vendor, brand;
+ 	void cpuid(int *result, int function_id) const
+ 	{
++#if defined(__x86_64__) || defined(__i386__)
+ #ifdef _MSC_VER
+ 		__cpuidex(result, function_id, 0);
+ 
+@@ -53,10 +54,12 @@
+ 		__asm__("cpuid\n\t"
+ 			: "=a" (result[0]), "=b" (result[1]), "=c" (result[2]), "=d" (result[3]) : "0" (function_id), "c"(0));
+ #endif  
++#endif
+ 	}
+ 
+ 	CpuInfoImpl()
+ 	{
++#if defined(__x86_64__) || defined(__i386__)
+ 		array<int, 4> cpui = { -1 };
+ 		cpuid(cpui.data(), 0);
+ 		int nIds_ = cpui[0];
+@@ -90,6 +93,9 @@
+ 			std::bitset<32> EBX = data_[7][1];
+ 			avx2 = EBX[5];
+ 		}
++#else
++		sse2=true;
++#endif
+ 	}
+ 
+ 	const string& GetVendor() const
+@@ -145,4 +151,4 @@
+ bool CCpuInfo::AVX_Enabled() { return cpu_info_impl.avx; }
+ bool CCpuInfo::AVX2_Enabled() { return cpu_info_impl.avx2; }
+ 
+-// ***** EOF
+\ No newline at end of file
++// ***** EOF
+--- kmc.orig/kmer_counter/intr_copy.h
++++ kmc/kmer_counter/intr_copy.h
+@@ -11,8 +11,8 @@
+ #ifndef _INTR_COPY_H
+ #define _INTR_COPY_H
+ 
+-#include <emmintrin.h>
+-#include <immintrin.h>
++#define SIMDE_ENABLE_NATIVE_ALIASES
++#include <simde/x86/sse2.h> 
+ 
+ #ifndef WIN32
+ typedef long long __int64;
+@@ -89,4 +89,4 @@
+ 
+ #endif
+ 
+-// ***** EOF
+\ No newline at end of file
++// ***** EOF
+--- kmc.orig/kmer_counter/kmc.h
++++ kmc/kmer_counter/kmc.h
+@@ -1112,6 +1112,8 @@
+ #ifdef __APPLE__
+ 	sort_func = RadixSort::RadixSortMSD<CKmer<SIZE>, SIZE>;
+ 	CSmallSort<SIZE>::Adjust(384);
++#elif !defined(__x86_64__) && !defined(__i386__)
++	sort_func = RadulsSort::RadixSortMSD_SSE2<CKmer<SIZE>>;
+ #else	
+ 	auto proc_name = CCpuInfo::GetBrand();
+ 	bool is_intel = CCpuInfo::GetVendor() == "GenuineIntel";
+--- kmc.orig/makefile
++++ kmc/makefile
+@@ -30,11 +30,16 @@
+ $(KMC_MAIN_DIR)/kmer.o \
+ $(KMC_MAIN_DIR)/splitter.o \
+ $(KMC_MAIN_DIR)/kb_collector.o
++ifeq (1,$(SIMD))
+ RADULS_OBJS = \
+ $(KMC_MAIN_DIR)/raduls_sse2.o \
+ $(KMC_MAIN_DIR)/raduls_sse41.o \
+ $(KMC_MAIN_DIR)/raduls_avx2.o \
+ $(KMC_MAIN_DIR)/raduls_avx.o
++else
++RADULS_OBJS = \
++$(KMC_MAIN_DIR)/raduls_sse2.o
++endif
+ 
+ KMC_DUMP_OBJS = \
+ $(KMC_DUMP_DIR)/nc_utils.o \
+@@ -66,6 +71,7 @@
+ $(KMC_TOOLS_OBJS): %.o: %.cpp
+ 	$(CXX) $(CPPFLAGS) $(KMC_TOOLS_CXXFLAGS) -c $< -o $@
+ 
++ifeq (1,$(SIMD))
+ $(KMC_MAIN_DIR)/raduls_sse2.o: $(KMC_MAIN_DIR)/raduls_sse2.cpp
+ 	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -msse2 -c $< -o $@
+ $(KMC_MAIN_DIR)/raduls_sse41.o: $(KMC_MAIN_DIR)/raduls_sse41.cpp
+@@ -74,6 +80,10 @@
+ 	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -mavx -c $< -o $@
+ $(KMC_MAIN_DIR)/raduls_avx2.o: $(KMC_MAIN_DIR)/raduls_avx2.cpp
+ 	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -mavx2 -c $< -o $@
++else
++$(KMC_MAIN_DIR)/raduls_sse2.o: $(KMC_MAIN_DIR)/raduls_sse2.cpp
++	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
++endif
+ 
+ kmc: $(KMC_OBJS) $(RADULS_OBJS)
+ 	-mkdir -p $(KMC_BIN_DIR)
+--- kmc.orig/kmer_counter/splitter.cpp
++++ kmc/kmer_counter/splitter.cpp
+@@ -350,7 +350,7 @@
+ 				if (!both_strands && is_rev_comp) //if read is reversed and kmc was run to count all (not only canonical) kmers read must be transformed back
+ 				{
+ 					//static const char rev_maping[] = "=TGMCRSVAWYHKDBN";
+-					static const char rev_maping[] = { -1, 3, 2, -1, 1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1 };// "=TGMCRSVAWYHKDBN";
++					static const int rev_maping[] = { -1, 3, 2, -1, 1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1 };// "=TGMCRSVAWYHKDBN";
+ 					uint32 n_bytes = l_seq / 2;
+ 					uint64_t pos_after = pos + l_seq;
+ 					pos = pos_after;
+@@ -369,7 +369,7 @@
+ 				}
+ 				else
+ 				{
+-					static const char maping[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1 };//"=ACMGRSVTWYHKDBN";
++					static const int maping[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1 };//"=ACMGRSVTWYHKDBN";
+ 					uint32 n_bytes = l_seq / 2;
+ 					for (uint32_t ii = 0; ii < n_bytes; ++ii)
+ 					{
+@@ -956,4 +956,4 @@
+ template class CWSmallKSplitter<uint32>;
+ template class CWSmallKSplitter<uint64>;
+ 
+-// ***** EOF
+\ No newline at end of file
++// ***** EOF
+--- kmc.orig/kmer_counter/raduls.h
++++ kmc/kmer_counter/raduls.h
+@@ -23,7 +23,7 @@
+ {
+ 	template<typename KMER_T>
+ 	void RadixSortMSD_SSE2(KMER_T* kmers, KMER_T* tmp, uint64 n_recs, uint32 byte, uint32 n_threads, CMemoryPool* pmm_radix_buf);
+-
++#if defined(__x86_64__) || defined(__i386__)
+ 	template<typename KMER_T>
+ 	void RadixSortMSD_SSE41(KMER_T* kmers, KMER_T* tmp, uint64 n_recs, uint32 byte, uint32 n_threads, CMemoryPool* pmm_radix_buf);
+ 
+@@ -32,8 +32,9 @@
+ 
+ 	template<typename KMER_T>
+ 	void RadixSortMSD_AVX2(KMER_T* kmers, KMER_T* tmp, uint64 n_recs, uint32 byte, uint32 n_threads, CMemoryPool* pmm_radix_buf);
++#endif
+ }
+ 
+ #endif // RADULS_H
+ 
+-// ***** EOF
+\ No newline at end of file
++// ***** EOF
+--- kmc.orig/kmer_counter/raduls_impl.h
++++ kmc/kmer_counter/raduls_impl.h
+@@ -730,7 +730,7 @@
+ #define RADULS_RADIX_SORT_FUNNAME RadixSortMSD_AVX
+ #elif defined(__SSE4_1__)
+ #define RADULS_RADIX_SORT_FUNNAME RadixSortMSD_SSE41
+-#elif defined(__SSE2__)
++#else
+ #define RADULS_RADIX_SORT_FUNNAME RadixSortMSD_SSE2
+ #endif
+ 
+@@ -769,4 +769,4 @@
+ 
+ #endif
+ 
+-// ***** EOF
+\ No newline at end of file
++// ***** EOF


=====================================
debian/rules
=====================================
@@ -3,15 +3,26 @@
 export DH_VERBOSE := 1
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
+export DEB_CFLAGS_MAINT_APPEND+=-DSIMDE_ENABLE_OPENMP -fopenmp-simd -O3
+export DEB_CXXFLAGS_MAINT_APPEND+=-DSIMDE_ENABLE_OPENMP -fopenmp-simd -O3
+
 include /usr/share/dpkg/default.mk
 DATE := $(SOURCE_DATE_EPOCH)
 
 mandir := $(CURDIR)/debian/man
 debfolder := $(CURDIR)/debian
 
+
 %:
 	dh $@
 
+override_dh_auto_build:
+ifneq (,$(filter $(DEB_HOST_ARCH),amd64 i386))
+	dh_auto_build -- SIMD=1
+else
+	dh_auto_build
+endif
+
 override_dh_install:
 	dh_install
 
@@ -26,3 +37,6 @@ override_dh_installman:
 	asciidoctor -a docdate='' -b manpage $(debfolder)/man_src/*.adoc
 	cp $(debfolder)/man_src/*.? $(mandir)
 	dh_installman --
+
+override_dh_gencontrol:
+	dh_gencontrol -- -Vsimde:Built-Using="$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W "libsimde-dev")"



View it on GitLab: https://salsa.debian.org/med-team/kmc/-/compare/7f6dd3e1ee626e102fe8de456e690f33aefa4cbf...63615ec8dbaee3262108178c990039f0bae8f872

-- 
View it on GitLab: https://salsa.debian.org/med-team/kmc/-/compare/7f6dd3e1ee626e102fe8de456e690f33aefa4cbf...63615ec8dbaee3262108178c990039f0bae8f872
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/20210122/86920013/attachment-0001.html>


More information about the debian-med-commit mailing list