21 #ifndef KALDI_CUDAMATRIX_COMMON_H_ 22 #define KALDI_CUDAMATRIX_COMMON_H_ 39 NvtxTracer::NvtxTracer(
const char* name) {
40 const uint32_t colors[] = { 0xff00ff00, 0xff0000ff, 0xffffff00, 0xffff00ff, 0xff00ffff, 0xffff0000, 0xffffffff };
41 const int num_colors =
sizeof(colors)/
sizeof(uint32_t);
42 int color_id = ((int)name[0])%num_colors;
43 nvtxEventAttributes_t eventAttrib = {0};
44 eventAttrib.version = NVTX_VERSION;
45 eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
46 eventAttrib.colorType = NVTX_COLOR_ARGB;
47 eventAttrib.color = colors[color_id];
48 eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
49 eventAttrib.message.ascii = name;
50 nvtxRangePushEx(&eventAttrib);
53 NvtxTracer::~NvtxTracer() {
59 cublasOperation_t cublas_trans;
62 cublas_trans = CUBLAS_OP_N;
63 else if (kaldi_trans ==
kTrans)
64 cublas_trans = CUBLAS_OP_T;
66 cublas_trans = CUBLAS_OP_C;
70 void GetBlockSizesForSimpleMatrixOperation(
int32 num_rows,
75 int32 col_blocksize = 64, row_blocksize = 4;
76 while (col_blocksize > 1 &&
77 (num_cols + (num_cols / 2) <= col_blocksize ||
78 num_rows > 65535 * row_blocksize)) {
83 dimBlock->x = col_blocksize;
84 dimBlock->y = row_blocksize;
86 dimGrid->x = n_blocks(num_cols, col_blocksize);
87 dimGrid->y = n_blocks(num_rows, row_blocksize);
89 "Matrix has too many rows to process");
93 const char* cublasGetStatusString(cublasStatus_t status) {
95 case CUBLAS_STATUS_SUCCESS:
return "CUBLAS_STATUS_SUCCESS";
96 case CUBLAS_STATUS_NOT_INITIALIZED:
return "CUBLAS_STATUS_NOT_INITIALIZED";
97 case CUBLAS_STATUS_ALLOC_FAILED:
return "CUBLAS_STATUS_ALLOC_FAILED";
98 case CUBLAS_STATUS_INVALID_VALUE:
return "CUBLAS_STATUS_INVALID_VALUE";
99 case CUBLAS_STATUS_ARCH_MISMATCH:
return "CUBLAS_STATUS_ARCH_MISMATCH";
100 case CUBLAS_STATUS_MAPPING_ERROR:
return "CUBLAS_STATUS_MAPPING_ERROR";
101 case CUBLAS_STATUS_EXECUTION_FAILED:
return "CUBLAS_STATUS_EXECUTION_FAILED";
102 case CUBLAS_STATUS_INTERNAL_ERROR:
return "CUBLAS_STATUS_INTERNAL_ERROR";
103 case CUBLAS_STATUS_NOT_SUPPORTED:
return "CUBLAS_STATUS_NOT_SUPPORTED";
104 case CUBLAS_STATUS_LICENSE_ERROR:
return "CUBLAS_STATUS_LICENSE_ERROR";
106 return "CUBLAS_STATUS_UNKNOWN_ERROR";
109 const char* cusparseGetStatusString(cusparseStatus_t status) {
112 case CUSPARSE_STATUS_SUCCESS:
return "CUSPARSE_STATUS_SUCCESS";
113 case CUSPARSE_STATUS_NOT_INITIALIZED:
return "CUSPARSE_STATUS_NOT_INITIALIZED";
114 case CUSPARSE_STATUS_ALLOC_FAILED:
return "CUSPARSE_STATUS_ALLOC_FAILED";
115 case CUSPARSE_STATUS_INVALID_VALUE:
return "CUSPARSE_STATUS_INVALID_VALUE";
116 case CUSPARSE_STATUS_ARCH_MISMATCH:
return "CUSPARSE_STATUS_ARCH_MISMATCH";
117 case CUSPARSE_STATUS_MAPPING_ERROR:
return "CUSPARSE_STATUS_MAPPING_ERROR";
118 case CUSPARSE_STATUS_EXECUTION_FAILED:
return "CUSPARSE_STATUS_EXECUTION_FAILED";
119 case CUSPARSE_STATUS_INTERNAL_ERROR:
return "CUSPARSE_STATUS_INTERNAL_ERROR";
120 case CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED:
return "CUSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED";
121 case CUSPARSE_STATUS_ZERO_PIVOT:
return "CUSPARSE_STATUS_ZERO_PIVOT";
123 return "CUSPARSE_STATUS_UNKNOWN_ERROR";
126 const char* curandGetStatusString(curandStatus_t status) {
129 case CURAND_STATUS_SUCCESS:
return "CURAND_STATUS_SUCCESS";
130 case CURAND_STATUS_VERSION_MISMATCH:
return "CURAND_STATUS_VERSION_MISMATCH";
131 case CURAND_STATUS_NOT_INITIALIZED:
return "CURAND_STATUS_NOT_INITIALIZED";
132 case CURAND_STATUS_ALLOCATION_FAILED:
return "CURAND_STATUS_ALLOCATION_FAILED";
133 case CURAND_STATUS_TYPE_ERROR:
return "CURAND_STATUS_TYPE_ERROR";
134 case CURAND_STATUS_OUT_OF_RANGE:
return "CURAND_STATUS_OUT_OF_RANGE";
135 case CURAND_STATUS_LENGTH_NOT_MULTIPLE:
return "CURAND_STATUS_LENGTH_NOT_MULTIPLE";
136 case CURAND_STATUS_DOUBLE_PRECISION_REQUIRED:
return "CURAND_STATUS_DOUBLE_PRECISION_REQUIRED";
137 case CURAND_STATUS_LAUNCH_FAILURE:
return "CURAND_STATUS_LAUNCH_FAILURE";
138 case CURAND_STATUS_PREEXISTING_FAILURE:
return "CURAND_STATUS_PREEXISTING_FAILURE";
139 case CURAND_STATUS_INITIALIZATION_FAILED:
return "CURAND_STATUS_INITIALIZATION_FAILED";
140 case CURAND_STATUS_ARCH_MISMATCH:
return "CURAND_STATUS_ARCH_MISMATCH";
141 case CURAND_STATUS_INTERNAL_ERROR:
return "CURAND_STATUS_INTERNAL_ERROR";
143 return "CURAND_STATUS_UNKNOWN_ERROR";
150 #endif // KALDI_CUDAMATRIX_COMMON_H_ This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
#define KALDI_ASSERT(cond)