]> granicus.if.org Git - libjpeg-turbo/commitdiff
Lay the groundwork for 64-bit AVX2 SIMD support
authorDRC <information@libjpeg-turbo.org>
Fri, 20 May 2016 15:45:32 +0000 (10:45 -0500)
committerDRC <information@libjpeg-turbo.org>
Wed, 1 Jun 2016 03:54:38 +0000 (22:54 -0500)
30 files changed:
jmemmgr.c
simd/CMakeLists.txt
simd/Makefile.am
simd/jccolext-sse2-64.asm
simd/jccolor-sse2-64.asm
simd/jcgray-sse2-64.asm
simd/jcgryext-sse2-64.asm
simd/jchuff-sse2-64.asm
simd/jcsample-sse2-64.asm
simd/jdcolext-sse2-64.asm
simd/jdcolor-sse2-64.asm
simd/jdmerge-sse2-64.asm
simd/jdmrgext-sse2-64.asm
simd/jdsample-sse2-64.asm
simd/jfdctflt-sse-64.asm
simd/jfdctfst-sse2-64.asm
simd/jfdctint-sse2-64.asm
simd/jidctflt-sse2-64.asm
simd/jidctfst-sse2-64.asm
simd/jidctint-sse2-64.asm
simd/jidctred-sse2-64.asm
simd/jquantf-sse2-64.asm
simd/jquanti-sse2-64.asm
simd/jsimd.h
simd/jsimd_x86_64.c
simd/jsimdcfg.inc.h
simd/jsimdcpu-64.asm [new file with mode: 0644]
simd/jsimdcpu.asm
simd/jsimdext.inc
win/jsimdcfg.inc

index 9174ad3ffb0b6d82bd919ca225d16982b1785d8e..7f6b1497e4938e33a8e0c5df7ab9afb5d495c67d 100644 (file)
--- a/jmemmgr.c
+++ b/jmemmgr.c
@@ -85,7 +85,9 @@ round_up_pow2 (size_t a, size_t b)
 #ifndef WITH_SIMD
 #define ALIGN_SIZE  sizeof(double)
 #else
-#define ALIGN_SIZE  16 /* Most SIMD implementations require this */
+#define ALIGN_SIZE  32 /* Most of the SIMD instructions we support require
+                          16-byte (128-bit) alignment, but AVX2 requires
+                          32-byte alignment. */
 #endif
 #endif
 
index 37938ecc714fb6defa6408f17303cea59b684604..2738c77213958a7ac8693b7a054596d363abc7e8 100755 (executable)
@@ -21,7 +21,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug"
 endif()
 
 if(SIMD_X86_64)
-  set(SIMD_BASENAMES jfdctflt-sse-64 jccolor-sse2-64 jcgray-sse2-64
+  set(SIMD_BASENAMES jsimdcpu-64 jfdctflt-sse-64 jccolor-sse2-64 jcgray-sse2-64
     jchuff-sse2-64 jcsample-sse2-64 jdcolor-sse2-64 jdmerge-sse2-64
     jdsample-sse2-64 jfdctfst-sse2-64 jfdctint-sse2-64 jidctflt-sse2-64
     jidctfst-sse2-64 jidctint-sse2-64 jidctred-sse2-64 jquantf-sse2-64
index fad6c8c8a5101359de079c674b024be1e57aa565..a9083859c7035cb732acc36488687f65e64f4c16 100644 (file)
@@ -12,7 +12,8 @@ EXTRA_DIST = nasm_lt.sh CMakeLists.txt \
 if SIMD_X86_64
 
 libsimd_la_SOURCES = jsimd_x86_64.c jsimd.h jsimdcfg.inc.h jsimdext.inc \
-       jcolsamp.inc jdct.inc jpeg_nbits_table.inc jfdctflt-sse-64.asm \
+       jcolsamp.inc jdct.inc jpeg_nbits_table.inc  jsimdcpu-64.asm \
+       jfdctflt-sse-64.asm \
        jccolor-sse2-64.asm   jcgray-sse2-64.asm    jchuff-sse2-64.asm \
        jcsample-sse2-64.asm  jdcolor-sse2-64.asm   jdmerge-sse2-64.asm \
        jdsample-sse2-64.asm  jfdctfst-sse2-64.asm  jfdctint-sse2-64.asm \
index 258dfad23c159ca983c339df86de404b0eb9e639..8fe072d08bd031c3c11a8126eb3d1c0affccfb30 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; jccolext.asm - colorspace conversion (64-bit SSE2)
 ;
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -36,7 +36,7 @@
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  8
 
-    align       16
+    align       32
 
     global      EXTN(jsimd_rgb_ycc_convert_sse2)
 
@@ -483,4 +483,4 @@ EXTN(jsimd_rgb_ycc_convert_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index af6e1e20f0a018dad445e7769482af5f6e1f5832..0482650c350a04f74e4a53d16975fa70329654bd 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; jccolor.asm - colorspace conversion (64-bit SSE2)
 ;
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +34,7 @@ F_0_337 equ (F_0_587 - F_0_250)  ; FIX(0.58700) - FIX(0.25000)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_rgb_ycc_convert_sse2)
 
 EXTN(jconst_rgb_ycc_convert_sse2):
@@ -46,7 +46,7 @@ PW_MF008_MF041  times 4 dw -F_0_081,-F_0_418
 PD_ONEHALFM1_CJ times 4 dd  (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS)
 PD_ONEHALF      times 4 dd  (1 << (SCALEBITS-1))
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
index 61c96827507457b63e8b00c93dcca3081c53e74b..116791854e5fcdb4b9c6de7a8cee53b50e2e56aa 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; jcgray.asm - grayscale colorspace conversion (64-bit SSE2)
 ;
-; Copyright (C) 2011, D. R. Commander.
+; Copyright (C) 2011, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -30,7 +30,7 @@ F_0_337 equ (F_0_587 - F_0_250)  ; FIX(0.58700) - FIX(0.25000)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_rgb_gray_convert_sse2)
 
 EXTN(jconst_rgb_gray_convert_sse2):
@@ -39,7 +39,7 @@ PW_F0299_F0337 times 4 dw F_0_299, F_0_337
 PW_F0114_F0250 times 4 dw F_0_114, F_0_250
 PD_ONEHALF     times 4 dd (1 << (SCALEBITS-1))
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
index 663104e3d2e6448100fb0f1de99f53a9b2d95afd..d26ada3dcc67672ffc8be7a65b7fe2d95fca04ec 100644 (file)
@@ -1,7 +1,7 @@
 ;
 ; jcgryext.asm - grayscale colorspace conversion (64-bit SSE2)
 ;
-; Copyright (C) 2011, D. R. Commander.
+; Copyright (C) 2011, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -36,7 +36,7 @@
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  2
 
-    align       16
+    align       32
 
     global      EXTN(jsimd_rgb_gray_convert_sse2)
 
@@ -362,4 +362,4 @@ EXTN(jsimd_rgb_gray_convert_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 486fd8040c7e67844fa3a88b7195caa8e1976116..91d8ecf0be5facd80e4069246e5a2f6191f2373c 100644 (file)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_huff_encode_one_block)
 
 EXTN(jconst_huff_encode_one_block):
 
 %include "jpeg_nbits_table.inc"
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -182,7 +182,7 @@ EXTN(jconst_huff_encode_one_block):
 %define put_bits    r9d
 %define buffer      rax
 
-    align       16
+    align       32
     global      EXTN(jsimd_huff_encode_one_block_sse2)
 
 EXTN(jsimd_huff_encode_one_block_sse2):
@@ -357,4 +357,4 @@ EXTN(jsimd_huff_encode_one_block_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 29fc9822cadfb71ae8eef03600573b7e1b551db1..2e5d3f5b06c44d1e4725824e0c2ab87c45cb6140 100644 (file)
@@ -2,7 +2,7 @@
 ; jcsample.asm - downsampling (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -39,7 +39,7 @@
 ; r14 = JSAMPARRAY input_data
 ; r15 = JSAMPARRAY output_data
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v1_downsample_sse2)
 
 EXTN(jsimd_h2v1_downsample_sse2):
@@ -183,7 +183,7 @@ EXTN(jsimd_h2v1_downsample_sse2):
 ; r14 = JSAMPARRAY input_data
 ; r15 = JSAMPARRAY output_data
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v2_downsample_sse2)
 
 EXTN(jsimd_h2v2_downsample_sse2):
@@ -326,4 +326,4 @@ EXTN(jsimd_h2v2_downsample_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index b48b2b7bb95365bae2602465b1d198d5bf40f27b..f49709ff419d8d2f592154e284956e13141110eb 100644 (file)
@@ -2,7 +2,7 @@
 ; jdcolext.asm - colorspace conversion (64-bit SSE2)
 ;
 ; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -37,7 +37,7 @@
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  2
 
-    align       16
+    align       32
     global      EXTN(jsimd_ycc_rgb_convert_sse2)
 
 EXTN(jsimd_ycc_rgb_convert_sse2):
@@ -437,4 +437,4 @@ EXTN(jsimd_ycc_rgb_convert_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 855badb731c7c691aa7385eab1043d578a15faf3..6701ee6a6b5cf0b63e39571627e2e3003a992fc6 100644 (file)
@@ -2,7 +2,7 @@
 ; jdcolor.asm - colorspace conversion (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +33,7 @@ F_0_228 equ (131072 - F_1_772)  ; FIX(2) - FIX(1.77200)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_ycc_rgb_convert_sse2)
 
 EXTN(jconst_ycc_rgb_convert_sse2):
@@ -44,7 +44,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
 PW_ONE          times 8 dw  1
 PD_ONEHALF      times 4 dd  1 << (SCALEBITS-1)
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
index dddefd897f87d657d19844d36aa881b7e016d5a7..4b2963962c51853e961d74ef507118d2a56339ae 100644 (file)
@@ -2,7 +2,7 @@
 ; jdmerge.asm - merged upsampling/color conversion (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -33,7 +33,7 @@ F_0_228 equ (131072 - F_1_772)  ; FIX(2) - FIX(1.77200)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_merged_upsample_sse2)
 
 EXTN(jconst_merged_upsample_sse2):
@@ -44,7 +44,7 @@ PW_MF0344_F0285 times 4 dw -F_0_344, F_0_285
 PW_ONE          times 8 dw  1
 PD_ONEHALF      times 4 dd  1 << (SCALEBITS-1)
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
index 93a3ef34c2c55b3d11cbb0dd991ced7d4909b126..4c2bb04938b6aa040108c7843f28361c806473f8 100644 (file)
@@ -2,7 +2,7 @@
 ; jdmrgext.asm - merged upsampling/color conversion (64-bit SSE2)
 ;
 ; Copyright 2009, 2012 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, 2012, D. R. Commander.
+; Copyright (C) 2009, 2012, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -37,7 +37,7 @@
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  3
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v1_merged_upsample_sse2)
 
 EXTN(jsimd_h2v1_merged_upsample_sse2):
@@ -444,7 +444,7 @@ EXTN(jsimd_h2v1_merged_upsample_sse2):
 ; r12d = JDIMENSION in_row_group_ctr
 ; r13 = JSAMPARRAY output_buf
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v2_merged_upsample_sse2)
 
 EXTN(jsimd_h2v2_merged_upsample_sse2):
@@ -534,4 +534,4 @@ EXTN(jsimd_h2v2_merged_upsample_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 11c3464f9eb2255c244e5d2dacf02abde94c9fdd..42a8e7842999289c6bf3e2719092279159c76a68 100644 (file)
@@ -2,7 +2,7 @@
 ; jdsample.asm - upsampling (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -21,7 +21,7 @@
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_fancy_upsample_sse2)
 
 EXTN(jconst_fancy_upsample_sse2):
@@ -32,7 +32,7 @@ PW_THREE times 8 dw 3
 PW_SEVEN times 8 dw 7
 PW_EIGHT times 8 dw 8
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -57,7 +57,7 @@ PW_EIGHT times 8 dw 8
 ; r12 = JSAMPARRAY input_data
 ; r13 = JSAMPARRAY *output_data_ptr
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v1_fancy_upsample_sse2)
 
 EXTN(jsimd_h2v1_fancy_upsample_sse2):
@@ -199,7 +199,7 @@ EXTN(jsimd_h2v1_fancy_upsample_sse2):
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  4
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v2_fancy_upsample_sse2)
 
 EXTN(jsimd_h2v2_fancy_upsample_sse2):
