summaryrefslogtreecommitdiff
path: root/benchmarks/CUDA/MUM/mummergpu.h
blob: 875d3b729bdd8dd269224bce55bb6b38ea94de4c (plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <stdlib.h>
#include "common.cu"

extern "C" {
struct QuerySet
{
	  int qfile;

	  char * h_tex_array;
	  char* d_tex_array;	
	  int* d_addrs_tex_array; 
	  int* h_addrs_tex_array;
	  int* h_lengths_array;
	  int* d_lengths_array;
	  char** h_names;

	  unsigned int count; 
	  size_t texlen;

	  // total device memory occupied by this query set
	  size_t bytes_on_board;
};


struct AuxiliaryNodeData
{
	  int length;
	  int depth;
	  int leafid;
      char leafchar;
      TextureAddress parent;
};


struct Reference
{
	  /* Reference string */
	  char* str;
	  size_t len;

	  unsigned int pitch;
  	  void* d_ref_tex_array;  //cudaArray*
 	  char* h_ref_tex_array;
 
	  /* Suffix tree for reference */
	  void* d_node_tex_array;  //really a cudaArray*
	  void* h_node_tex_array;  //really a PixelOfNode*	  
	  
	  void* d_children_tex_array; //cudaArray*
	  void* h_children_tex_array; //PixelOfChildren*	  

	  unsigned int tex_height;
	  unsigned int tex_width;

	  // total device memory occupied by this query set
	  size_t bytes_on_board;

	  AuxiliaryNodeData* aux_data;
	  int num_nodes;

};


// Matches are reported as a node in the suffix tree,
// plus a distance up the node's parent link for partial 
// matches on the patch from the root to the node

struct MatchCoord
{
	  unsigned int node; // match node
	  short edge_match_length;  // number of missing characters UP the parent edge
};

struct MatchResults
{	  
	  // Each MatchCoord in the buffers below corresponds to the first character
	  // of some substring of one of the queries
	  MatchCoord* d_match_coords;
	  MatchCoord* h_match_coords;

	  size_t numCoords;

	  // total device memory occupied by this query set
	  size_t bytes_on_board;
};

typedef unsigned int MUMMERGPU_OPTIONS;

enum MUMMerGPUOption {
   DEFAULT,
   ON_CPU = (1<<0)
};

//All times in milliseconds
struct Statistics
{
	  float t_kernel;
	  float t_output;
      float t_to_board;
      float t_from_board;
	  float t_moving_tree_pages;
	  float t_query_read;
	  float t_total;
	  float t_construction;

	  float bp_avg_query_length;
};

struct MatchContext
{
	  char* full_ref;
	  size_t full_ref_len;

	  Reference* ref;
	  QuerySet* queries;
	  MatchResults results;

	  bool on_cpu;

	  int min_match_length;

      bool reverse;
      bool forwardreverse;
      bool forwardcoordinates;
      bool show_query_length;
      bool maxmatch;

	  char* stats_file;

	  Statistics statistics;
};


struct ReferencePage
{
	  int begin;
	  int end;
	  int shadow_left;
	  int shadow_right;
	  MatchResults results;
	  unsigned int id;
	  Reference ref;
};


int createReference(const char* fromFile, Reference* ref);
int destroyReference(Reference* ref);

int createQuerySet(const char* fromFile, QuerySet* queries);
int destroyQuerySet(QuerySet* queries);

int createMatchContext(Reference* ref,
					   QuerySet* queries,
					   MatchResults* matches,
					   MUMMERGPU_OPTIONS options,
					   int min_match_length,
					   char* stats_file,
                       bool reverse,
                       bool forwardreverse,
                       bool forwardcoordinates,
                       bool showQueryLength,
					   MatchContext* ctx);

int destroyMatchContext(MatchContext* ctx);


int matchQueries(MatchContext* ctx);
				 
void printStringForError(int err);
}