Commit 589e315d authored by Peter Mitsis's avatar Peter Mitsis Committed by Fabio Baltieri
Browse files

tests: Fix app_kernel benchmark to run on cavs25



Instead of sending output strings to stdout via fputs(), just
print them using printk(). This allows the output to be detected
by twister.

Fixes #60676

Signed-off-by: default avatarPeter Mitsis <peter.mitsis@intel.com>
parent ff09cc74
Loading
Loading
Loading
Loading
+15 −15
Original line number Diff line number Diff line
@@ -20,14 +20,14 @@ void queue_test(void)
	uint32_t et; /* elapsed time */
	int i;

	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	et = BENCH_START();
	for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
		k_msgq_put(&DEMOQX1, data_bench, K_FOREVER);
	}
	et = TIME_STAMP_DELTA_GET(et);

	PRINT_F(output_file, FORMAT, "enqueue 1 byte msg in FIFO",
	PRINT_F(FORMAT, "enqueue 1 byte msg in FIFO",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));

	et = BENCH_START();
@@ -37,7 +37,7 @@ void queue_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT, "dequeue 1 byte msg in FIFO",
	PRINT_F(FORMAT, "dequeue 1 byte msg in FIFO",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));

	et = BENCH_START();
@@ -47,7 +47,7 @@ void queue_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT, "enqueue 4 bytes msg in FIFO",
	PRINT_F(FORMAT, "enqueue 4 bytes msg in FIFO",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));

	et = BENCH_START();
@@ -57,7 +57,7 @@ void queue_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT, "dequeue 4 bytes msg in FIFO",
	PRINT_F(FORMAT, "dequeue 4 bytes msg in FIFO",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));

	k_sem_give(&STARTRCV);
@@ -69,7 +69,7 @@ void queue_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT,
	PRINT_F(FORMAT,
		"enqueue 1 byte msg in FIFO to a waiting higher priority task",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));

@@ -80,7 +80,7 @@ void queue_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT,
	PRINT_F(FORMAT,
		"enqueue 4 bytes in FIFO to a waiting higher priority task",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS));
}
+30 −32
Original line number Diff line number Diff line
@@ -16,44 +16,42 @@ static struct k_mbox_msg message;
#define PRINT_HEADER()                                                       \
	(PRINT_STRING                                                        \
	   ("|   size(B) |       time/packet (usec)       |          MB/sec" \
	    "                |\n", output_file))
	    "                |\n"))
#define PRINT_ONE_RESULT()                                                   \
	PRINT_F(output_file, "|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,\
	PRINT_F("|%11u|%32.3f|%32f|\n", putsize, puttime / 1000.0,           \
		(1000.0 * putsize) / SAFE_DIVISOR(puttime))

#define PRINT_OVERHEAD()                                                     \
	PRINT_F(output_file,						\
	     "| message overhead:  %10.3f     usec/packet                   "\
	PRINT_F("| message overhead:  %10.3f     usec/packet               " \
		"                |\n", empty_msg_put_time / 1000.0)

#define PRINT_XFER_RATE()                                                     \
	double netto_transfer_rate;                                           \
	netto_transfer_rate = 1000.0 * \
		(putsize >> 1) / SAFE_DIVISOR(puttime - empty_msg_put_time);  \
	PRINT_F(output_file,						\
	     "| raw transfer rate:     %10.3f MB/sec (without"		\
	PRINT_F("| raw transfer rate:     %10.3f MB/sec (without"             \
		" overhead)                 |\n", netto_transfer_rate)

#else
#define PRINT_HEADER()                                                       \
	(PRINT_STRING                                                        \
	   ("|   size(B) |       time/packet (nsec)       |          KB/sec" \
	    "                |\n", output_file))
	    "                |\n"))

#define PRINT_ONE_RESULT()                                                   \
	PRINT_F(output_file, "|%11u|%32u|%32u|\n", putsize, puttime,	     \
	     (uint32_t)(((uint64_t)putsize * 1000000U) / SAFE_DIVISOR(puttime)))
	PRINT_F("|%11u|%32u|%32u|\n", putsize, puttime,	                     \
		(uint32_t)                                                   \
		(((uint64_t)putsize * 1000000U) / SAFE_DIVISOR(puttime)))

#define PRINT_OVERHEAD()                                                     \
	PRINT_F(output_file,						\
	     "| message overhead:  %10u     nsec/packet                     "\
	PRINT_F("| message overhead:  %10u     nsec/packet                 " \
	     "              |\n", empty_msg_put_time)

#define PRINT_XFER_RATE()                                                    \
	PRINT_F(output_file, "| raw transfer rate:     %10u KB/sec (without" \
	PRINT_F("| raw transfer rate:     %10u KB/sec (without"              \
		" overhead)                 |\n",                            \
	     (uint32_t)((uint64_t)(putsize >> 1) * 1000000U                   \
	     / SAFE_DIVISOR(puttime - empty_msg_put_time)))
		(uint32_t)((uint64_t)(putsize >> 1) * 1000000U /             \
			   SAFE_DIVISOR(puttime - empty_msg_put_time)))

#endif

@@ -80,19 +78,19 @@ void mailbox_test(void)
	unsigned int empty_msg_put_time;
	struct getinfo getinfo;

	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	PRINT_STRING("|                "
		     "M A I L B O X   M E A S U R E M E N T S"
				 "                      |\n", output_file);
	PRINT_STRING(dashline, output_file);
		     "                      |\n");
	PRINT_STRING(dashline);
	PRINT_STRING("| Send mailbox message to waiting high "
		 "priority task and wait                 |\n", output_file);
	PRINT_F(output_file, "| repeat for %4d times and take the "
		     "priority task and wait                 |\n");
	PRINT_F("| repeat for %4d times and take the "
		"average                                  |\n",
		NR_OF_MBOX_RUNS);
	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	PRINT_HEADER();
	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	k_sem_reset(&SEM0);
	k_sem_give(&STARTRCV);

@@ -110,7 +108,7 @@ void mailbox_test(void)
		k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
		PRINT_ONE_RESULT();
	}
	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	PRINT_OVERHEAD();
	PRINT_XFER_RATE();
}
+8 −33
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ struct k_pipe *test_pipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
char sline[SLINE_LEN + 1];
const char newline[] = "\n";

