Add hipStreamQuery
Change-Id: Ib0813b1065feba4fe9ae861d24cfc6f9c5f580be
Αυτή η υποβολή περιλαμβάνεται σε:
@@ -33,7 +33,8 @@ public:
|
||||
Streamer(size_t numElements);
|
||||
~Streamer();
|
||||
void runAsync();
|
||||
void waitComplete();
|
||||
void queryUntilComplete();
|
||||
|
||||
|
||||
private:
|
||||
T *_A_h;
|
||||
@@ -66,11 +67,24 @@ void Streamer<T>::runAsync()
|
||||
printf ("testing: %s numElements=%zu size=%6.2fMB\n", __func__, _numElements, _numElements * sizeof(T) / 1024.0/1024.0);
|
||||
unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, _numElements);
|
||||
hipLaunchKernel(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, _stream, _A_d, _B_d, _C_d, _numElements);
|
||||
|
||||
// Test case where hipStreamWaitEvent waits on same event we just placed into the queue.
|
||||
HIPCHECK(hipEventRecord(_event, _stream));
|
||||
HIPCHECK(hipStreamWaitEvent(_stream, _event, 0));
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Streamer<T>::queryUntilComplete()
|
||||
{
|
||||
int numQueries = 0;
|
||||
hipError_t e = hipSuccess;
|
||||
do {
|
||||
numQueries++;
|
||||
e = hipStreamQuery(_stream);
|
||||
} while (e != hipSuccess) ;
|
||||
|
||||
printf ("completed after %d queries\n", numQueries);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -113,11 +127,28 @@ int main(int argc, char *argv[])
|
||||
streamers.push_back(s);
|
||||
}
|
||||
|
||||
for (int i=0; i<p_streams; i++) {
|
||||
streamers[i]->runAsync();
|
||||
if (p_tests & 0x1) {
|
||||
printf ("==> Test 0x1 runAsnc\n");
|
||||
for (int i=0; i<p_streams; i++) {
|
||||
streamers[i]->runAsync();
|
||||
}
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
if (p_tests & 0x2) {
|
||||
printf ("==> Test 0x2 queryUntilComplete\n");
|
||||
for (int i=0; i<p_streams; i++) {
|
||||
streamers[i]->runAsync();
|
||||
streamers[i]->queryUntilComplete();
|
||||
}
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
}
|
||||
|
||||
if (p_tests & 0x4) {
|
||||
hipStreamQuery(0/* try null stream*/);
|
||||
|
||||
}
|
||||
|
||||
HIPCHECK(hipDeviceSynchronize());
|
||||
|
||||
passed();
|
||||
}
|
||||
|
||||
Αναφορά σε νέο ζήτημα
Block a user