File: Library.h

package info (click to toggle)
ray 2.3.1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,960 kB
  • sloc: cpp: 49,973; sh: 339; makefile: 278; python: 168
file content (154 lines) | stat: -rw-r--r-- 4,731 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 	Ray
    Copyright (C) 2010, 2011, 2012 Sébastien Boisvert

	http://DeNovoAssembler.SourceForge.Net/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 3 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You have received a copy of the GNU General Public License
    along with this program (gpl-3.0.txt).  
	see <http://www.gnu.org/licenses/>

*/

#ifndef _Library
#define _Library

#include "LibraryWorker.h"

#include <code/SeedExtender/ExtensionData.h>
#include <code/SeedExtender/ReadFetcher.h>
#include <code/Mock/common_functions.h>
#include <code/Mock/Parameters.h>
#include <code/SeedingData/SeedingData.h>

#include <RayPlatform/structures/StaticVector.h>
#include <RayPlatform/profiling/TimePrinter.h>
#include <RayPlatform/communication/VirtualCommunicator.h>
#include <RayPlatform/communication/BufferedData.h>
#include <RayPlatform/memory/RingAllocator.h>
#include <RayPlatform/handlers/SlaveModeHandler.h>
#include <RayPlatform/handlers/MasterModeHandler.h>
#include <RayPlatform/core/ComputeCore.h>

#include <map>
using namespace std;

__DeclarePlugin(Library);

__DeclareMasterModeAdapter(Library,RAY_MASTER_MODE_UPDATE_DISTANCES);
__DeclareSlaveModeAdapter(Library,RAY_SLAVE_MODE_AUTOMATIC_DISTANCE_DETECTION);
__DeclareSlaveModeAdapter(Library,RAY_SLAVE_MODE_SEND_LIBRARY_DISTANCES);

/*
 * This class computes the average outer distances 
 * for paired reads and mate-pairs.
 * To do so, it spawns a pool of workers.
 * These workers will push messages and these
 * messages are grouped by the virtual communicator.
 * \author Sébastien Boisvert
 */
class Library :  public CorePlugin{

	__AddAdapter(Library,RAY_MASTER_MODE_UPDATE_DISTANCES);
	__AddAdapter(Library,RAY_SLAVE_MODE_AUTOMATIC_DISTANCE_DETECTION);
	__AddAdapter(Library,RAY_SLAVE_MODE_SEND_LIBRARY_DISTANCES);

	MessageTag RAY_MPI_TAG_ASK_LIBRARY_DISTANCES_FINISHED;
	MessageTag RAY_MPI_TAG_AUTOMATIC_DISTANCE_DETECTION_IS_DONE;
	MessageTag RAY_MPI_TAG_LIBRARY_DISTANCE;
	MessageTag RAY_MPI_TAG_UPDATE_LIBRARY_INFORMATION;
	MessageTag RAY_MPI_TAG_UPDATE_LIBRARY_INFORMATION_REPLY;
	MessageTag RAY_MPI_TAG_GET_READ_MATE;
	MessageTag RAY_MPI_TAG_REQUEST_VERTEX_READS;
	MessageTag RAY_MPI_TAG_REQUEST_VERTEX_READS_REPLY;

	MasterMode RAY_MASTER_MODE_TRIGGER_EXTENSIONS;
	MasterMode RAY_MASTER_MODE_UPDATE_DISTANCES;
	MasterMode RAY_MASTER_MODE_TRIGGER_FUSIONS;

	SlaveMode RAY_SLAVE_MODE_DO_NOTHING;
	SlaveMode RAY_SLAVE_MODE_AUTOMATIC_DISTANCE_DETECTION;
	SlaveMode RAY_SLAVE_MODE_SEND_LIBRARY_DISTANCES;
	

	int m_currentLibrary;
	int m_ranksThatReplied;
	int m_informationSent;

	int m_detectedDistances;
	vector<int> m_libraryIndexes;
	VirtualCommunicator*m_virtualCommunicator;
	BufferedData m_bufferedData;
	int m_ready;
	int m_rank;
	StaticVector*m_outbox;
	StaticVector*m_inbox;
	ExtensionData*m_ed;
	RingAllocator*m_outboxAllocator;
	int m_size;
	TimePrinter*m_timePrinter;
	int*m_mode;
	int*m_master_mode;
	Parameters*m_parameters;
	SeedingData*m_seedingData;
	int m_libraryIterator;
	map<int,map<int,int> > m_libraryDistances;
	map<int,int>::iterator m_libraryIndex;
	bool m_libraryIndexInitiated;
	bool m_workerInitiated;
	bool m_initiatedIterator;
	LargeIndex m_SEEDING_i;
	set<WorkerHandle> m_activeWorkers;
	set<WorkerHandle>::iterator m_activeWorkerIterator;
	int m_completedJobs;
	int m_maximumAliveWorkers;
	int m_maximumWorkers;

	map<WorkerHandle,LibraryWorker> m_aliveWorkers;
	bool m_communicatorWasTriggered;
	vector<WorkerHandle> m_workersDone;
	vector<WorkerHandle> m_waitingWorkers;
	vector<WorkerHandle> m_activeWorkersToRestore;

	MyAllocator m_allocator;
	void updateStates();

	void completeSlaveMode();

	void readLibraryCheckpoint();
	bool hasLibraryCheckpoint();
	void writeLibraryCheckpoint();
	bool mustWriteLibraryCheckpoint();

public:
	Library();
	void allocateBuffers();
	void call_RAY_MASTER_MODE_UPDATE_DISTANCES();
	void setReadiness();
	int getRank();
	int getSize();
	void call_RAY_SLAVE_MODE_AUTOMATIC_DISTANCE_DETECTION();

	void call_RAY_SLAVE_MODE_SEND_LIBRARY_DISTANCES();

	void constructor(int m_rank,StaticVector*m_outbox,RingAllocator*m_outboxAllocator,
	ExtensionData*m_ed,int m_size,
TimePrinter*m_timePrinter,int*m_mode,int*m_master_mode,
Parameters*m_parameters,SeedingData*m_seedingData,StaticVector*inbox,VirtualCommunicator*vc
);

	void registerPlugin(ComputeCore*core);
	void resolveSymbols(ComputeCore*core);
};

#endif