[med-svn] [Git][med-team/plink1-9][upstream] New upstream version 1.90~b6.6-181012

Dylan Aïssi gitlab at salsa.debian.org
Thu Nov 1 06:37:57 GMT 2018


Dylan Aïssi pushed to branch upstream at Debian Med / plink1.9


Commits:
868d9efd by Dylan Aïssi at 2018-11-01T06:30:14Z
New upstream version 1.90~b6.6-181012
- - - - -


9 changed files:

- Makefile
- Makefile.std
- plink.c
- plink_common.h
- plink_family.c
- plink_matrix.c
- plink_matrix.h
- plink_rserve.c
- toy.ped


Changes:

=====================================
Makefile
=====================================
@@ -31,7 +31,7 @@ CC ?=		gcc
 CXX ?=		g++
 CFLAGS ?=	-Wall -O2
 CXXFLAGS ?=	-Wall -O2
-BLASFLAGS ?=	-L/usr/lib64/atlas -llapack -lcblas -latlas
+BLASFLAGS ?=	-L/usr/lib64/atlas -llapack -lblas -lcblas -latlas
 LDFLAGS ?=	-lm -lpthread -ldl
 ZLIB ?=		../zlib-1.2.11/libz.so.1.2.11
 


=====================================
Makefile.std
=====================================
@@ -31,7 +31,7 @@ CC ?=		gcc
 CXX ?=		g++
 CFLAGS ?=	-Wall -O2
 CXXFLAGS ?=	-Wall -O2
-BLASFLAGS ?=	-L/usr/lib64/atlas -llapack -lcblas -latlas
+BLASFLAGS ?=	-L/usr/lib64/atlas -llapack -lblas -lcblas -latlas
 LDFLAGS ?=	-lm -lpthread -ldl
 ZLIB ?=		../zlib-1.2.11/libz.so.1.2.11
 


=====================================
plink.c
=====================================
@@ -93,7 +93,7 @@
 
 static const char ver_str[] =
 #ifdef STABLE_BUILD
-  "PLINK v1.90b6.5"
+  "PLINK v1.90b6.6"
 #else
   "PLINK v1.90p"
 #endif
@@ -105,7 +105,7 @@ static const char ver_str[] =
 #else
   " 32-bit"
 #endif
-  " (13 Sep 2018)";
+  " (12 Oct 2018)";
 static const char ver_str2[] =
   // include leading space if day < 10, so character length stays the same
   ""


=====================================
plink_common.h
=====================================
@@ -27,6 +27,9 @@
 #include <string.h>
 #include <math.h>
 #include <stdint.h>
+#ifndef __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS 1
+#endif
 #include <inttypes.h>
 
 // avoid compiler warning
@@ -59,7 +62,13 @@
   // needed for MEMORYSTATUSEX
   #ifndef _WIN64
     #define WINVER 0x0500
+  #else
+    #define __LP64__
   #endif
+  #ifndef WIN32_LEAN_AND_MEAN
+    #define WIN32_LEAN_AND_MEAN
+  #endif
+  #include <windows.h>
 #else // Unix
   #include <sys/stat.h>
 #endif
@@ -77,12 +86,13 @@
 #endif
 
 #ifdef _WIN32
-  #define PRId64 "I64d"
-  #define PRIu64 "I64u"
   #define fseeko fseeko64
   #define ftello ftello64
-  #include <windows.h>
   #include <process.h>
+#  undef PRId64
+#  undef PRIu64
+#  define PRId64 "I64d"
+#  define PRIu64 "I64u"
   #define pthread_t HANDLE
   #define THREAD_RET_TYPE unsigned __stdcall
   #define THREAD_RETURN return 0
@@ -96,8 +106,10 @@
     #define getc_unlocked getc
     #define putc_unlocked putc
   #endif
-  #define uint64_t unsigned long long
-  #define int64_t long long
+  #if __cplusplus < 201103L
+    #define uint64_t unsigned long long
+    #define int64_t long long
+  #endif
 #else
   #include <pthread.h>
   #define THREAD_RET_TYPE void*
@@ -144,6 +156,27 @@
 
 #ifdef __cplusplus
   #include <algorithm>
+#  ifdef _WIN32
+// Windows C++11 <algorithm> resets these values :(
+#    undef PRIu64
+#    undef PRId64
+#    define PRIu64 "I64u"
+#    define PRId64 "I64d"
+#    undef PRIuPTR
+#    undef PRIdPTR
+#    ifdef __LP64__
+#      define PRIuPTR PRIu64
+#      define PRIdPTR PRId64
+#    else
+#      if __cplusplus < 201103L
+#        define PRIuPTR "lu"
+#        define PRIdPTR "ld"
+#      else
+#        define PRIuPTR "u"
+#        define PRIdPTR "d"
+#      endif
+#    endif
+#  endif
   #define HEADER_INLINE inline
 #else
   #define HEADER_INLINE static inline
@@ -206,12 +239,12 @@
 
   #define ZEROLU 0LU
   #define ONELU 1LU
-  #ifndef PRIuPTR
-    #define PRIuPTR "lu"
-  #endif
-  #ifndef PRIdPTR
-    #define PRIdPTR "ld"
-  #endif
+#  if (__GNUC__ <= 4) && (__GNUC_MINOR__ < 8) && (__cplusplus < 201103L)
+#    undef PRIuPTR
+#    undef PRIdPTR
+#    define PRIuPTR "lu"
+#    define PRIdPTR "ld"
+#  endif
   #define PRIxPTR2 "08lx"
 
   // todo: update code so this still works when reduced to 4


=====================================
plink_family.c
=====================================
@@ -1749,6 +1749,7 @@ int32_t tdt_poo(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* o
   // entry bit 16 & 24: hhh?
   // entry bit 17: paternal A1 transmitted?
   // entry bit 25: maternal A1 transmitted?
+  // bugfix (10 Oct 2018): missed a few chrX possibilities
   const uint32_t poo_table[] =
     {0, 0, 0, 0,
      0, 0, 0, 0,
@@ -1758,10 +1759,10 @@ int32_t tdt_poo(pthread_t* threads, FILE* bedfile, uintptr_t bed_offset, char* o
      0, 0, 0, 0,
      0, 0, 0, 0,
      0, 0, 0, 0,
-     0x2000200, 0, 0x200, 0,
+     0x2000200, 0, 0x200, 0x200,
      0, 0, 0, 0,
      0x2020202, 0, 0x1010202, 0x202,
-     0, 0, 0x2000200, 0x200,
+     0x2000200, 0, 0x2000200, 0x200,
      0, 0, 0, 0,
      0, 0, 0, 0,
      0, 0, 0x20002, 2};


=====================================
plink_matrix.c
=====================================
@@ -20,9 +20,9 @@
 #include "plink_matrix.h"
 
 #ifndef NOLAPACK
-#ifndef __APPLE__
+#  ifndef __APPLE__
   void xerbla_(void) {} // fix static linking error
-#endif
+#  endif
 #endif
 
 static inline double SQR(const double a) {
@@ -286,7 +286,7 @@ int32_t invert_matrix(int32_t dim, double* matrix, MATRIX_INVERT_BUF1_TYPE* dbl_
   }
   return 0;
 }
-#else
+#else  // !NOLAPACK
 int32_t invert_matrix(__CLPK_integer dim, double* matrix, MATRIX_INVERT_BUF1_TYPE* int_1d_buf, double* dbl_2d_buf) {
   // dgetrf_/dgetri_ is more efficient than dpotrf_/dpotri_ on OS X.
   __CLPK_integer lwork = dim * dim;
@@ -321,7 +321,7 @@ int32_t invert_matrix_checked(__CLPK_integer dim, double* matrix, MATRIX_INVERT_
   dgetri_(&dim, matrix, &dim, int_1d_buf, dbl_2d_buf, &lwork, &info);
   return 0;
 }
-#endif
+#endif  // !NOLAPACK
 
 void col_major_matrix_multiply(__CLPK_integer row1_ct, __CLPK_integer col2_ct, __CLPK_integer common_ct, double* inmatrix1, double* inmatrix2, double* outmatrix) {
 #ifdef NOLAPACK
@@ -345,15 +345,15 @@ void col_major_matrix_multiply(__CLPK_integer row1_ct, __CLPK_integer col2_ct, _
     }
   }
 #else
-#ifdef _WIN32
+#  ifndef USE_CBLAS_XGEMM
   char blas_char = 'N';
   double dyy = 1;
   double dzz = 0;
   dgemm_(&blas_char, &blas_char, &row1_ct, &col2_ct, &common_ct, &dyy, inmatrix1, &row1_ct, inmatrix2, &common_ct, &dzz, outmatrix, &row1_ct);
-#else
+#  else
   cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, row1_ct, col2_ct, common_ct, 1.0, inmatrix1, row1_ct, inmatrix2, common_ct, 0.0, outmatrix, row1_ct);
-#endif // _WIN32
-#endif // NOLAPACK
+#  endif  // USE_CBLAS_XGEMM
+#endif  // !NOLAPACK
 }
 
 void col_major_fmatrix_multiply(__CLPK_integer row1_ct, __CLPK_integer col2_ct, __CLPK_integer common_ct, float* inmatrix1, float* inmatrix2, float* outmatrix) {
@@ -378,15 +378,15 @@ void col_major_fmatrix_multiply(__CLPK_integer row1_ct, __CLPK_integer col2_ct,
     }
   }
 #else
-#ifdef _WIN32
+#  ifndef USE_CBLAS_XGEMM
   char blas_char = 'N';
   float fyy = 1;
   float fzz = 0;
   sgemm_(&blas_char, &blas_char, &row1_ct, &col2_ct, &common_ct, &fyy, inmatrix1, &row1_ct, inmatrix2, &common_ct, &fzz, outmatrix, &row1_ct);
-#else
+#  else
   cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, row1_ct, col2_ct, common_ct, 1.0, inmatrix1, row1_ct, inmatrix2, common_ct, 0.0, outmatrix, row1_ct);
