提交 70a13ee1 编写于 作者: 饶先宏's avatar 饶先宏

202108051031

上级 b67ad835
......@@ -61,6 +61,8 @@ DEFINE_GUID(CLSID_CNN_BUF_W4, 0x9d2c00a4, 0x519f, 0x4b07, 0x82, 0x1e, 0x94, 0x34
int cnnInit();
#define CNNCELLDEBUG 0
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus
......
......@@ -85,8 +85,6 @@ IDLIST
VID(lineindex),
END_IDLIST
#define CONVDEBUG 1
MODULE_DECLARE(cnncell_convolution)
int input_w, input_h, input_c;
int output_w, output_h, output_c;
......@@ -100,7 +98,7 @@ MODULE_DECLARE(cnncell_convolution)
float* line_out;
short *coeff;
short *bias;
#if CONVDEBUG
#if CNNCELLDEBUG
FILE* pDumpFile;
#endif
END_MODULE_DECLARE(cnncell_convolution)
......@@ -211,7 +209,7 @@ DEFINE_FUNC(cnncell_convolution_gen_line) {
/* bias */
//if (layer_info->bias_term)
data_acc += pobj->bias[cc] * pobj->bias_scale;
#if CONVDEBUG
#if CNNCELLDEBUG
fprintf(pobj->pDumpFile, "%d, %d, %d, %f\n", vget(writeline), ww, cc, data_acc);
#endif
/* active function */
......@@ -223,7 +221,7 @@ DEFINE_FUNC(cnncell_convolution_gen_line) {
pobj->line_out[ww * pobj->output_c + cc] = data_acc;
}
}
#if CONVDEBUG
#if CNNCELLDEBUG
fflush(pobj->pDumpFile);
#endif
}
......@@ -398,7 +396,7 @@ MODULE_INIT(cnncell_convolution)
pobj->linesize = (pobj->input_w + 2 * pobj->pw) * pobj->input_c;
pobj->line_in = (float*)malloc(pobj->kh * pobj->linesize * sizeof(float));
pobj->line_out = (float*)malloc(pobj->output_w * pobj->output_c * sizeof(float));
#if CONVDEBUG
#if CNNCELLDEBUG
{
char filename[80];
sprintf(filename, "d:/gitwork/debugfile/cnncell_%s.txt", pobj->data.name);
......
......@@ -81,8 +81,6 @@ IDLIST
VID(index),
END_IDLIST
#define INPD_DEBUG 1
MODULE_DECLARE(cnncell_innerproduct)
int input_w, input_h, input_c;
int output_w, output_h, output_c;
......@@ -92,7 +90,7 @@ MODULE_DECLARE(cnncell_innerproduct)
short* bias;
float* inbuf;
float* outbuf;
#ifdef INPD_DEBUG
#if CNNCELLDEBUG
FILE* pDumpFile;
#endif
END_MODULE_DECLARE(cnncell_innerproduct)
......@@ -167,11 +165,11 @@ DEFINE_FUNC(cnncell_innerproduct_calc) {
pobj->outbuf[oc] *= pobj->coeff_scale;
/* bias */
pobj->outbuf[oc] += bias[oc] * pobj->bias_scale;
#ifdef INPD_DEBUG
#if CNNCELLDEBUG
fprintf(pobj->pDumpFile, "%d, %f\n", oc, pobj->outbuf[oc]);
#endif
}
#ifdef INPD_DEBUG
#if CNNCELLDEBUG
fflush(pobj->pDumpFile);
#endif
return 0;
......@@ -308,7 +306,7 @@ MODULE_INIT(cnncell_innerproduct)
pobj->bias = (short*)malloc(pobj->output_c * pobj->output_h * pobj->output_w * sizeof(short));
pobj->inbuf = (float*)malloc(pobj->input_c * pobj->input_h * pobj->input_w * sizeof(float));
pobj->outbuf = (float*)malloc(pobj->output_c * pobj->output_h * pobj->output_w * sizeof(float));
#ifdef INPD_DEBUG
#if CNNCELLDEBUG
{
char filename[80];
sprintf(filename, "d:/gitwork/debugfile/cnncell_%s.txt", pobj->data.name);
......
......@@ -65,8 +65,6 @@ IDLIST
VID(state),
END_IDLIST
#define LRNDEBUG 1
MODULE_DECLARE(cnncell_lrn)
int w, h, c;
int region;
......@@ -74,7 +72,7 @@ MODULE_DECLARE(cnncell_lrn)
float k, alpha, beta;
float* buf;
float* square;
#if LRNDEBUG
#if CNNCELLDEBUG
FILE* pDumpFile;
#endif
END_MODULE_DECLARE(cnncell_lrn)
......@@ -147,7 +145,7 @@ DEFINE_FUNC(cnncell_lrn_gen_line) {
sum += square[pobj->local_size] - square[0];
square++;
}
#if LRNDEBUG
#if CNNCELLDEBUG
for (j = 0; j < pobj->c; j++) {
fprintf(pobj->pDumpFile, "%d, %f\n", j, pobj->buf[j]);
}
......@@ -211,7 +209,7 @@ MODULE_INIT(cnncell_lrn)
pobj->alpha = (float)MODULE_PARAM_REAL(5);
pobj->beta = (float)MODULE_PARAM_REAL(6);
pobj->region = (int)MODULE_PARAM(7);
#if LRNDEBUG
#if CNNCELLDEBUG
{
char filename[80];
sprintf(filename, "d:/gitwork/debugfile/cnncell_%s.txt", pobj->data.name);
......
......@@ -69,8 +69,6 @@ IDLIST
VID(lineindex),
END_IDLIST
#define POOLINGDEBUG 1
MODULE_DECLARE(cnncell_pooling)
int input_w, input_h, input_c;
int output_w, output_h, output_c;
......@@ -80,7 +78,7 @@ MODULE_DECLARE(cnncell_pooling)
int linesize;
float* line_in;
float* line_out;
#if POOLINGDEBUG
#if CNNCELLDEBUG
FILE* pDumpFile;
#endif
......@@ -151,7 +149,7 @@ DEFINE_FUNC(cnncell_pooling_gen_line) {
}
}
}
#if POOLINGDEBUG
#if CNNCELLDEBUG
fprintf(pobj->pDumpFile, "%d, %d, %d, %f\n", vget(writeline), ww, cc, data_max);
#endif
#if 0
......@@ -179,7 +177,7 @@ DEFINE_FUNC(cnncell_pooling_gen_line) {
}
}
data_total /= (pobj->kh * pobj->kw);
#if POOLINGDEBUG
#if CNNCELLDEBUG
fprintf(pobj->pDumpFile, "%d, %d, %d, %f\n", vget(writeline), ww, cc, data_total);
#endif
/* active function */
......@@ -194,7 +192,7 @@ DEFINE_FUNC(cnncell_pooling_gen_line) {
}
}
}
#if POOLINGDEBUG
#if CNNCELLDEBUG
fflush(pobj->pDumpFile);
#endif
}
......@@ -322,7 +320,7 @@ MODULE_INIT(cnncell_pooling)
pobj->line_in = (float*)malloc(pobj->kh * pobj->linesize * sizeof(float));
memset(pobj->line_in, 0, pobj->kh* pobj->linesize * sizeof(float));
pobj->line_out = (float*)malloc(pobj->output_w * pobj->output_c * sizeof(float));
#if POOLINGDEBUG
#if CNNCELLDEBUG
{
char filename[80];
sprintf(filename, "d:/gitwork/debugfile/cnncell_%s.txt", pobj->data.name);
......
......@@ -65,13 +65,11 @@ IDLIST
VID(index),
END_IDLIST
#define SOFTMAX_DEBUG 1
MODULE_DECLARE(cnncell_softmax)
int w, h, c;
float* inbuf;
float* outbuf;
#ifdef SOFTMAX_DEBUG
#if CNNCELLDEBUG
FILE* pDumpFile;
#endif
END_MODULE_DECLARE(cnncell_softmax)
......@@ -104,7 +102,7 @@ DEFINE_FUNC(cnncell_softmax_calc) {
for (i = 0; i < pobj->c * pobj->w * pobj->h; i++) {
pobj->outbuf[i] /= total;
}
#ifdef SOFTMAX_DEBUG
#if CNNCELLDEBUG
for (i = 0; i < pobj->c * pobj->w * pobj->h; i++) {
fprintf(pobj->pDumpFile, "%d, %f\n", i, pobj->outbuf[i]);
}
......@@ -192,7 +190,7 @@ MODULE_INIT(cnncell_softmax)
pobj->c = (int)MODULE_PARAM(2);
pobj->inbuf = (float*)malloc(pobj->c * pobj->h * pobj->w * sizeof(float));
pobj->outbuf = (float*)malloc(pobj->c * pobj->h * pobj->w * sizeof(float));
#ifdef SOFTMAX_DEBUG
#if CNNCELLDEBUG
{
char filename[80];
sprintf(filename, "d:/gitwork/debugfile/cnncell_%s.txt", pobj->data.name);
......
......@@ -49,7 +49,7 @@ unsigned long long clocks = 0;
static int running = 1;
#define VCDOUTPUT 1
#define VCDOUTPUT 0
int cnnInit();
......@@ -66,6 +66,10 @@ int main(int argc, char* argv[])
int i;
int width;
int count, unitcount;
time_t starttime;
time_t lasttime;
IHDL4SEWaveOutput** vcdfile;
cnnInit();
sim = hdl4sesimCreateSimulator();
......@@ -76,7 +80,7 @@ int main(int argc, char* argv[])
objectPrintInfo(stdout, fprintf);
#if VCDOUTPUT
vcdfile = hdl4sesimCreateVCDFile("googlenet.vcd");
objectCall2(vcdfile, AddSignal, "/top/net/cnn_buf_167", "wRead");
objectCall2(vcdfile, AddSignal, "/top/net/cnn_buf_167", "wDataValid");
objectCall2(vcdfile, AddSignal, "/top/net/cnn_buf_167", "bReadData");
......@@ -128,6 +132,7 @@ int main(int argc, char* argv[])
objectCall0(vcdfile, StartRecord);
#endif
clocks = 0;
lasttime = starttime = time(NULL);
do {
objectCall0(sim, ClkTick);
#if VCDOUTPUT
......@@ -137,8 +142,14 @@ int main(int argc, char* argv[])
if (clocks == 2)
objectCall1(sim, SetReset, 1);
clocks++;
if ((clocks & 0xFFF) == 0)
printf("clocks: %lld\n", clocks);
if ((clocks & 0xFFF) == 0) {
time_t thistime = time(NULL);
printf("clocks: %lld, TSPD=%lfcps, LSPD=%lfcps\n",
clocks,
(double)clocks / (double)(thistime - starttime),
4096.0 / (double)(thistime - lasttime));
lasttime = time(NULL);
}
} while (running);
#if VCDOUTPUT
objectCall0(vcdfile, StopRecord);
......
......@@ -224,7 +224,7 @@ static int hdl4sesim_hdl4se_simulator_ClkTick(HOBJECT object)
for (i = 0; i < pobj->singlethreadmodules.itemcount; i++) {
hdl4se_module_ClkTick(&((IHDL4SEModuleVar*)(pobj->singlethreadmodules.array[i]))->data);
}
#pragma omp parallel for num_threads(16)
//#pragma omp parallel for num_threads(4)
for (i = 0; i < pobj->multithreadmodules.itemcount; i++) {
hdl4se_module_ClkTick(&((IHDL4SEModuleVar*)(pobj->multithreadmodules.array[i]))->data);
}
......@@ -243,7 +243,7 @@ static int hdl4sesim_hdl4se_simulator_Setup(HOBJECT object)
for (i = 0; i < pobj->singlethreadmodules.itemcount; i++) {
hdl4se_module_Setup(&((IHDL4SEModuleVar*)(pobj->singlethreadmodules.array[i]))->data);
}
#pragma omp parallel for num_threads(16)
//#pragma omp parallel for num_threads(4)
for (i = 0; i < pobj->multithreadmodules.itemcount; i++) {
hdl4se_module_Setup(&((IHDL4SEModuleVar*)(pobj->multithreadmodules.array[i]))->data);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册