summaryrefslogtreecommitdiff
path: root/filters.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-09-04 10:24:24 -0400
committerJeffrey Walton <noloader@gmail.com>2017-09-04 10:24:24 -0400
commit9c2a1c74fe76a9dada1877d920afea120609ce5c (patch)
tree849c63ec83524724a35f18dcbed3718bd0eca490 /filters.h
parent8578383e2ca293480a2b80ccfe117488a580f25a (diff)
downloadcryptopp-git-9c2a1c74fe76a9dada1877d920afea120609ce5c.tar.gz
Fixup under-aligned buffers for AltiVec and Power8
This commit supports the upcoming AltiVec and Power8 processor support. The commit favors AlignedSecByteBlock over SecByteBlock in places where messages are handled on the AltiVec and Power8 processor data paths. The data paths include all block cipher modes of operation, and some filters like Intel and ARM processors are tolerant of under-aligned buffers when using crypto intstructions. AltiVec and Power8 are less tolerant, and they simply ignore the three low-order bits to ensure an address is aligned. The AltiVec and Power8 have caused a fair number of wild writes on the stack and in the heap. Testing on a 64-bit Intel Skylake show a marked improvement in performance. We suspect GCC is generating better code since it knows the alignment of the pointers, and does not have to emit fixup code for under-aligned and mis-aligned data. Here are some data points: SecByteBlock - Poly1305: 3.4 cpb - Blake2s: 6.7 cpb - Blake2b: 4.5 cpb - SipHash-2-4: 3.1 cpb - SipHash-4-8: 3.5 cpb - ChaCha20: 7.4 cpb - ChaCha12: 4.6 cpb - ChaCha8: 3.5 cpb AlignedSecByteBlock - Poly1305: 2.9 cpb - Blake2s: 5.5. cpb - Blake2b: 3.9 cpb - SipHash-2-4: 1.9 cpb - SipHash-4-8: 3.3 cpb - ChaCha20: 6.0 cpb - ChaCha12: 4.0 cpb - ChaCha8: 2.9 cpb Testing on an mid-2000's 32-bit VIA C7-D with SSE2+SSSE3 showed no improvement, and no performance was lost.
Diffstat (limited to 'filters.h')
-rw-r--r--filters.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/filters.h b/filters.h
index 2e56f122..6619a335 100644
--- a/filters.h
+++ b/filters.h
@@ -210,7 +210,7 @@ struct CRYPTOPP_DLL FilterPutSpaceHelper
{return HelpCreatePutSpace(target, channel, minSize, minSize, bufferSize);}
//! \brief Temporay working space
- SecByteBlock m_tempSpace;
+ AlignedSecByteBlock m_tempSpace;
};
//! \class MeterFilter
@@ -414,7 +414,7 @@ protected:
size_t MaxSize() const {return m_buffer.size();}
private:
- SecByteBlock m_buffer;
+ AlignedSecByteBlock m_buffer;
size_t m_blockSize, m_maxBlocks, m_size;
byte *m_begin;
};