39
39
#include < string>
40
40
41
41
42
+ #include " deepvariant/fast_pipeline_utils.h"
42
43
#include " absl/flags/flag.h"
43
44
#include " absl/flags/parse.h"
44
45
#include " absl/log/log.h"
54
55
#include " boost/process.hpp" // NOLINT
55
56
#include " boost/process/search_path.hpp" // NOLINT
56
57
57
- namespace bp = boost::process;
58
- namespace bi = boost::interprocess;
59
-
60
58
ABSL_FLAG (std::string, make_example_flags, " " ,
61
59
" file containing make_examples flags" );
62
60
ABSL_FLAG (std::string, call_variants_flags, " " ,
@@ -66,6 +64,13 @@ ABSL_FLAG(int, num_shards, 0, "number of make_examples shards");
66
64
ABSL_FLAG (int , buffer_size, 10485760 ,
67
65
" Shared memory buffer size for each shard, default is 10MB" );
68
66
67
+ namespace learning {
68
+ namespace genomics {
69
+ namespace deepvariant {
70
+
71
+ namespace bp = boost::process;
72
+ namespace bi = boost::interprocess;
73
+
69
74
FastPipeline::FastPipeline (int num_shards, int buffer_size,
70
75
absl::string_view shm_prefix,
71
76
absl::string_view path_to_make_examples_flags,
@@ -106,7 +111,7 @@ FastPipeline::FastPipeline(int num_shards, int buffer_size,
106
111
void FastPipeline::SetGlobalObjects () {
107
112
for (int shard = 0 ; shard < num_shards_; ++shard) {
108
113
// Create shared memory buffers.
109
- std::string shard_shm_name = absl::StrCat (shm_prefix_, " _shm_ " , shard);
114
+ std::string shard_shm_name = GetShmBufferName (shm_prefix_, shard);
110
115
shm_[shard] =
111
116
std::make_unique<bi::shared_memory_object>(bi::shared_memory_object (
112
117
bi::open_or_create, shard_shm_name.data (), bi::read_write));
@@ -115,17 +120,17 @@ void FastPipeline::SetGlobalObjects() {
115
120
LOG (INFO) << " Creating buffer_empty mutex" ;
116
121
buffer_empty_[shard] = std::make_unique<bi::named_mutex>(
117
122
bi::open_or_create,
118
- absl::StrCat (shm_prefix_, " _buffer_empty_ " , shard).data ());
123
+ GetBufferEmptyMutexName (shm_prefix_, shard).data ());
119
124
// Create mutex signalling that items are available in the buffer.
120
125
LOG (INFO) << " Creating items_available mutex" ;
121
126
items_available_[shard] = std::make_unique<bi::named_mutex>(
122
127
bi::open_or_create,
123
- absl::StrCat (shm_prefix_, " _items_available_ " , shard).data ());
128
+ GetItemsAvailableMutexName (shm_prefix_, shard).data ());
124
129
// Create mutex signalling that shard is finished.
125
130
LOG (INFO) << " Creating shard_finished mutex" ;
126
131
make_examples_shard_finished_[shard] = std::make_unique<bi::named_mutex>(
127
132
bi::open_or_create,
128
- absl::StrCat (shm_prefix_, " _shard_finished_ " , shard).data ());
133
+ GetShardFinishedMutexName (shm_prefix_, shard).data ());
129
134
}
130
135
}
131
136
@@ -135,13 +140,13 @@ void FastPipeline::ClearGlobalObjects() {
135
140
buffer_empty_[shard].release ();
136
141
items_available_[shard].release ();
137
142
make_examples_shard_finished_[shard].release ();
138
- shm_[shard]->remove (absl::StrCat (shm_prefix_, " _shm_ " , shard).data ());
143
+ shm_[shard]->remove (GetShmBufferName (shm_prefix_, shard).data ());
139
144
buffer_empty_[shard]->remove (
140
- absl::StrCat (shm_prefix_, " _buffer_empty_ " , shard).data ());
145
+ GetBufferEmptyMutexName (shm_prefix_, shard).data ());
141
146
items_available_[shard]->remove (
142
- absl::StrCat (shm_prefix_, " _items_available_ " , shard).data ());
147
+ GetItemsAvailableMutexName (shm_prefix_, shard).data ());
143
148
make_examples_shard_finished_[shard]->remove (
144
- absl::StrCat (shm_prefix_, " _shard_finished_ " , shard).data ());
149
+ GetShardFinishedMutexName (shm_prefix_, shard).data ());
145
150
}
146
151
}
147
152
@@ -206,6 +211,10 @@ void RunFastPipeline(absl::string_view dv_bin_path) {
206
211
fast_pipeline.ClearGlobalObjects ();
207
212
}
208
213
214
+ } // namespace deepvariant
215
+ } // namespace genomics
216
+ } // namespace learning
217
+
209
218
int main (int argc, char ** argv) {
210
219
211
220
absl::ParseCommandLine (argc, argv);
@@ -224,5 +233,6 @@ int main(int argc, char** argv) {
224
233
// 5. call_variants_flags file exists
225
234
// 6. No SHM files with the same prefix exist.
226
235
227
- RunFastPipeline (dv_bin_path);
236
+ learning::genomics::deepvariant::RunFastPipeline (dv_bin_path);
237
+ return EXIT_SUCCESS;
228
238
}
0 commit comments