-#endif // _WIN32
-#endif // NOLAPACK
+#  endif  // USE_CBLAS_XGEMM
+#endif  // !NOLAPACK
 }
 
 // Todo: replace these with cache-oblivious, or at least -friendlier,


=====================================
plink_matrix.h
=====================================
@@ -19,66 +19,118 @@
 
 
 // Wrappers for frequent LAPACK calls (sometimes with no-LAPACK fallbacks).
-// May want to make this comprehensive to make linking with Intel MKL practical
-// in the future.
-
-// todo: allow this to take advantage of 64-bit integer LAPACK.  As of this
-// writing, it's available on Amazon EC2 64-bit Linux instances, but I can't
-// find it for Windows.  (And even if OS X vecLib adds it soon, we can't use it
-// there anytime soon because static linking is not an option.)
-
-#ifdef __APPLE__
-#include <Accelerate/Accelerate.h>
-#endif
+// (Update, 11 Oct 2018: Backported PLINK 2.0's MKL support.)
 
 #ifdef NOLAPACK
 
-#define MATRIX_INVERT_BUF1_TYPE double
-#define MATRIX_INVERT_BUF1_ELEM_ALLOC (2 * sizeof(double))
-#define MATRIX_INVERT_BUF1_CHECKED_ALLOC (2 * sizeof(double))
-#define __CLPK_integer int
+#  define MATRIX_INVERT_BUF1_TYPE double
+#  define MATRIX_INVERT_BUF1_ELEM_ALLOC (2 * sizeof(double))
+#  define MATRIX_INVERT_BUF1_CHECKED_ALLOC (2 * sizeof(double))
+#  define __CLPK_integer int
 
-#else // not NOLAPACK
+#else // !NOLAPACK
 
-#ifndef __APPLE__
+#  ifdef __APPLE__
+#    include <Accelerate/Accelerate.h>
+#    define USE_CBLAS_XGEMM
+#  endif
 