FILE *output_file;

/*
 * Time in timer cycles necessary to read time.
 * Used for correction in time measurements.
@@ -72,26 +70,6 @@ int kbhit(void)
	return 0;
}


/**
 *
 * @brief Prepares the test output
 *
 * @param continuously   Run test till the user presses the key.
 * @param autorun        Expect user input.
 *
 */
void init_output(int *continuously, int *autorun)
{
	ARG_UNUSED(continuously);
	ARG_UNUSED(autorun);

	/*
	 * send all printf and fprintf to console
	 */
	output_file = stdout;
}

/**
 *
 * @brief Close output for the test
@@ -113,18 +91,16 @@ void output_close(void)
 */
int main(void)
{
	int autorun = 0, continuously = 0;
	int continuously = 0;

	init_output(&continuously, &autorun);
	bench_test_init();

	PRINT_STRING(newline, output_file);
	PRINT_STRING(newline);
	do {
		PRINT_STRING(dashline, output_file);
		PRINT_STRING(dashline);
		PRINT_STRING("|          S I M P L E   S E R V I C E    "
					 "M E A S U R E M E N T S  |  nsec    |\n",
					 output_file);
		PRINT_STRING(dashline, output_file);
			     "M E A S U R E M E N T S  |  nsec    |\n");
		PRINT_STRING(dashline);
		queue_test();
		sema_test();
		mutex_test();
@@ -132,10 +108,9 @@ int main(void)
		mailbox_test();
		pipe_test();
		PRINT_STRING("|         END OF TESTS                     "
					 "                                   |\n",
					 output_file);
		PRINT_STRING(dashline, output_file);
		PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n", output_file);
			     "                                   |\n");
		PRINT_STRING(dashline);
		PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n");
		TC_PRINT_RUNID;
	} while (continuously && !kbhit());

+7 −10
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@
extern char msg[MAX_MSG];
extern char data_bench[MESSAGE_SIZE];
extern struct k_pipe *test_pipes[];
extern FILE *output_file;
extern const char newline[];
extern char sline[];

@@ -150,25 +149,24 @@ extern struct k_mem_slab MAP1;


/* PRINT_STRING
 * Macro to print an ASCII NULL terminated string. fprintf is used
 * so output can go to console.
 * Macro to print an ASCII NULL terminated string.
 */
#define PRINT_STRING(string, stream)  fputs(string, stream)
#define PRINT_STRING(string)  printk("%s", string)

/* PRINT_F
 * Macro to print a formatted output string. fprintf is used when
 * Macro to print a formatted output string.
 * Assumed that sline character array of SLINE_LEN + 1 characters
 * is defined in the main file
 */

#define PRINT_F(stream, fmt, ...)					\
#define PRINT_F(fmt, ...)					        \
{									\
	snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__);                 \
	PRINT_STRING(sline, stream);					\
	PRINT_STRING(sline);					        \
}

#define PRINT_OVERFLOW_ERROR()						\
	PRINT_F(output_file, __FILE__":%d Error: tick occurred\n", __LINE__)
	PRINT_F(__FILE__":%d Error: tick occurred\n", __LINE__)

static inline uint32_t BENCH_START(void)
{
@@ -187,5 +185,4 @@ static inline void check_result(void)
	}
}


#endif /* _MASTER_H */
+3 −3
Original line number Diff line number Diff line
@@ -24,12 +24,12 @@ void memorymap_test(void)
	void *p;
	int alloc_status;

	PRINT_STRING(dashline, output_file);
	PRINT_STRING(dashline);
	et = BENCH_START();
	for (i = 0; i < NR_OF_MAP_RUNS; i++) {
		alloc_status = k_mem_slab_alloc(&MAP1, &p, K_FOREVER);
		if (alloc_status != 0) {
			PRINT_F(output_file, FORMAT,
			PRINT_F(FORMAT,
				"Error: Slab allocation failed.", alloc_status);
			break;
		}
@@ -38,7 +38,7 @@ void memorymap_test(void)
	et = TIME_STAMP_DELTA_GET(et);
	check_result();

	PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page",
	PRINT_F(FORMAT, "average alloc and dealloc memory page",
		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS)));
}

Loading