This commit is contained in:
parent
c2d5d136fd
commit
446660bed4
|
@ -1,4 +1,9 @@
|
|||
menuconfig APP_BENCHMARK
|
||||
bool "embench for xiuos"
|
||||
default n
|
||||
default Y
|
||||
if APP_BENCHMARK
|
||||
config USING_BENCHMARK
|
||||
bool "USING_BENCHMARK"
|
||||
default y
|
||||
endif
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
Some of this code is referenced by the book the Hacker's Delight (which
|
||||
placed it in the public domain). See http://www.hackersdelight.org/ */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
/* CRC - 32 BIT ANSI X3.66 CRC checksum files */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "snipmath.h"
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
#define LOCAL_SCALE_FACTOR 51
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
#define LOCAL_SCALE_FACTOR 1
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
***************************************************************************/
|
||||
// #define DO_TRACING
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
#include "picojpeg.h"
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
bytes 66.8 billion clocks 13449.513 sec AVR ATmega2560 @ 20 MHz 318 bytes
|
||||
269.0 billion clocks */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
#define LOCAL_SCALE_FACTOR 1
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
Original code from: https://github.com/tz1/qrduino */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
#include "qrencode.h"
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include <string.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
#include "sglib.h"
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
#define LOCAL_SCALE_FACTOR 47
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -5,6 +5,6 @@ cwd = GetCurrentDir()
|
|||
src = Glob('*.c')
|
||||
path = [cwd]
|
||||
|
||||
group = DefineGroup('benchmark', src, depend=['USING_BENCHMAKR'], CPPPATH=path)
|
||||
group = DefineGroup('benchmark', src, depend=['USING_BENCHMARK'], CPPPATH=path)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
into public domain. */
|
||||
|
||||
#include <string.h>
|
||||
#include "support.h"
|
||||
#include <support.h>
|
||||
|
||||
/* This scale factor will be changed to equalise the runtime of the
|
||||
benchmarks. */
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import os
|
||||
from building import *
|
||||
|
||||
Import('RTT_ROOT')
|
||||
Import('rtconfig')
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
DEPENDS = [""]
|
||||
|
||||
SOURCES = ['benchmark.c']+['beebsc.c']
|
||||
path = [cwd]
|
||||
|
||||
group = DefineGroup('benchmark', src, depend=['USING_BENCHMARK'], CPPPATH=path)
|
||||
|
||||
Return('group')
|
||||
objs = DefineGroup('benchmark', src = SOURCES, depend = DEPENDS,CPPPATH = path)
|
||||
Return("objs")
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <transform.h>
|
||||
|
||||
// #define NUTTX
|
||||
// #define RTTHREAD 0
|
||||
#ifdef NUTTX
|
||||
// #include "k210_sysctl.h"
|
||||
#include "../../../../../Ubiquitous/Nuttx_Fusion_XiUOS/nuttx/arch/risc-v/src/k210/encoding.h"
|
||||
|
@ -156,11 +157,9 @@ void *run_one_example(void *arg) {
|
|||
organize_result(handle, start_time, end_time);
|
||||
PrivMutexAbandon(&case_mu);
|
||||
done_cnt++;
|
||||
#ifdef NUTTX
|
||||
if (done_cnt == 22) {
|
||||
PrivSemaphoreAbandon(&res_mu);
|
||||
}
|
||||
#endif
|
||||
// printf("Case done. %d\n", done_cnt);
|
||||
}
|
||||
|
||||
|
@ -180,7 +179,7 @@ void *run_benchmark_parallel(void *args) {
|
|||
case_attr.priority = 64;
|
||||
case_attr.stacksize = 16384;
|
||||
#else
|
||||
case_attr.schedparam.sched_priority = 25;
|
||||
case_attr.schedparam.sched_priority = 27;
|
||||
case_attr.stacksize = 16384;
|
||||
#endif
|
||||
PrivMutexCreate(&case_mu, NULL);
|
||||
|
@ -193,22 +192,32 @@ void *run_benchmark_parallel(void *args) {
|
|||
start_trigger(&g_start_time);
|
||||
while (NULL != cur_handle) {
|
||||
assert(cur_handle->handle.magic_number != MAGIC_NUMBER);
|
||||
#ifdef RTTHREAD
|
||||
rt_thread_t tid = rt_thread_create("bm_case", run_one_example,
|
||||
(void *)cur_handle, 16384, 27, 20);
|
||||
rt_thread_startup(tid);
|
||||
#else
|
||||
PrivTaskCreate(&cur_handle->task_ptr, &case_attr, run_one_example,
|
||||
(void *)cur_handle);
|
||||
|
||||
#endif
|
||||
cur_handle = cur_handle->next;
|
||||
}
|
||||
// printf("Create done.\n");
|
||||
|
||||
#ifdef NUTTX
|
||||
PrivSemaphoreObtainWait(&res_mu, NULL);
|
||||
#ifdef NUTTX
|
||||
case_attr.priority = 64;
|
||||
case_attr.stacksize = 16384;
|
||||
PrivTaskCreate(&res_thread, &case_attr, print_result_asyn, NULL);
|
||||
#elif RTTHREAD
|
||||
rt_thread_t tid =
|
||||
rt_thread_create("bm_res", print_result_asyn, NULL, 4096, 23, 20);
|
||||
rt_thread_startup(tid);
|
||||
#else
|
||||
case_attr.schedparam.sched_priority = 23;
|
||||
case_attr.stacksize = 16384;
|
||||
#endif
|
||||
PrivTaskCreate(&res_thread, &case_attr, print_result_asyn, NULL);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -251,28 +260,70 @@ void *run_benchmark_sequential(void *args) {
|
|||
(uint64_t)(s_stop_time - s_start_time));
|
||||
}
|
||||
|
||||
/*****************************************************/
|
||||
|
||||
#define NR_BM_MUTEX_LOOP 1000000
|
||||
|
||||
void TestWrapMutexManagement(void) {
|
||||
pthread_mutex_t mu;
|
||||
PrivMutexCreate(&mu, 0);
|
||||
uint64_t start_time = read_cycle();
|
||||
for (int i = 0; i < NR_BM_MUTEX_LOOP; i++) {
|
||||
PrivMutexObtain(&mu);
|
||||
PrivMutexAbandon(&mu);
|
||||
}
|
||||
uint64_t end_time = read_cycle();
|
||||
printf("Wrapped Mutex cost: %20ld\n", (uint64_t)(end_time - start_time));
|
||||
}
|
||||
|
||||
void TestOrigMutexManagement(void) {
|
||||
pthread_mutex_t mu;
|
||||
pthread_mutex_init(&mu, 0);
|
||||
uint64_t start_time = read_cycle();
|
||||
for (int i = 0; i < NR_BM_MUTEX_LOOP; i++) {
|
||||
pthread_mutex_lock(&mu);
|
||||
pthread_mutex_unlock(&mu);
|
||||
}
|
||||
uint64_t end_time = read_cycle();
|
||||
printf("Original Mutex cost: %20ld\n", (uint64_t)(end_time - start_time));
|
||||
}
|
||||
|
||||
/*****************************************************/
|
||||
|
||||
pthread_t main_thread;
|
||||
int embenchmark_parallel() {
|
||||
#ifdef NUTTX
|
||||
case_attr.priority = 128;
|
||||
case_attr.stacksize = 16384;
|
||||
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_parallel, NULL);
|
||||
#elif RTTHREAD
|
||||
rt_thread_t tid = rt_thread_create(
|
||||
"benchmark_parallel", run_benchmark_parallel, NULL, 16384, 30, 20);
|
||||
rt_thread_startup(tid);
|
||||
#else
|
||||
case_attr.schedparam.sched_priority = 30;
|
||||
case_attr.stacksize = 16384;
|
||||
#endif
|
||||
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_parallel, NULL);
|
||||
#endif
|
||||
// run_benchmark_parallel(NULL);
|
||||
// TestWrapMutexManagement();
|
||||
return 0;
|
||||
}
|
||||
int embenchmark_sequential(void) {
|
||||
#ifdef NUTTX
|
||||
case_attr.priority = 128;
|
||||
case_attr.stacksize = 16384;
|
||||
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_sequential, NULL);
|
||||
#elif RTTHREAD
|
||||
rt_thread_t tid = rt_thread_create(
|
||||
"benchmark_sequential", run_benchmark_sequential, NULL, 16384, 30, 20);
|
||||
rt_thread_startup(tid);
|
||||
#else
|
||||
case_attr.schedparam.sched_priority = 30;
|
||||
case_attr.stacksize = 16384;
|
||||
#endif
|
||||
PrivTaskCreate(&main_thread, &case_attr, run_benchmark_sequential, NULL);
|
||||
#endif
|
||||
// TestOrigMutexManagement();
|
||||
return 0;
|
||||
}
|
||||
PRIV_SHELL_CMD_FUNCTION(embenchmark_parallel, run benchmark in parallel,
|
||||
|
|
|
@ -82,6 +82,11 @@ int PrivSemaphoreAbandon(sem_t *sem)
|
|||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
// sched_setscheduler()
|
||||
struct sched_param sp;
|
||||
sp.sched_priority = attr->priority;
|
||||
sched_setscheduler(0, SCHED_RR, &sp);
|
||||
|
||||
return pthread_create(thread, attr, start_routine, arg);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ int PrivSemaphoreObtainWaitForever(sem_t *sem)
|
|||
int PrivTaskCreate(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
pthread_attr_t attrtmp ;
|
||||
pthread_attr_t attrtmp;
|
||||
pthread_attr_init(&attrtmp);
|
||||
pthread_attr_setschedparam(&attrtmp, &(attr->schedparam)); /* 修改属性对应的优先级 */
|
||||
pthread_attr_setstacksize(&attrtmp, (size_t)((attr->stacksize)));
|
||||
|
|
|
@ -115,7 +115,7 @@ CONFIG_RT_USING_FINSH=y
|
|||
CONFIG_RT_USING_MSH=y
|
||||
CONFIG_FINSH_USING_MSH=y
|
||||
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_PRIORITY=30
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=16384
|
||||
CONFIG_FINSH_USING_HISTORY=y
|
||||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
|
@ -234,7 +234,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
|||
# Socket abstraction layer
|
||||
#
|
||||
CONFIG_RT_USING_SAL=y
|
||||
CONFIG_SAL_INTERNET_CHECK=y
|
||||
# CONFIG_SAL_INTERNET_CHECK is not set
|
||||
# CONFIG_SAL_USING_POSIX is not set
|
||||
CONFIG_SAL_SOCKETS_NUM=16
|
||||
|
||||
|
@ -242,10 +242,10 @@ CONFIG_SAL_SOCKETS_NUM=16
|
|||
# Network interface device
|
||||
#
|
||||
CONFIG_RT_USING_NETDEV=y
|
||||
CONFIG_NETDEV_USING_IFCONFIG=y
|
||||
CONFIG_NETDEV_USING_PING=y
|
||||
CONFIG_NETDEV_USING_NETSTAT=y
|
||||
CONFIG_NETDEV_USING_AUTO_DEFAULT=y
|
||||
# CONFIG_NETDEV_USING_IFCONFIG is not set
|
||||
# CONFIG_NETDEV_USING_PING is not set
|
||||
# CONFIG_NETDEV_USING_NETSTAT is not set
|
||||
# CONFIG_NETDEV_USING_AUTO_DEFAULT is not set
|
||||
# CONFIG_NETDEV_USING_IPV6 is not set
|
||||
CONFIG_NETDEV_IPV4=1
|
||||
CONFIG_NETDEV_IPV6=0
|
||||
|
@ -420,6 +420,7 @@ CONFIG_APPLICATION_SENSOR=y
|
|||
# CONFIG_USING_EMBEDDED_DATABASE_APP is not set
|
||||
# CONFIG_APP_USING_WEBNET is not set
|
||||
CONFIG_APP_BENCHMARK=y
|
||||
CONFIG_USING_BENCHMARK=y
|
||||
|
||||
#
|
||||
# lib
|
||||
|
|
|
@ -222,5 +222,5 @@ static int embenchmark_sequential(void) {
|
|||
// PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
// PRIV_SHELL_CMD_FUNCTION(embenchmark_sequential, run benchmark in sequential,
|
||||
// PRIV_SHELL_CMD_MAIN_ATTR);
|
||||
MSH_CMD_EXPORT(embenchmark_parallel, embench parallel);
|
||||
MSH_CMD_EXPORT(embenchmark_sequential, embench sequential);
|
||||
// MSH_CMD_EXPORT(embenchmark_parallel, embench parallel);
|
||||
// MSH_CMD_EXPORT(embenchmark_sequential, embench sequential);
|
||||
|
|
|
@ -3,7 +3,7 @@ import rtconfig
|
|||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
drv_path = cwd + "/../../../aiit_board/k210/kendryte-sdk/kendryte-sdk-source/lib/drivers/include"
|
||||
drv_path = cwd + "/../../../rt-thread/bsp/k210/driver/"
|
||||
src = [
|
||||
'board.c',
|
||||
'heap.c',
|
||||
|
|
|
@ -18,7 +18,7 @@ kendryte-sdk-source/lib/drivers/kpu.c
|
|||
kendryte-sdk-source/lib/drivers/plic.c
|
||||
kendryte-sdk-source/lib/drivers/pwm.c
|
||||
kendryte-sdk-source/lib/drivers/rtc.c
|
||||
kendryte-sdk-source/lib/drivers/sha256.c
|
||||
|
||||
kendryte-sdk-source/lib/drivers/spi.c
|
||||
kendryte-sdk-source/lib/drivers/sysctl.c
|
||||
kendryte-sdk-source/lib/drivers/timer.c
|
||||
|
@ -27,11 +27,20 @@ kendryte-sdk-source/lib/drivers/uarths.c
|
|||
kendryte-sdk-source/lib/drivers/utils.c
|
||||
kendryte-sdk-source/lib/drivers/wdt.c
|
||||
''')
|
||||
CPPPATH = [cwd + '/kendryte-sdk-source/lib/drivers/include',
|
||||
cwd + '/kendryte-sdk-source/lib/bsp/include',
|
||||
cwd + '/kendryte-sdk-source/lib/utils/include']
|
||||
CPPDEFINES = ['CONFIG_LOG_COLORS', 'CONFIG_LOG_ENABLE', 'CONFIG_LOG_LEVEL=LOG_VERBOSE', 'FPGA_PLL', 'LOG_KERNEL', '__riscv64']
|
||||
CPPPATH = [
|
||||
cwd + '/kendryte-sdk-source/lib/drivers/include',
|
||||
cwd + '/kendryte-sdk-source/lib/bsp/include',
|
||||
cwd + '/kendryte-sdk-source/lib/utils/include'
|
||||
]
|
||||
CPPDEFINES = [
|
||||
'CONFIG_LOG_COLORS', 'CONFIG_LOG_ENABLE', 'CONFIG_LOG_LEVEL=LOG_VERBOSE',
|
||||
'FPGA_PLL', 'LOG_KERNEL', '__riscv64'
|
||||
]
|
||||
|
||||
group = DefineGroup('SDK', src, depend = [''], CPPPATH = CPPPATH, LOCAL_CPPDEFINES = CPPDEFINES)
|
||||
group = DefineGroup('SDK',
|
||||
src,
|
||||
depend=[''],
|
||||
CPPPATH=CPPPATH,
|
||||
LOCAL_CPPDEFINES=CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
#define RT_USING_MSH
|
||||
#define FINSH_USING_MSH
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_PRIORITY 30
|
||||
#define FINSH_THREAD_STACK_SIZE 16384
|
||||
#define FINSH_USING_HISTORY
|
||||
#define FINSH_HISTORY_LINES 5
|
||||
|
@ -147,16 +147,11 @@
|
|||
/* Socket abstraction layer */
|
||||
|
||||
#define RT_USING_SAL
|
||||
#define SAL_INTERNET_CHECK
|
||||
#define SAL_SOCKETS_NUM 16
|
||||
|
||||
/* Network interface device */
|
||||
|
||||
#define RT_USING_NETDEV
|
||||
#define NETDEV_USING_IFCONFIG
|
||||
#define NETDEV_USING_PING
|
||||
#define NETDEV_USING_NETSTAT
|
||||
#define NETDEV_USING_AUTO_DEFAULT
|
||||
#define NETDEV_IPV4 1
|
||||
#define NETDEV_IPV6 0
|
||||
|
||||
|
@ -246,6 +241,7 @@
|
|||
|
||||
#define APPLICATION_SENSOR
|
||||
#define APP_BENCHMARK
|
||||
#define USING_BENCHMARK
|
||||
|
||||
/* lib */
|
||||
|
||||
|
|
Loading…
Reference in New Issue