Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HEPnOS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sds
HEP
HEPnOS
Commits
a99a7121
Commit
a99a7121
authored
Mar 11, 2020
by
Matthieu Dorier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enabled Prefetcher for SubRun
parent
5f577a11
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
36 deletions
+158
-36
include/hepnos/SubRun.hpp
include/hepnos/SubRun.hpp
+2
-0
src/SubRun.cpp
src/SubRun.cpp
+111
-35
test/SubRunTest.cpp
test/SubRunTest.cpp
+45
-1
No files found.
include/hepnos/SubRun.hpp
View file @
a99a7121
...
...
@@ -349,6 +349,8 @@ class SubRun : public KeyValueContainer {
class
SubRun
::
const_iterator
{
friend
class
SubRun
;
protected:
/**
...
...
src/SubRun.cpp
View file @
a99a7121
...
...
@@ -7,6 +7,8 @@
#include <memory>
#include "hepnos/SubRun.hpp"
#include "hepnos/AsyncEngine.hpp"
#include "hepnos/Prefetcher.hpp"
#include "PrefetcherImpl.hpp"
#include "ItemImpl.hpp"
#include "DataStoreImpl.hpp"
#include "WriteBatchImpl.hpp"
...
...
@@ -14,8 +16,58 @@
namespace
hepnos
{
////////////////////////////////////////////////////////////////////////////////////////////
// SubRun::const_iterator::Impl implementation
////////////////////////////////////////////////////////////////////////////////////////////
class
SubRun
::
const_iterator
::
Impl
{
public:
Event
m_current_event
;
std
::
shared_ptr
<
PrefetcherImpl
>
m_prefetcher
;
Impl
()
:
m_current_event
()
{}
Impl
(
const
Event
&
event
)
:
m_current_event
(
event
)
{}
Impl
(
Event
&&
event
)
:
m_current_event
(
std
::
move
(
event
))
{}
Impl
(
const
Impl
&
other
)
:
m_current_event
(
other
.
m_current_event
)
{}
~
Impl
()
{
if
(
m_prefetcher
)
m_prefetcher
->
m_associated
=
false
;
}
bool
operator
==
(
const
Impl
&
other
)
const
{
return
m_current_event
==
other
.
m_current_event
;
}
void
setPrefetcher
(
const
std
::
shared_ptr
<
PrefetcherImpl
>&
p
)
{
if
(
p
->
m_associated
)
throw
Exception
(
"Prefetcher object already in use"
);
if
(
m_prefetcher
)
m_prefetcher
->
m_associated
=
false
;
m_prefetcher
=
p
;
m_prefetcher
->
m_associated
=
true
;
}
};
static
SubRun
::
iterator
SubRun_end
;
////////////////////////////////////////////////////////////////////////////////////////////
// SubRun implementation
////////////////////////////////////////////////////////////////////////////////////////////
SubRun
::
SubRun
()
:
m_impl
(
std
::
make_shared
<
ItemImpl
>
(
nullptr
,
UUID
(),
InvalidRunNumber
))
{}
...
...
@@ -175,11 +227,23 @@ SubRun::iterator SubRun::find(const EventNumber& eventNumber) {
return
iterator
(
Event
(
std
::
make_shared
<
ItemImpl
>
(
m_impl
->
m_datastore
,
id
.
dataset
,
id
.
run
,
id
.
subrun
,
eventNumber
)));
}
SubRun
::
const_iterator
SubRun
::
find
(
const
EventNumber
&
eventNumber
)
const
{
iterator
it
=
const_cast
<
SubRun
*>
(
this
)
->
find
(
eventNumber
);
SubRun
::
iterator
SubRun
::
find
(
const
EventNumber
&
eventNumber
,
const
Prefetcher
&
prefetcher
)
{
auto
it
=
find
(
eventNumber
);
if
(
it
!=
end
())
{
it
.
m_impl
->
setPrefetcher
(
prefetcher
.
m_impl
);
prefetcher
.
m_impl
->
prefetchFrom
(
ItemType
::
EVENT
,
ItemType
::
SUBRUN
,
it
.
m_impl
->
m_current_event
.
m_impl
);
}
return
it
;
}
SubRun
::
const_iterator
SubRun
::
find
(
const
EventNumber
&
eventNumber
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
find
(
eventNumber
);
}
SubRun
::
const_iterator
SubRun
::
find
(
const
EventNumber
&
eventNumber
,
const
Prefetcher
&
prefetcher
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
find
(
eventNumber
,
prefetcher
);
}
SubRun
::
iterator
SubRun
::
begin
()
{
auto
it
=
find
(
0
);
if
(
it
!=
end
())
return
it
;
...
...
@@ -193,6 +257,15 @@ SubRun::iterator SubRun::begin() {
else
return
end
();
}
SubRun
::
iterator
SubRun
::
begin
(
const
Prefetcher
&
prefetcher
)
{
auto
it
=
begin
();
if
(
it
!=
end
())
{
it
.
m_impl
->
setPrefetcher
(
prefetcher
.
m_impl
);
prefetcher
.
m_impl
->
prefetchFrom
(
ItemType
::
EVENT
,
ItemType
::
SUBRUN
,
it
.
m_impl
->
m_current_event
.
m_impl
);
}
return
it
;
}
SubRun
::
iterator
SubRun
::
end
()
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
...
...
@@ -204,6 +277,10 @@ SubRun::const_iterator SubRun::begin() const {
return
const_iterator
(
const_cast
<
SubRun
*>
(
this
)
->
begin
());
}
SubRun
::
const_iterator
SubRun
::
begin
(
const
Prefetcher
&
prefetcher
)
const
{
return
const_iterator
(
const_cast
<
SubRun
*>
(
this
)
->
begin
(
prefetcher
));
}
SubRun
::
const_iterator
SubRun
::
end
()
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
...
...
@@ -215,6 +292,10 @@ SubRun::const_iterator SubRun::cbegin() const {
return
const_iterator
(
const_cast
<
SubRun
*>
(
this
)
->
begin
());
}
SubRun
::
const_iterator
SubRun
::
cbegin
(
const
Prefetcher
&
prefetcher
)
const
{
return
const_iterator
(
const_cast
<
SubRun
*>
(
this
)
->
begin
(
prefetcher
));
}
SubRun
::
const_iterator
SubRun
::
cend
()
const
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
...
...
@@ -248,11 +329,23 @@ SubRun::iterator SubRun::lower_bound(const EventNumber& lb) {
}
}
SubRun
::
const_iterator
SubRun
::
lower_bound
(
const
EventNumber
&
lb
)
const
{
iterator
it
=
const_cast
<
SubRun
*>
(
this
)
->
lower_bound
(
lb
);
SubRun
::
iterator
SubRun
::
lower_bound
(
const
EventNumber
&
lb
,
const
Prefetcher
&
prefetcher
)
{
auto
it
=
lower_bound
(
lb
);
if
(
it
!=
end
())
{
it
.
m_impl
->
setPrefetcher
(
prefetcher
.
m_impl
);
prefetcher
.
m_impl
->
prefetchFrom
(
ItemType
::
EVENT
,
ItemType
::
SUBRUN
,
it
.
m_impl
->
m_current_event
.
m_impl
);
}
return
it
;
}
SubRun
::
const_iterator
SubRun
::
lower_bound
(
const
EventNumber
&
lb
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
lower_bound
(
lb
);
}
SubRun
::
const_iterator
SubRun
::
lower_bound
(
const
EventNumber
&
lb
,
const
Prefetcher
&
prefetcher
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
lower_bound
(
lb
,
prefetcher
);
}
SubRun
::
iterator
SubRun
::
upper_bound
(
const
EventNumber
&
ub
)
{
if
(
!
valid
())
{
throw
Exception
(
"Calling SubRun member function on invalid SubRun object"
);
...
...
@@ -264,11 +357,23 @@ SubRun::iterator SubRun::upper_bound(const EventNumber& ub) {
else
return
iterator
(
event
);
}
SubRun
::
const_iterator
SubRun
::
upper_bound
(
const
EventNumber
&
ub
)
const
{
iterator
it
=
const_cast
<
SubRun
*>
(
this
)
->
upper_bound
(
ub
);
SubRun
::
iterator
SubRun
::
upper_bound
(
const
EventNumber
&
lb
,
const
Prefetcher
&
prefetcher
)
{
auto
it
=
upper_bound
(
lb
);
if
(
it
!=
end
())
{
it
.
m_impl
->
setPrefetcher
(
prefetcher
.
m_impl
);
prefetcher
.
m_impl
->
prefetchFrom
(
ItemType
::
EVENT
,
ItemType
::
SUBRUN
,
it
.
m_impl
->
m_current_event
.
m_impl
);
}
return
it
;
}
SubRun
::
const_iterator
SubRun
::
upper_bound
(
const
EventNumber
&
ub
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
upper_bound
(
ub
);
}
SubRun
::
const_iterator
SubRun
::
upper_bound
(
const
EventNumber
&
ub
,
const
Prefetcher
&
prefetcher
)
const
{
return
const_cast
<
SubRun
*>
(
this
)
->
upper_bound
(
ub
,
prefetcher
);
}
void
SubRun
::
toDescriptor
(
SubRunDescriptor
&
descriptor
)
{
std
::
memset
(
descriptor
.
data
,
0
,
sizeof
(
descriptor
.
data
));
if
(
!
valid
())
return
;
...
...
@@ -284,35 +389,6 @@ SubRun SubRun::fromDescriptor(const DataStore& datastore, const SubRunDescriptor
else
return
SubRun
();
}
////////////////////////////////////////////////////////////////////////////////////////////
// SubRun::const_iterator::Impl implementation
////////////////////////////////////////////////////////////////////////////////////////////
class
SubRun
::
const_iterator
::
Impl
{
public:
Event
m_current_event
;
Impl
()
:
m_current_event
()
{}
Impl
(
const
Event
&
event
)
:
m_current_event
(
event
)
{}
Impl
(
Event
&&
event
)
:
m_current_event
(
std
::
move
(
event
))
{}
Impl
(
const
Impl
&
other
)
:
m_current_event
(
other
.
m_current_event
)
{}
bool
operator
==
(
const
Impl
&
other
)
const
{
return
m_current_event
==
other
.
m_current_event
;
}
};
////////////////////////////////////////////////////////////////////////////////////////////
// SubRun::const_iterator implementation
////////////////////////////////////////////////////////////////////////////////////////////
...
...
test/SubRunTest.cpp
View file @
a99a7121
...
...
@@ -198,5 +198,49 @@ void SubRunTest::testAsync() {
}
void
SubRunTest
::
testPrefetcher
()
{
// TODO
auto
root
=
datastore
->
root
();
DataSet
mds
=
root
.
createDataSet
(
"matthieu_prefetch"
);
CPPUNIT_ASSERT
(
mds
.
valid
());
Run
r
=
mds
.
createRun
(
42
);
CPPUNIT_ASSERT
(
r
.
valid
());
SubRun
sr
=
r
.
createSubRun
(
3
);
CPPUNIT_ASSERT
(
sr
.
valid
());
for
(
unsigned
i
=
0
;
i
<
20
;
i
++
)
{
Event
e
=
sr
.
createEvent
(
i
);
CPPUNIT_ASSERT
(
e
.
valid
());
}
// test begin/end
{
Prefetcher
prefetcher
(
*
datastore
);
unsigned
i
=
0
;
for
(
auto
it
=
sr
.
begin
(
prefetcher
);
it
!=
sr
.
end
();
it
++
)
{
CPPUNIT_ASSERT
(
it
->
valid
());
CPPUNIT_ASSERT
(
it
->
number
()
==
i
);
i
+=
1
;
}
}
// test lower_bound
{
Prefetcher
prefetcher
(
*
datastore
);
unsigned
i
=
5
;
auto
it
=
sr
.
lower_bound
(
5
);
for
(;
it
!=
sr
.
end
();
it
++
)
{
CPPUNIT_ASSERT
(
it
->
valid
());
CPPUNIT_ASSERT
(
it
->
number
()
==
i
);
i
+=
1
;
}
}
// test upper_bound
{
Prefetcher
prefetcher
(
*
datastore
);
unsigned
i
=
6
;
auto
it
=
sr
.
upper_bound
(
5
);
for
(;
it
!=
sr
.
end
();
it
++
)
{
CPPUNIT_ASSERT
(
it
->
valid
());
CPPUNIT_ASSERT
(
it
->
number
()
==
i
);
i
+=
1
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment