Commit cd411b09 authored by Matthieu Dorier's avatar Matthieu Dorier

added test of prefetcher for load/store of objects

parent 3f69eaf5
...@@ -447,3 +447,42 @@ void LoadStoreTest::testPrefetchLoadStore() { ...@@ -447,3 +447,42 @@ void LoadStoreTest::testPrefetchLoadStore() {
} }
} }
} }
void LoadStoreTest::testAsyncPrefetchLoadStore() {
auto root = datastore->root();
auto mds = root.createDataSet("prefetch_run");
std::string label = "key";
{
TestObjectA obj_a;
TestObjectB obj_b;
for(unsigned i = 0; i < 20; i++) {
obj_a.x() = i;
obj_a.y() = 2*i;
obj_b.a() = 3*i;
obj_b.b() = "matthieu";
auto r = mds.createRun(i);
CPPUNIT_ASSERT(r.valid());
r.store(label, obj_a);
r.store(label, obj_b);
}
}
{
// iterate through the dataset with a prefetcher
AsyncEngine async(*datastore, 1);
Prefetcher p(*datastore, async);
p.fetchProduct<TestObjectA>(label);
p.fetchProduct<TestObjectB>(label);
unsigned i = 0;
for(auto& run : p(mds.runs())) {
TestObjectA obj_a;
TestObjectB obj_b;
run.load(p, label, obj_a);
run.load(p, label, obj_b);
CPPUNIT_ASSERT(obj_a.x() == i);
CPPUNIT_ASSERT(obj_a.y() == 2*i);
CPPUNIT_ASSERT(obj_b.a() == 3*i);
CPPUNIT_ASSERT(obj_b.b() == "matthieu");
i += 1;
}
}
}
...@@ -19,6 +19,7 @@ class LoadStoreTest : public CppUnit::TestFixture ...@@ -19,6 +19,7 @@ class LoadStoreTest : public CppUnit::TestFixture
CPPUNIT_TEST( testAsyncLoadStoreSubRun ); CPPUNIT_TEST( testAsyncLoadStoreSubRun );
CPPUNIT_TEST( testAsyncLoadStoreEvent ); CPPUNIT_TEST( testAsyncLoadStoreEvent );
CPPUNIT_TEST( testPrefetchLoadStore ); CPPUNIT_TEST( testPrefetchLoadStore );
CPPUNIT_TEST( testAsyncPrefetchLoadStore );
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
public: public:
...@@ -36,6 +37,7 @@ class LoadStoreTest : public CppUnit::TestFixture ...@@ -36,6 +37,7 @@ class LoadStoreTest : public CppUnit::TestFixture
void testAsyncLoadStoreSubRun(); void testAsyncLoadStoreSubRun();
void testAsyncLoadStoreEvent(); void testAsyncLoadStoreEvent();
void testPrefetchLoadStore(); void testPrefetchLoadStore();
void testAsyncPrefetchLoadStore();
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment