cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Raistmer
Adept II

Stream read queueing

is it possible?

For example, there are 3 streams.
read to each stream takes let say 5ms.
Is it possible to issue 3 stream reads at once then wait ~15ms or wait should be added after each stream read.

That is, what will better:

1)
A.read(buf1);
Sleep(5);
B.read(buf2);
Sleep(5);
C.read(buf3);
Sleep(5);

or

2)
A.read(buf1);
B.read(buf2);
C.read(buf3);
Sleep(15);

?
0 Likes
5 Replies
gaurav_garg
Adept I

Both can be used. But, I think second one would be better, as it would help to hide Setup time required in Brook+ StreamRead.

0 Likes

Thanks.
And next question, if all these 3 streams used later in kernel that runs let say 20ms, what will give better CPU usage?
1)
A.read(buf1);
B.read(buf2);
C.read(buf3);
Sleep(15);
ABC_kernel(A,B,C,dest);
Sleep(20);

or 2)
A.read(buf1);
B.read(buf2);
C.read(buf3);
ABC_kernel(A,B,C,dest);
Sleep(35);

?
0 Likes

First one. The kernel launch will wait for streamReads to complete on all the streams passed as argument and then only it will return.

But, usually kernel launch setup time also include kernel compilation, it might be good idea to sleep for lesser period after stream reads.

A.read(buf1);
B.read(buf2);
C.read(buf3);
Sleep(t);  // t < 15
ABC_kernel(A,B,C,dest);
Sleep(20);

0 Likes

I see, thanks again

BTW, mentioned kernel compilation performed once per process launch on first kernel call or each kernel call even it in loop ?
0 Likes

Only on first kernel call.

0 Likes