LCOV - code coverage report
Current view: top level - ballet/blake3 - blake3_dispatch.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 4 20 20.0 %
Date: 2024-11-13 11:58:15 Functions: 1 4 25.0 %

          Line data    Source code
       1             : // Source originally from https://github.com/BLAKE3-team/BLAKE3
       2             : // From commit: 64747d48ffe9d1fbf4b71e94cabeb8a211461081
       3             : 
       4             : #include <stdbool.h>
       5             : #include <stddef.h>
       6             : #include <stdint.h>
       7             : 
       8             : #include "blake3_impl.h"
       9             : 
      10             : #if defined(IS_X86)
      11             : #if defined(_MSC_VER)
      12             : #include <intrin.h>
      13             : #elif defined(__GNUC__)
      14             : #include <immintrin.h>
      15             : #else
      16             : #undef IS_X86 /* Unimplemented! */
      17             : #endif
      18             : #endif
      19             : 
      20             : #define MAYBE_UNUSED(x) (void)((x))
      21             : 
      22             : void blake3_compress_in_place(uint32_t cv[8],
      23             :                               const uint8_t block[BLAKE3_BLOCK_LEN],
      24             :                               uint8_t block_len, uint64_t counter,
      25           0 :                               uint8_t flags) {
      26           0 : #if FD_HAS_AVX512
      27           0 :   blake3_compress_in_place_avx512(cv, block, block_len, counter, flags);
      28             : #elif FD_HAS_AVX
      29             :   blake3_compress_in_place_sse41(cv, block, block_len, counter, flags);
      30             : #elif FD_HAS_SSE
      31             :   blake3_compress_in_place_sse2(cv, block, block_len, counter, flags);
      32             : #else
      33             :   blake3_compress_in_place_portable(cv, block, block_len, counter, flags);
      34             : #endif
      35           0 : }
      36             : 
      37             : void blake3_compress_xof(const uint32_t cv[8],
      38             :                          const uint8_t block[BLAKE3_BLOCK_LEN],
      39             :                          uint8_t block_len, uint64_t counter, uint8_t flags,
      40          15 :                          uint8_t out[64]) {
      41           5 : #if FD_HAS_AVX512
      42           5 :   blake3_compress_xof_avx512(cv, block, block_len, counter, flags, out);
      43             : #elif FD_HAS_AVX
      44             :   blake3_compress_xof_sse41(cv, block, block_len, counter, flags, out);
      45             : #elif FD_HAS_SSE
      46             :   blake3_compress_xof_sse2(cv, block, block_len, counter, flags, out);
      47             : #else
      48             :   blake3_compress_xof_portable(cv, block, block_len, counter, flags, out);
      49             : #endif
      50          15 : }
      51             : 
      52             : void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs,
      53             :                       size_t blocks, const uint32_t key[8], uint64_t counter,
      54             :                       bool increment_counter, uint8_t flags,
      55           0 :                       uint8_t flags_start, uint8_t flags_end, uint8_t *out) {
      56           0 : #if FD_HAS_AVX512
      57           0 :   blake3_hash_many_avx512(inputs, num_inputs, blocks, key, counter,
      58           0 :                           increment_counter, flags, flags_start, flags_end,
      59           0 :                           out);
      60             : #elif FD_HAS_AVX
      61             :   blake3_hash_many_avx2(inputs, num_inputs, blocks, key, counter,
      62           0 :                         increment_counter, flags, flags_start, flags_end,
      63           0 :                         out);
      64             : #elif FD_HAS_SSE
      65             :   /* TODO use sse4.1 here? */
      66             :   blake3_hash_many_sse2(inputs, num_inputs, blocks, key, counter,
      67             :                         increment_counter, flags, flags_start, flags_end,
      68             :                         out);
      69             : #else
      70             :   blake3_hash_many_portable(inputs, num_inputs, blocks, key, counter,
      71             :                             increment_counter, flags, flags_start, flags_end,
      72             :                             out);
      73             : #endif
      74           0 : }
      75             : 
      76             : // The dynamically detected SIMD degree of the current platform.
      77           0 : size_t blake3_simd_degree(void) {
      78           0 : #if FD_HAS_AVX
      79           0 :   return 8;
      80             : #else
      81             :   return 1;
      82             : #endif
      83           0 : }

Generated by: LCOV version 1.14