@@ -496,7 +496,7 @@ EXTN(jsimd_h2v2_fancy_upsample_sse2):
 ; r12 = JSAMPARRAY input_data
 ; r13 = JSAMPARRAY *output_data_ptr
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v1_upsample_sse2)
 
 EXTN(jsimd_h2v1_upsample_sse2):
@@ -585,7 +585,7 @@ EXTN(jsimd_h2v1_upsample_sse2):
 ; r12 = JSAMPARRAY input_data
 ; r13 = JSAMPARRAY *output_data_ptr
 
-    align       16
+    align       32
     global      EXTN(jsimd_h2v2_upsample_sse2)
 
 EXTN(jsimd_h2v2_upsample_sse2):
@@ -667,4 +667,4 @@ EXTN(jsimd_h2v2_upsample_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index cd481345946a6584232cb82e23e173820e7b4689..127ef28a51e07bc3bb0a09ae7c3cabc6be5b4caf 100644 (file)
@@ -2,7 +2,7 @@
 ; jfdctflt.asm - floating-point FDCT (64-bit SSE)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -36,7 +36,7 @@
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_fdct_float_sse)
 
 EXTN(jconst_fdct_float_sse):
@@ -46,7 +46,7 @@ PD_0_707 times 4 dd 0.707106781186547524400844
 PD_0_541 times 4 dd 0.541196100146196984399723
 PD_1_306 times 4 dd 1.306562964876376527856643
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -63,7 +63,7 @@ PD_1_306 times 4 dd 1.306562964876376527856643
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  2
 
-    align       16
+    align       32
     global      EXTN(jsimd_fdct_float_sse)
 
 EXTN(jsimd_fdct_float_sse):
@@ -354,4 +354,4 @@ EXTN(jsimd_fdct_float_sse):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 5fbc4d743faa902d8b74a1d05f3cf3d58068a2ea..479e5da9d163f30981ed0b0aa46dce50aeecdfe4 100644 (file)
@@ -2,7 +2,7 @@
 ; jfdctfst.asm - fast integer FDCT (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -51,7 +51,7 @@ F_1_306 equ DESCALE(1402911301, 30-CONST_BITS)  ; FIX(1.306562965)
 %define PRE_MULTIPLY_SCALE_BITS  2
 %define CONST_SHIFT              (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_fdct_ifast_sse2)
 
 EXTN(jconst_fdct_ifast_sse2):
@@ -61,7 +61,7 @@ PW_F0382 times 8 dw F_0_382 << CONST_SHIFT
 PW_F0541 times 8 dw F_0_541 << CONST_SHIFT
 PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -78,7 +78,7 @@ PW_F1306 times 8 dw F_1_306 << CONST_SHIFT
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  2
 
-    align       16
+    align       32
     global      EXTN(jsimd_fdct_ifast_sse2)
 
 EXTN(jsimd_fdct_ifast_sse2):
@@ -388,4 +388,4 @@ EXTN(jsimd_fdct_ifast_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 70148f18c28f6555bd5d9f8795b990c19ed32a8a..cdaa56f4e92c4118d9a626e2eb5c1072bff0ba30 100644 (file)
@@ -2,7 +2,7 @@
 ; jfdctint.asm - accurate integer FDCT (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30-CONST_BITS)  ; FIX(3.072711026)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_fdct_islow_sse2)
 
 EXTN(jconst_fdct_islow_sse2):
@@ -82,7 +82,7 @@ PD_DESCALE_P1  times 4 dd  1 << (DESCALE_P1-1)
 PD_DESCALE_P2  times 4 dd  1 << (DESCALE_P2-1)
 PW_DESCALE_P2X times 8 dw  1 << (PASS1_BITS-1)
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -99,7 +99,7 @@ PW_DESCALE_P2X times 8 dw  1 << (PASS1_BITS-1)
 %define wk(i)   rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM  6
 
-    align       16
+    align       32
     global      EXTN(jsimd_fdct_islow_sse2)
 
 EXTN(jsimd_fdct_islow_sse2):
@@ -618,4 +618,4 @@ EXTN(jsimd_fdct_islow_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 7e714d92c824f843d2b4cbf3de26054906bf423e..6f22339a95f2cab756d824604d468d977074eef2 100644 (file)
@@ -2,7 +2,7 @@
 ; jidctflt.asm - floating-point IDCT (64-bit SSE & SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -36,7 +36,7 @@
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_idct_float_sse2)
 
 EXTN(jconst_idct_float_sse2):
@@ -48,7 +48,7 @@ PD_M2_613       times 4  dd -2.613125929752753055713286
 PD_RNDINT_MAGIC times 4  dd  100663296.0  ; (float)(0x00C00000 << 3)
 PB_CENTERJSAMP  times 16 db  CENTERJSAMPLE
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -72,7 +72,7 @@ PB_CENTERJSAMP  times 16 db  CENTERJSAMPLE
 %define workspace     wk(0)-DCTSIZE2*SIZEOF_FAST_FLOAT
                                         ; FAST_FLOAT workspace[DCTSIZE2]
 
-    align       16
+    align       32
     global      EXTN(jsimd_idct_float_sse2)
 
 EXTN(jsimd_idct_float_sse2):
@@ -479,4 +479,4 @@ EXTN(jsimd_idct_float_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index e7a1617080823f0c0ba7b84a14674b3931863ced..422ad1b7ec3d67281e3c3352135b1024c9e5f121 100644 (file)
@@ -2,7 +2,7 @@
 ; jidctfst.asm - fast integer IDCT (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -58,7 +58,7 @@ F_1_613 equ (F_2_613 - (1 << CONST_BITS))       ; FIX(2.613125930) - FIX(1)
 %define PRE_MULTIPLY_SCALE_BITS  2
 %define CONST_SHIFT              (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_idct_ifast_sse2)
 
 EXTN(jconst_idct_ifast_sse2):
@@ -69,7 +69,7 @@ PW_MF1613      times 8  dw -F_1_613 << CONST_SHIFT
 PW_F1082       times 8  dw  F_1_082 << CONST_SHIFT
 PB_CENTERJSAMP times 16 db  CENTERJSAMPLE
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -91,7 +91,7 @@ PB_CENTERJSAMP times 16 db  CENTERJSAMPLE
 %define wk(i)         rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM        2
 
-    align       16
+    align       32
     global      EXTN(jsimd_idct_ifast_sse2)
 
 EXTN(jsimd_idct_ifast_sse2):
@@ -488,4 +488,4 @@ EXTN(jsimd_idct_ifast_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index a8cbce8f6c235131c550521409ae2e4c5db64269..6487266fe204c1917d278e04bf7fc6b755a87c1d 100644 (file)
@@ -2,7 +2,7 @@
 ; jidctint.asm - accurate integer IDCT (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -65,7 +65,7 @@ F_3_072 equ DESCALE(3299298341, 30-CONST_BITS)  ; FIX(3.072711026)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_idct_islow_sse2)
 
 EXTN(jconst_idct_islow_sse2):
@@ -82,7 +82,7 @@ PD_DESCALE_P1  times 4  dd  1 << (DESCALE_P1-1)
 PD_DESCALE_P2  times 4  dd  1 << (DESCALE_P2-1)
 PB_CENTERJSAMP times 16 db  CENTERJSAMPLE
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -104,7 +104,7 @@ PB_CENTERJSAMP times 16 db  CENTERJSAMPLE
 %define wk(i)         rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM        12
 
-    align       16
+    align       32
     global      EXTN(jsimd_idct_islow_sse2)
 
 EXTN(jsimd_idct_islow_sse2):
@@ -844,4 +844,4 @@ EXTN(jsimd_idct_islow_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index dace694dbeb581f39b7fa626f0c685ed765ebea1..69b71f0b8387cf72cf5c74671ca39462b31b27ea 100644 (file)
@@ -2,7 +2,7 @@
 ; jidctred.asm - reduced-size IDCT (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -71,7 +71,7 @@ F_3_624 equ DESCALE(3891787747, 30-CONST_BITS)  ; FIX(3.624509785)
 ; --------------------------------------------------------------------------
     SECTION     SEG_CONST
 
-    alignz      16
+    alignz      32
     global      EXTN(jconst_idct_red_sse2)
 
 EXTN(jconst_idct_red_sse2):
@@ -89,7 +89,7 @@ PD_DESCALE_P1_2 times 4  dd  1 << (DESCALE_P1_2-1)
 PD_DESCALE_P2_2 times 4  dd  1 << (DESCALE_P2_2-1)
 PB_CENTERJSAMP  times 16 db  CENTERJSAMPLE
 
-    alignz      16
+    alignz      32
 
 ; --------------------------------------------------------------------------
     SECTION     SEG_TEXT
@@ -112,7 +112,7 @@ PB_CENTERJSAMP  times 16 db  CENTERJSAMPLE
 %define wk(i)         rbp-(WK_NUM-(i))*SIZEOF_XMMWORD  ; xmmword wk[WK_NUM]
 %define WK_NUM        2
 
-    align       16
+    align       32
     global      EXTN(jsimd_idct_4x4_sse2)
 
 EXTN(jsimd_idct_4x4_sse2):
@@ -411,7 +411,7 @@ EXTN(jsimd_idct_4x4_sse2):
 ; r12 = JSAMPARRAY output_buf
 ; r13d = JDIMENSION output_col
 
-    align       16
+    align       32
     global      EXTN(jsimd_idct_2x2_sse2)
 
 EXTN(jsimd_idct_2x2_sse2):
@@ -572,4 +572,4 @@ EXTN(jsimd_idct_2x2_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 241b85724c1ad0e9a51cd8a758894172723cf6b4..3699d44df36a1afb71362326ed30550cc617dfc5 100644 (file)
@@ -2,7 +2,7 @@
 ; jquantf.asm - sample data conversion and quantization (64-bit SSE & SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +34,7 @@
 ; r11d = JDIMENSION start_col
 ; r12 = FAST_FLOAT *workspace
 
-    align       16
+    align       32
     global      EXTN(jsimd_convsamp_float_sse2)
 
 EXTN(jsimd_convsamp_float_sse2):
@@ -108,7 +108,7 @@ EXTN(jsimd_convsamp_float_sse2):
 ; r11 = FAST_FLOAT *divisors
 ; r12 = FAST_FLOAT *workspace
 
-    align       16
+    align       32
     global      EXTN(jsimd_quantize_float_sse2)
 
 EXTN(jsimd_quantize_float_sse2):
@@ -154,4 +154,4 @@ EXTN(jsimd_quantize_float_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index 0f8f9eced98fe4bf2c3b67a5c54545c2b5a829f7..4b0873e0abf5ea1a84e2d189c76df9efe5ecd3d2 100644 (file)
@@ -2,7 +2,7 @@
 ; jquanti.asm - sample data conversion and quantization (64-bit SSE2)
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2009, D. R. Commander.
+; Copyright (C) 2009, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -34,7 +34,7 @@
 ; r11d = JDIMENSION start_col
 ; r12 = DCTELEM *workspace
 
-    align       16
+    align       32
     global      EXTN(jsimd_convsamp_sse2)
 
 EXTN(jsimd_convsamp_sse2):
@@ -110,7 +110,7 @@ EXTN(jsimd_convsamp_sse2):
 ; r11 = DCTELEM *divisors
 ; r12 = DCTELEM *workspace
 
-    align       16
+    align       32
     global      EXTN(jsimd_quantize_sse2)
 
 EXTN(jsimd_quantize_sse2):
@@ -183,4 +183,4 @@ EXTN(jsimd_quantize_sse2):
 
 ; For some reason, the OS X linker does not honor the request to align the
 ; segment unless we do this.
-    align       16
+    align       32
index dc6ec430db965455aa24e5d3e3eab37010de1820..a10995eb583afc02c3ae7c1155cf4648635b8ab3 100644 (file)
@@ -23,6 +23,7 @@
 #define JSIMD_ARM_NEON   0x10
 #define JSIMD_MIPS_DSPR2 0x20
 #define JSIMD_ALTIVEC    0x40
+#define JSIMD_AVX2       0x80
 
 /* SIMD Ext: retrieve SIMD/CPU information */
 EXTERN(unsigned int) jpeg_simd_cpu_support (void);
index a62bcdb0eedf936a3f63cf89f01b0a15a6ffc2be..b2fe5d361310f7acd74164a922a062772545c7bd 100644 (file)
@@ -46,9 +46,15 @@ init_simd (void)
   if (simd_support != ~0U)
     return;
 
-  simd_support = JSIMD_SSE2 | JSIMD_SSE;
+  simd_support = jpeg_simd_cpu_support();
 
   /* Force different settings through environment variables */
+  env = getenv("JSIMD_FORCESSE2");
+  if ((env != NULL) && (strcmp(env, "1") == 0))
+    simd_support &= JSIMD_SSE2;
+  env = getenv("JSIMD_FORCEAVX2");
+  if ((env != NULL) && (strcmp(env, "1") == 0))
+    simd_support &= JSIMD_AVX2;
   env = getenv("JSIMD_FORCENONE");
   if ((env != NULL) && (strcmp(env, "1") == 0))
     simd_support = 0;
index 81574d5ff83ccbb253000c1ab5d63d6876076a1e..7ff7e29296d48fe2afd8c57af6babcfba6692bad 100644 (file)
 %define _cpp_protection_JSIMD_3DNOW  JSIMD_3DNOW
 %define _cpp_protection_JSIMD_SSE    JSIMD_SSE
 %define _cpp_protection_JSIMD_SSE2   JSIMD_SSE2
+%define _cpp_protection_JSIMD_AVX2   JSIMD_AVX2
diff --git a/simd/jsimdcpu-64.asm b/simd/jsimdcpu-64.asm
new file mode 100644 (file)
index 0000000..37ac0e8
--- /dev/null
@@ -0,0 +1,62 @@
+;
+; jsimdcpu-64.asm - SIMD instruction support check
+;
+; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
+; Copyright (C) 2016, D. R. Commander.
+;
+; Based on
+; x86 SIMD extension for IJG JPEG library
+; Copyright (C) 1999-2006, MIYASAKA Masaru.
+; For conditions of distribution and use, see copyright notice in jsimdext.inc
+;
+; This file should be assembled with NASM (Netwide Assembler),
+; can *not* be assembled with Microsoft's MASM or any compatible
+; assembler (including Borland's Turbo Assembler).
+; NASM is available from http://nasm.sourceforge.net/ or
+; http://sourceforge.net/project/showfiles.php?group_id=6208
+;
+; [TAB8]
+
+%include "jsimdext.inc"
+
+; --------------------------------------------------------------------------
+        SECTION SEG_TEXT
+        BITS    64
+;
+; Check if the CPU supports SIMD instructions
+;
+; GLOBAL(unsigned int)
+; jpeg_simd_cpu_support (void)
+;
+
+        align   32
+        global  EXTN(jpeg_simd_cpu_support)
+
+EXTN(jpeg_simd_cpu_support):
+        push    rbx
+        push    rdi
+
+        xor     rdi,rdi                 ; simd support flag
+
+        ; Check for AVX2 instruction support
+        mov     rax, 7
+        xor     rcx,rcx
+        cpuid
+        mov     rax,rbx                 ; rax = Extended feature flags
+
+        or      rdi, JSIMD_SSE2
+        or      rdi, JSIMD_SSE
+        test    rax, 1<<5               ; bit5:AVX2
+        jz      short .return
+        or      rdi, JSIMD_AVX2
+
+.return:
+        mov     rax,rdi
+
+        pop     rdi
+        pop     rbx
+        ret
+
+; For some reason, the OS X linker does not honor the request to align the
+; segment unless we do this.
+        align   32
index 599083b18227a2752b744f71eb7882e2f23685c9..580810b8578ab9627f60bf9178acafbd52321202 100644 (file)
@@ -2,6 +2,7 @@
 ; jsimdcpu.asm - SIMD instruction support check
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
+; Copyright (C) 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library
 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
@@ -74,6 +75,16 @@ EXTN(jpeg_simd_cpu_support):
         or      edi, byte JSIMD_SSE2
 .no_sse2:
 
+        ; Check for AVX2 instruction support
+        mov     eax, 7
+        xor     ecx,ecx
+        cpuid
+        mov     eax,ebx
+        test    eax, 1<<5               ; bit5:AVX2
+        jz      short .no_avx2
+        or      edi, JSIMD_AVX2
+.no_avx2:
+
         ; Check for 3DNow! instruction support
         mov     eax, 0x80000000
         cpuid
index c138f01b119cc51bd3405a56fe219e3ebd53b500..48d0fb1a468e397580c48d49a08296c8da1a90b6 100644 (file)
@@ -2,7 +2,7 @@
 ; jsimdext.inc - common declarations
 ;
 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
-; Copyright (C) 2010, D. R. Commander.
+; Copyright (C) 2010, 2016, D. R. Commander.
 ;
 ; Based on the x86 SIMD extension for IJG JPEG library - version 1.02
 ;
 ; -- segment definition --
 ;
 %ifdef __YASM_VER__
-%define SEG_TEXT   .text  align=16
-%define SEG_CONST  .rdata align=16
+%define SEG_TEXT   .text  align=32
+%define SEG_CONST  .rdata align=32
 %else
-%define SEG_TEXT   .text  align=16 public use32 class=CODE
-%define SEG_CONST  .rdata align=16 public use32 class=CONST
+%define SEG_TEXT   .text  align=32 public use32 class=CODE
+%define SEG_CONST  .rdata align=32 public use32 class=CONST
 %endif
 
 %elifdef WIN64  ; ----(nasm -fwin64 -DWIN64 ...)--------
 ; -- segment definition --
 ;
 %ifdef __YASM_VER__
-%define SEG_TEXT    .text  align=16
-%define SEG_CONST   .rdata align=16
+%define SEG_TEXT    .text  align=32
+%define SEG_CONST   .rdata align=32
 %else
-%define SEG_TEXT    .text  align=16 public use64 class=CODE
-%define SEG_CONST   .rdata align=16 public use64 class=CONST
+%define SEG_TEXT    .text  align=32 public use64 class=CODE
+%define SEG_CONST   .rdata align=32 public use64 class=CONST
 %endif
 %define EXTN(name)  name                ; foo() -> foo
 
@@ -78,11 +78,11 @@ section .note.GNU-stack noalloc noexec nowrite progbits
 ; -- segment definition --
 ;
 %ifdef __x86_64__
-%define SEG_TEXT   .text   progbits align=16
-%define SEG_CONST  .rodata progbits align=16
+%define SEG_TEXT   .text   progbits align=32
+%define SEG_CONST  .rodata progbits align=32
 %else
-%define SEG_TEXT   .text   progbits alloc exec   nowrite align=16
-%define SEG_CONST  .rodata progbits alloc noexec nowrite align=16
+%define SEG_TEXT   .text   progbits alloc exec   nowrite align=32
+%define SEG_CONST  .rodata progbits alloc noexec nowrite align=32
 %endif
 
 ; To make the code position-independent, append -DPIC to the commandline
@@ -108,8 +108,8 @@ section .note.GNU-stack noalloc noexec nowrite progbits
 
 ; -- segment definition --
 ;
-%define SEG_TEXT   .text  ;align=16     ; nasm doesn't accept align=16. why?
-%define SEG_CONST  .rodata align=16
+%define SEG_TEXT   .text  ;align=32     ; nasm doesn't accept align=16. why?
+%define SEG_CONST  .rodata align=32
 
 ; The generation of position-independent code (PIC) is the default on Darwin.
 ;
@@ -158,6 +158,10 @@ section .note.GNU-stack noalloc noexec nowrite progbits
 %define SIZEOF_XMMWORD  SIZEOF_OWORD    ; sizeof(XMMWORD)
 %define XMMWORD_BIT     OWORD_BIT       ; sizeof(XMMWORD)*BYTE_BIT
 
+%define YMMWORD                         ; int256 (AVX register)
+%define SIZEOF_YMMWORD  SIZEOF_YWORD    ; sizeof(YMMWORD)
+%define YMMWORD_BIT     YWORD_BIT       ; sizeof(YMMWORD)*BYTE_BIT
+
 ; Similar hacks for when we load a dword or MMWORD into an xmm# register
 %define XMM_DWORD
 %define XMM_MMWORD
@@ -167,12 +171,14 @@ section .note.GNU-stack noalloc noexec nowrite progbits
 %define SIZEOF_DWORD  4                 ; sizeof(DWORD)
 %define SIZEOF_QWORD  8                 ; sizeof(QWORD)
 %define SIZEOF_OWORD  16                ; sizeof(OWORD)
+%define SIZEOF_YWORD  32                ; sizeof(YWORD)
 
 %define BYTE_BIT      8                 ; CHAR_BIT in C
 %define WORD_BIT      16                ; sizeof(WORD)*BYTE_BIT
 %define DWORD_BIT     32                ; sizeof(DWORD)*BYTE_BIT
 %define QWORD_BIT     64                ; sizeof(QWORD)*BYTE_BIT
 %define OWORD_BIT     128               ; sizeof(OWORD)*BYTE_BIT
+%define YWORD_BIT     256               ; sizeof(YWORD)*BYTE_BIT
 
 ; --------------------------------------------------------------------------
 ;  External Symbol Name
index 9d4aedec9e36a8b33751da4da314195a3416fac5..14eca46aed18aa2146ece89cb5d5b8f9820bde96 100755 (executable)
@@ -90,5 +90,6 @@
 %define JSIMD_3DNOW 0x02
 %define JSIMD_SSE 0x04
 %define JSIMD_SSE2 0x08
+%define JSIMD_AVX2 0x80
 ; Short forms of external names for systems with brain-damaged linkers.
 ;