1 /* ----------------------------------------------------------------------
2  * Project:      CMSIS DSP Library
3  * Title:        arm_vlog_f16.c
4  * Description:  Fast vectorized log
5  *
6  * $Date:        23 April 2021
7  * $Revision:    V1.9.0
8  *
9  * Target Processor: Cortex-M and Cortex-A cores
10  * -------------------------------------------------------------------- */
11 /*
12  * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved.
13  *
14  * SPDX-License-Identifier: Apache-2.0
15  *
16  * Licensed under the Apache License, Version 2.0 (the License); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28 
29 #include "dsp/fast_math_functions_f16.h"
30 
31 #if defined(ARM_FLOAT16_SUPPORTED)
32 
33 #include "arm_common_tables.h"
34 #include "arm_vec_math_f16.h"
35 
arm_vlog_f16(const float16_t * pSrc,float16_t * pDst,uint32_t blockSize)36 void arm_vlog_f16(
37   const float16_t * pSrc,
38         float16_t * pDst,
39         uint32_t blockSize)
40 {
41    uint32_t blkCnt;
42 
43 #if defined(ARM_MATH_MVE_FLOAT16) && !defined(ARM_MATH_AUTOVECTORIZE)
44 
45    f16x8_t src;
46    f16x8_t dst;
47 
48    blkCnt = blockSize >> 3;
49 
50    while (blkCnt > 0U)
51    {
52       src = vld1q(pSrc);
53       dst = vlogq_f16(src);
54       vst1q(pDst, dst);
55 
56       pSrc += 8;
57       pDst += 8;
58       /* Decrement loop counter */
59       blkCnt--;
60    }
61 
62    blkCnt = blockSize & 7;
63 #else
64    blkCnt = blockSize;
65 #endif
66 
67    while (blkCnt > 0U)
68    {
69       /* C = log(A) */
70 
71       /* Calculate log and store result in destination buffer. */
72       *pDst++ = logf(*pSrc++);
73 
74       /* Decrement loop counter */
75       blkCnt--;
76    }
77 }
78 
79 #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */
80 
81