-#ifdef __cplusplus
+#  ifndef __APPLE__
+
+#    ifdef __cplusplus
 extern "C" {
-#endif
+#    endif
+
   typedef double __CLPK_doublereal;
-#ifdef _WIN32
-#define HAVE_LAPACK_CONFIG_H
-#define LAPACK_COMPLEX_STRUCTURE
-#include "lapack/lapacke/include/lapacke.h"
+#    if defined(__LP64__) || defined(_WIN32)
   typedef int32_t __CLPK_integer;
+#    else
+  typedef long int __CLPK_integer;
+#    endif
+
+#    ifdef _WIN32
+  // openblas is easy enough to set up on Windows nowadays.
+  // not worth the trouble of ripping out vector extensions, etc. just so we
+  // can compile with Visual Studio and gain access to MKL.
+  // (todo: upgrade from 0.2.19 to a later version, build setup will probably
+  // need to change a bit)
+#     define HAVE_LAPACK_CONFIG_H
+#     define LAPACK_COMPLEX_STRUCTURE
+#     include "lapacke.h"
+
+  __CLPK_doublereal ddot_(__CLPK_integer* n, __CLPK_doublereal* dx,
+                          __CLPK_integer* incx, __CLPK_doublereal* dy,
+                          __CLPK_integer* incy);
 
   void dger_(int* m, int* n, double* alpha, double* x, int* incx, double* y,
              int* incy, double* a, int* lda);
 
-  void dgemm_(char* transa, char* transb, int* m, int* n, int* k,
-              double* alpha, double* a, int* lda, double* b, int* ldb,
-              double* beta, double* c, int* ldc);
+  void dgemm_(char* transa, char* transb, __CLPK_integer* m, __CLPK_integer* n,
+              __CLPK_integer* k, double* alpha, double* a, __CLPK_integer* lda,
+              double* b, __CLPK_integer* ldb, double* beta, double* c,
+              __CLPK_integer* ldc);
 
   void dsymv_(char* uplo, int* n, double* alpha, double* a, int* lda,
               double* x, int* incx, double* beta, double* y, int* incy);
 
-  double ddot_(int* n, double* dx, int* incx, double* dy, int* incy);
-
   void dgetrf_(__CLPK_integer* m, __CLPK_integer* n,
                __CLPK_doublereal* a, __CLPK_integer* lda,
                __CLPK_integer* ipiv, __CLPK_integer* info);
 
-  void sgemm_(char* transa, char* transb, int* m, int* n, int* k,
-              float* alpha, float* a, int* lda, float* b, int* ldb,
-              float* beta, float* c, int* ldc);
+  void sgemm_(char* transa, char* transb, __CLPK_integer* m, __CLPK_integer* n,
+              __CLPK_integer* k, float* alpha, float* a, __CLPK_integer* lda,
+              float* b, __CLPK_integer* ldb, float* beta, float* c,
+              __CLPK_integer* ldc);
+
+#    else  // Linux
+#      ifdef USE_MKL
+#        ifndef __LP64__
+#          error "32-bit Linux build does not support Intel MKL."
+#        endif
+#        define USE_CBLAS_XGEMM
+  // sizeof(MKL_INT) should be 4.
+#        define MKL_LP64
+#        ifdef DYNAMIC_MKL
+#          include <mkl_service.h>
+#          include <mkl_cblas.h>
+#          include <mkl_lapack.h>
+#        else
+#          include "mkl_service.h"
+#          include "mkl_cblas.h"
+#          include "mkl_lapack.h"
+#        endif
+#      else
+#        ifdef USE_CBLAS_XGEMM
+#          include <cblas.h>
+#        else
+  // ARGH
+  // cmake on Ubuntu 14 seems to require use of cblas_f77.h instead of cblas.h.
+  // Conversely, cblas_f77.h does not seem to be available on the Scientific
+  // Linux ATLAS/LAPACK install, and right now that's my only option for
+  // producing 32-bit static builds...
+  // So.  Default include is cblas.h.  To play well with cmake + Ubuntu 14 and
+  // 16 simultaneously, there is a CBLAS_F77_ON_OLD_GCC mode which picks
+  // cblas_f77.h on Ubuntu 14 and cblas.h on 16.
+#          ifdef FORCE_CBLAS_F77
+#            include <cblas_f77.h>
+#          elif !defined(CBLAS_F77_ON_OLD_GCC)
+#            include <cblas.h>
+#          else
+#            if (__GNUC__ <= 4)
+#              include <cblas_f77.h>
+#            else
+#              if __has_include(<cblas.h>)
+#                include <cblas.h>
+#              else
+#                include <cblas_f77.h>
+#              endif
+#            endif
+#          endif
+  __CLPK_doublereal ddot_(__CLPK_integer* n, __CLPK_doublereal* dx,
+                          __CLPK_integer* incx, __CLPK_doublereal* dy,
+                          __CLPK_integer* incy);
+#        endif
 
-#else // not _WIN32
-#include <cblas.h>
-#ifdef __LP64__
-  typedef int32_t __CLPK_integer;
-#else
-  typedef long int __CLPK_integer;
-#endif
   int dgetrf_(__CLPK_integer* m, __CLPK_integer* n,
               __CLPK_doublereal* a, __CLPK_integer* lda,
               __CLPK_integer* ipiv, __CLPK_integer* info);
@@ -118,27 +170,46 @@ extern "C" {
                __CLPK_doublereal* vt, __CLPK_integer* ldvt,
                __CLPK_doublereal* work, __CLPK_integer* lwork,
                __CLPK_integer* iwork, __CLPK_integer* info);
-#endif
+
+#        ifndef USE_CBLAS_XGEMM
+  void dgemm_(char* transa, char* transb, __CLPK_integer* m, __CLPK_integer* n,
+              __CLPK_integer* k, double* alpha, double* a, __CLPK_integer* lda,
+              double* b, __CLPK_integer* ldb, double* beta, double* c,
+              __CLPK_integer* ldc);
+
+  void dsymv_(char* uplo, int* n, double* alpha, double* a, int* lda,
+              double* x, int* incx, double* beta, double* y, int* incy);
+
+  void sgemm_(char* transa, char* transb, __CLPK_integer* m, __CLPK_integer* n,
+              __CLPK_integer* k, float* alpha, float* a, __CLPK_integer* lda,
+              float* b, __CLPK_integer* ldb, float* beta, float* c,
+              __CLPK_integer* ldc);
+#        endif
+
+#      endif  // !USE_MKL
+#    endif
+
 
   void xerbla_(void);
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-#endif // __APPLE__
+#    ifdef __cplusplus
+} // extern "C"
+#    endif
+
+#  endif  // !__APPLE__
 
-#define MATRIX_INVERT_BUF1_TYPE __CLPK_integer
-#define MATRIX_INVERT_BUF1_ELEM_ALLOC sizeof(__CLPK_integer)
+#  define MATRIX_INVERT_BUF1_TYPE __CLPK_integer
+#  define MATRIX_INVERT_BUF1_ELEM_ALLOC sizeof(__CLPK_integer)
 // invert_matrix_checked() usually requires a larger buffer
-#define MATRIX_INVERT_BUF1_CHECKED_ALLOC (2 * sizeof(__CLPK_integer))
+#  define MATRIX_INVERT_BUF1_CHECKED_ALLOC (2 * sizeof(__CLPK_integer))
 
-#endif // NOLAPACK
+#endif  // !NOLAPACK
 
 #define MATRIX_SINGULAR_RCOND 1e-14
 
 #ifdef NOLAPACK
 int32_t invert_matrix(int32_t dim, double* matrix, MATRIX_INVERT_BUF1_TYPE* dbl_1d_buf, double* dbl_2d_buf);
 
-#define invert_matrix_checked invert_matrix
+#  define invert_matrix_checked invert_matrix
 #else
 int32_t invert_matrix(__CLPK_integer dim, double* matrix, MATRIX_INVERT_BUF1_TYPE* int_1d_buf, double* dbl_2d_buf);
 


=====================================
plink_rserve.c
=====================================
@@ -20,14 +20,14 @@
 // gcc instead of g++.
 #if defined __cplusplus && !defined _WIN32
 
-#include "plink_common.h"
-#include "plink_cluster.h"
-
 #define MAIN
 #define SOCK_ERRORS
 #include "sisocks.h"
 #include "Rconnection.h"
 
+#include "plink_common.h"
+#include "plink_cluster.h"
+
 #define RPLUGIN_BLOCK_SIZE 100
 
 int32_t rserve_call(char* rplugin_fname, char* rplugin_host_or_socket, int32_t rplugin_port, uint32_t rplugin_debug, FILE* bedfile, uintptr_t bed_offset, uintptr_t marker_ct, uintptr_t unfiltered_marker_ct, uintptr_t* marker_exclude, uintptr_t* marker_reverse, char* marker_ids, uintptr_t max_marker_id_len, char** marker_allele_ptrs, uint32_t* marker_pos, uint32_t plink_maxsnp, Chrom_info* chrom_info_ptr, uintptr_t unfiltered_sample_ct, uintptr_t* pheno_nm, uint32_t pheno_nm_ct, uintptr_t* pheno_c, double* pheno_d, uint32_t cluster_ct, uint32_t* cluster_map, uint32_t* cluster_starts, uintptr_t covar_ct, double* covar_d, char* outname, char* outname_end) {


=====================================
toy.ped
=====================================
@@ -1,2 +1,2 @@
-1 1000000000 0 0 1 1 0 0 1 1
-1 1000000001 0 0 1 2 1 1 1 2
+1 1000000000 0 0 1 1 0 0 A A
+1 1000000001 0 0 1 2 C C A G



View it on GitLab: https://salsa.debian.org/med-team/plink1-9/commit/868d9efd315a33e16f52340ecbcb18e579f731e7

-- 
View it on GitLab: https://salsa.debian.org/med-team/plink1-9/commit/868d9efd315a33e16f52340ecbcb18e579f731e7
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/20181101/d10e13b2/attachment-0001.html>


More information about the debian-med-commit mailing list