SW#
All Files Functions Variables Typedefs Macros
cuda_utils.h
Go to the documentation of this file.
1 /*
2 swsharp - CUDA parallelized Smith Waterman with applying Hirschberg's and
3 Ukkonen's algorithm and dynamic cell pruning.
4 Copyright (C) 2013 Matija Korpar, contributor Mile Šikić
5 
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 Contact the author by mkorpar@gmail.com.
20 */
27 #ifndef __SW_SHARP_CUDA_UTILSH__
28 #define __SW_SHARP_CUDA_UTILSH__
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define CUDA_SAFE_CALL(call) \
35  do { \
36  cudaError err = call; \
37  if (cudaSuccess != err) { \
38  fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \
39  __FILE__, __LINE__, cudaGetErrorString(err)); \
40  exit(EXIT_FAILURE); \
41  } \
42  } while(0)
43 
44 #define TO_GPU cudaMemcpyHostToDevice
45 #define FROM_GPU cudaMemcpyDeviceToHost
46 
47 #define MAX3(x, y, w) max(x, max(y, w))
48 #define MAX4(x, y, w, z) max(max(x, y), max(w, z))
49 
50 #define VEC2_ASSIGN(X, Y) \
51  do { \
52  (X).x = (Y).x; \
53  (X).y = (Y).y; \
54  } while(0)
55 
56 #define VEC3_ASSIGN(X, Y) \
57  do { \
58  (X).x = (Y).x; \
59  (X).y = (Y).y; \
60  (X).z = (Y).z; \
61  } while(0)
62 
63 #define VEC4_ASSIGN(X, Y) \
64  do { \
65  (X).x = (Y).x; \
66  (X).y = (Y).y; \
67  (X).z = (Y).z; \
68  (X).w = (Y).w; \
69  } while(0)
70 
77 extern void cudaGetCards(int** cards, int* cardsLen);
78 
87 extern int cudaCheckCards(int* cards, int cardsLen);
88 
89 extern void cudaCardBuckets(int*** cardBuckets, int** cardBucketsLens,
90  int* cards, int cardsLen, int buckets);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 #endif // __SW_SHARP_CUDA_UTILSH__
int cudaCheckCards(int *cards, int cardsLen)
Checks CUDA card index list.
void cudaGetCards(int **cards, int *cardsLen)
Gets CUDA card index list.