📄 main.c
字号:
/*
** Example of using PGO session IDs to indicate different builds of
** the same file.
*/
#include <ccblkfn.h>
#include <ctype.h>
#include <stdio.h>
#include <cycle_count.h>
#include "global.h"
#include "choices.h"
static const char data[] =
"This example demonstrates how Profile-Guided Optimization can be "
"affected by dual-core applications. This text will be processed "
"in two different ways, one by each core, but the code for both "
"versions resides in the same function, conditionally compiled. "
"PGO has to use session IDs to indicate which version of the file "
"is being profiled."
;
int main(void)
{
char c;
const char *s = data;
bool in_word = false;
int nAZ = 0, naz = 0, nx = 0;
int nc = 0, nw = 0, nl = 0;
cycle_t start_count, final_count;
#ifndef COREB
adi_core_b_enable(); /* start Core B running */
#endif
START_CYCLE_COUNT(start_count)
for (c = *s++; c; c = *s++) {
#ifdef COREA
if (EXPRA(isspace(c))) {
in_word = false;
if (EXPRB(c == '\n'))
nl++;
} else {
if (EXPRC(!in_word)) {
in_word = true;
nw++;
}
}
nc++;
#endif /* COREA */
#ifdef COREB
if (EXPRA(isupper(c)))
nAZ++;
else if (EXPRB(islower(c)))
naz++;
else
nx++;
#endif /* COREB */
}
STOP_CYCLE_COUNT(final_count, start_count)
#ifdef COREA
v_nw = nw;
v_nc = nc;
v_nl = nl;
while (!core_b_finished)
;
printf("nl = %d, nw = %d, nc = %d\n"
"nAZ = %d, naz = %d, nx = %d\n",
v_nl, v_nw, v_nc, v_nAZ, v_naz, v_nx);
PRINT_CYCLES("Core A cycles: ", final_count)
PRINT_CYCLES("Core B cycles: ", v_final_count)
return 0;
#endif
#ifdef COREB
v_nAZ = nAZ;
v_naz = naz;
v_nx = nx;
v_final_count = final_count;
core_b_finished = true;
while (true) ;
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -