cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Newbie
Newbie
4,239 Views
Registered: ‎06-28-2017

Failed dataflow checking: it can only be written in one process function

Jump to solution

I was trying to generate IP core for a project that deals with Convolutional neural network. Now, while I ran the .tcl file using the Vivado HLS 2016.4 , it gave me errors as, 

 

ERROR: [XFORM 203-711] Internal global variable 'l1' failed dataflow checking: it can only be read in one process function.

ERROR: [XFORM 203-711] Internal global variable 'o1' failed dataflow checking: it can only be read in one process function.

 

ERROR: [HLS 200-70] Pre-synthesis failed.

 

Now, I searched in the forum and found that someone else had similar problem. So, according to the solution, I tried changing the variables to static. But did not work in my case. 

I don't know the reason, but the similar process worked fine with Vivado HLS 2014.2

 

Here is the snippets from the code: 

/2 layer (linear):
 Lin1:	for (i = 0; i < LIN_1; i++) {
		l1[i] = lb1[i];
		for (j = 0; j < LIN_0; j++) {
			v = lin[j] * lw1[i][j];
			l1[i] += v;
		}
	}
//Classification (LogSoftMax):
	max = -HUGE_VAL;
 Class1:for (i = 0; i < CLASSES; i++) {
		if (l1[i] > max) {
			max = l1[i];
		}
	}

	x = 0;
 Class2:for (i = 0; i < CLASSES; i++) {
		v = l1[i] - max;
		l1[i] = exp(v);
		x += l1[i];
	}

 Class3:for (i = 0; i < CLASSES; i++) {
		res[i] = l1[i] / x;
		res[i] = log(res[i]);
	}

 

 

//Load biases
	for (k = 0; k < FM_1; k++) {
		for (i = 0; i < DIMH_1; i++) {
			for (j = 0; j < DIMW_1; j++) {
				o1[k][i][j] = b1[k];
			}
		}
	}
#pragma HLS PIPELINE
							actual_index =
							    indexes[s +
								    l * KH_1];
							actual_index += n;
							v = w1[k][l][s][t] *
							    buf[actual_index];
							o1[k][i][j] += v;
//Hyperbolic tangent
							y = exp(o1[k][i][j]);
							x = exp(-o1[k][i][j]);
							o1[k][i][j] = y - x;
							y = y + x;
							o1[k][i][j] /= y;
						

o1 and l1 is declared in the header file,

//Output tensor
#define DIMW_1 12
#define DIMH_1 12
static REAL o1[FM_1][DIMH_1][DIMW_1];

.....
.....

//Output tensor
static REAL l1[LIN_1];

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Scholar
Scholar
6,165 Views
Registered: ‎04-26-2015

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution

@rifat_buet Dataflow just isn't appropriate for this algorithm; the algorithm has several inherently-sequential steps and dataflow is only useful when several steps can be run in parallel.

 

In particular, I'd focus on merging loops (#pragma HLS LOOP_MERGE). Lin1 and Class1 could very easily be merged. In your next piece of code, loading the biases and performing the hyperbolic tangent could well be merged. Both should give you significant savings in both runtime and resources, unless HLS has already done that automatically.

View solution in original post

0 Kudos
5 Replies
Highlighted
Scholar
Scholar
4,211 Views
Registered: ‎04-26-2015

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution

The error message really says it all. For dataflow, you have to write to a variable/array in one location and read it in another location.

 

In your code, you both write (and possibly read, depending on how HLS does it) l1 in Lin1, then you read it in Class1, then you read it and write it in Class2, then you read it in Class3. HLS cannot handle this behaviour.

 

Apart from that, Class1 to Class2 isn't really dataflow friendly anyway, because Class1 has to complete before Class2 can start (until Class1 completes, "max" isn't defined).

0 Kudos
Newbie
Newbie
4,203 Views
Registered: ‎06-28-2017

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution
Hi @u4223374, thanks for the comment. Do you have any idea why it worked with 2014.2 and possibly 2015 versions?
0 Kudos
Highlighted
Scholar
Scholar
4,196 Views
Registered: ‎04-26-2015

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution

@rifat_buet I would hazard a guess that they simply investigated the code, said "nope, can't do dataflow here", and continued without it. Newer versions of HLS do seem to be better at actually stopping you if you've requested something that can't be done.

 

It's possible that the older tools were able to automatically partition the design, or maybe your old "similar" design was manually partitioned. I suspect that moving Class1/Class2/Class3 into a single separate function (call it ClassN) and only applying dataflow between Lin1 and ClassN would work, although it would require ping-pong buffers rather than the preferred FIFOs.

 

 

0 Kudos
Highlighted
Newbie
Newbie
4,063 Views
Registered: ‎06-28-2017

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution

Thank you very much @ u4223374 . I am very much novice in this field. So, as you said the code I am working with is not data flow friendly, what kind of modification I can do. Do, I need to add more functions to read and write? or I need to create different classes for reading and writing to variables? 

0 Kudos
Highlighted
Scholar
Scholar
6,166 Views
Registered: ‎04-26-2015

Re: Failed dataflow checking: it can only be written in one process function

Jump to solution

@rifat_buet Dataflow just isn't appropriate for this algorithm; the algorithm has several inherently-sequential steps and dataflow is only useful when several steps can be run in parallel.

 

In particular, I'd focus on merging loops (#pragma HLS LOOP_MERGE). Lin1 and Class1 could very easily be merged. In your next piece of code, loading the biases and performing the hyperbolic tangent could well be merged. Both should give you significant savings in both runtime and resources, unless HLS has already done that automatically.

View solution in original post

0 Kudos