Skip to content

Commit

Permalink
Fix alignment in SHA256 hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
bhatuzdanamemsr committed Mar 11, 2021
1 parent a71669e commit 76a74df
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions SCI/src/utils/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ class Hash { public:
}
__attribute__((target("sse2")))
static block128 hash_for_block128(const void * data, int nbyte) {
char digest[DIGEST_SIZE];
// even though stack is aligned to 16 byte, we don't know the order of locals.
char digest[DIGEST_SIZE] __attribute__ ((aligned (16)));
hash_once(digest, data, nbyte);
return _mm_load_si128((__m128i*)&digest[0]);
}

__attribute__((target("avx")))
static block256 hash_for_block256(const void * data, int nbyte) {
char digest[DIGEST_SIZE];
char digest[DIGEST_SIZE] __attribute__ ((aligned (32)));
hash_once(digest, data, nbyte);
return _mm256_load_si256((__m256i*)&digest[0]);
}
Expand Down

0 comments on commit 76a74df

Please sign in to comment.