add some code
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dsp_tests.h"
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
|
||||
TEST_CASE("dsps_mul_f32_ansi functionality", "[dsps]")
|
||||
{
|
||||
int n = 32;
|
||||
float x[n];
|
||||
float y[n];
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i;
|
||||
y[i] = i * i;
|
||||
}
|
||||
dsps_mul_f32_ansi(x, x, x, n, 1, 1, 1);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_f32 functionality", "[dsps]")
|
||||
{
|
||||
int n = 32;
|
||||
float x[n];
|
||||
float y[n];
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i;
|
||||
y[i] = i * i;
|
||||
}
|
||||
dsps_mul_f32(x, x, x, n, 1, 1, 1);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int repeat_count = 1;
|
||||
|
||||
dsps_mul_f32(x, x, x, n, 1, 1, 1);
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_f32(x, x, x, n, 1, 1, 1);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (n * repeat_count);
|
||||
ESP_LOGI(TAG, "dsps_mul_f32 - %f cycles per sample \n", cycles);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dsp_tests.h"
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
|
||||
TEST_CASE("dsps_mul_s16 functionality", "[dsps]")
|
||||
{
|
||||
int n = 64;
|
||||
int16_t x[n];
|
||||
int16_t y[n];
|
||||
int32_t temp;
|
||||
int shift = 0;
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
temp = ((int32_t)x[i] * (int32_t)x[i]) >> shift;
|
||||
y[i] = temp;
|
||||
}
|
||||
|
||||
dsps_mul_s16(x, x, x, n, 1, 1, 1, shift);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]);
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_s16 benchmark", "[dsps]")
|
||||
{
|
||||
const int n = 256;
|
||||
int16_t x[n];
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_s16(x, x, x, n, 1, 1, 1, 0);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float cycles = end_b - start_b;
|
||||
ESP_LOGI(TAG, "dsps_mul_s16 - %f cycles per sample \n", cycles);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
#if (dsps_mul_s16_aes3_enabled == 1)
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
TEST_CASE("dsps_mul_s16_aes3 functionality", "[dsps]")
|
||||
{
|
||||
int n = 64;
|
||||
int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
int32_t temp;
|
||||
int shift = 0;
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
temp = ((int32_t)x[i] * (int32_t)x[i]) >> shift;
|
||||
y[i] = temp;
|
||||
}
|
||||
|
||||
dsps_mul_s16_aes3(x, x, x, n, 1, 1, 1, shift);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]);
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
free(x);
|
||||
free(y);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_s16_aes3 benchmark", "[dsps]")
|
||||
{
|
||||
const int n = 2048;
|
||||
int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_s16_aes3(x, x, x, n, 1, 1, 1, 0);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float cycles = end_b - start_b;
|
||||
ESP_LOGI(TAG, "dsps_mul_s16_aes3 - %f cycles per sample \n", cycles);
|
||||
free(x);
|
||||
|
||||
}
|
||||
#endif // (dsps_mul_s16_aes3_enabled == 1)
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
TEST_CASE("dsps_mul_s16_ansi functionality", "[dsps]")
|
||||
{
|
||||
int n = 64;
|
||||
int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
int32_t temp;
|
||||
int shift = 0;
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
temp = ((int32_t)x[i] * (int32_t)x[i]) >> shift;
|
||||
y[i] = temp;
|
||||
}
|
||||
|
||||
dsps_mul_s16_ansi(x, x, x, n, 1, 1, 1, shift);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]);
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
free(x);
|
||||
free(y);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_s16_ansi benchmark", "[dsps]")
|
||||
{
|
||||
const int n = 2048;
|
||||
int16_t *x = (int16_t *)memalign(16, n * sizeof(int16_t));
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_s16_ansi(x, x, x, n, 1, 1, 1, 0);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float cycles = end_b - start_b;
|
||||
ESP_LOGI(TAG, "dsps_mul_s16_ansi - %f cycles per sample \n", cycles);
|
||||
free(x);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
#if (dsps_mul_s16_aes3_enabled == 1)
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
TEST_CASE("dsps_mul_s8_aes3 functionality", "[dsps]")
|
||||
{
|
||||
int n = 64;
|
||||
int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t));
|
||||
int8_t *y = (int8_t *)memalign(16, n * sizeof(int8_t));
|
||||
int32_t temp;
|
||||
int shift = 0;
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i - n / 2;
|
||||
temp = ((int32_t)x[i] * (int32_t)x[i]) >> shift;
|
||||
y[i] = temp;
|
||||
}
|
||||
|
||||
dsps_mul_s8_aes3(x, x, x, n, 1, 1, 1, shift);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
ESP_LOGD(TAG, "x[%i] = %i %i", i, x[i], y[i]);
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
free(x);
|
||||
free(y);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_s8_aes3 benchmark", "[dsps]")
|
||||
{
|
||||
const int n = 256;
|
||||
int8_t *x = (int8_t *)memalign(16, n * sizeof(int8_t));
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_s8_aes3(x, x, x, n, 1, 1, 1, 0);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float cycles = end_b - start_b;
|
||||
ESP_LOGI(TAG, "dsps_mul_s8_aes3 - %f cycles per sample \n", cycles);
|
||||
free(x);
|
||||
|
||||
}
|
||||
#endif // (dsps_mul_s16_aes3_enabled == 1)
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dsp_tests.h"
|
||||
#include "dsps_mul.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
static const char *TAG = "dsps_mul";
|
||||
|
||||
TEST_CASE("dsps_mul_s8_ansi functionality", "[dsps]")
|
||||
{
|
||||
int n = 64;
|
||||
int8_t x[n];
|
||||
int8_t y[n];
|
||||
int32_t temp;
|
||||
int shift = 0;
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i - n / 2;
|
||||
temp = ((int32_t)x[i] * (int32_t)x[i]) >> shift;
|
||||
y[i] = temp;
|
||||
}
|
||||
|
||||
dsps_mul_s8_ansi(x, x, x, n, 1, 1, 1, 0);
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
if (x[i] != y[i]) {
|
||||
TEST_ASSERT_EQUAL(x[i], y[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_mul_s8_ansi benchmark", "[dsps]")
|
||||
{
|
||||
const int n = 256;
|
||||
int8_t x[n];
|
||||
for (int i = 0 ; i < n ; i++) {
|
||||
x[i] = i << 4;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dsps_mul_s8_ansi(x, x, x, n, 1, 1, 1, 0);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float cycles = end_b - start_b;
|
||||
ESP_LOGI(TAG, "dsps_mul_s8_ansi - %f cycles per sample \n", cycles);
|
||||
}
|
||||
Reference in New Issue
Block a user