// Returns True if sequences pass all sanity checks. bool check_sequences(Sequences *seqs) { return check_sequences( seqs->get_num_seqs(), seqs->length(), seqs->get_seqs()) && check_seq_names(seqs); }
unsigned int gapmis_one_to_many_opt_gpu ( const char * p1, const char ** t, const struct gapmis_params * in, struct gapmis_align * out ) { const char * p[] = { p1, NULL}; if ( in -> scoring_matrix > 1 ) { errno = MATRIX; return ( 0 ); } unsigned int pats = get_number_of_sequences (p); unsigned int txts = get_number_of_sequences (t); unsigned int maxPatLen = get_max_length (pats, p); unsigned int minTxtLen = get_min_length (txts, t); if (check_sequences(pats,p,in->scoring_matrix)==0) { errno = BADCHAR; return ( 0 ); } if (check_sequences(txts,t,in->scoring_matrix)==0) { errno = BADCHAR; return ( 0 ); } if(maxPatLen > minTxtLen) { errno = LENGTH; return ( 0 ); } if ( in -> max_gap >= minTxtLen ) { errno = MAXGAP; return ( 0 ); } int err = -1; /* get the GPU id */ cl_platform_id gpu_id = get_gpu_id(&err); if(err) { errno = NOGPU; return ( 0 ); } /* get the device id */ cl_device_id dev_id = get_dev_id(gpu_id, &err); if(err) { errno = NOGPU; return ( 0 ); } /* create the context using dev_id */ cl_context context = create_context(dev_id, &err); if(err) { errno = GPUERROR; return ( 0 ); } /* create a list with the commands to be executed by GPU */ cl_command_queue cmd_queue = create_cmd_queue (dev_id, context, &err); if(err) { errno = GPUERROR; return ( 0 ); } /* create a kernel */ cl_kernel kernel; /* load the kernel ``kernel_dna.cl'' with name ``gapmis_kernel''*/ if(in->scoring_matrix==0) kernel = load_kernel ("kernel_dna.cl", "gapmis_kernel", dev_id, context, &err); else kernel = load_kernel ("kernel_pro.cl", "gapmis_kernel", dev_id, context, &err); if(err) { errno = KERNEL; return ( 0 ); } const unsigned int patGroupSize = 1; const unsigned int txtGroupSize = 768; unsigned int i, j; unsigned int patGroups = get_number_of_groups (pats, patGroupSize); unsigned int txtGroups = get_number_of_groups (txts, txtGroupSize); const char * groupPatterns[patGroupSize+1]; set_null (groupPatterns, patGroupSize+1); const char * groupTexts[txtGroupSize+1]; set_null (groupTexts, txtGroupSize+1); float * groupScores; groupScores = calloc (patGroupSize*txtGroupSize, sizeof(float) ); int groupMatch [patGroupSize]; float groupMatchScores [patGroupSize]; set_invalid(groupMatch,patGroupSize); set_minimum(groupMatchScores,patGroupSize); for(i=0;i<patGroups;i++) { set_null (groupPatterns, patGroupSize+1); initialize_pointers (groupPatterns,i,patGroupSize,p,pats); set_invalid(groupMatch,patGroupSize); set_minimum(groupMatchScores,patGroupSize); for(j=0;j<txtGroups;j++) { set_null (groupTexts, txtGroupSize+1); initialize_pointers (groupTexts,j,txtGroupSize,t,txts); if( ! ( kernel_launch (kernel, context, cmd_queue, groupPatterns, groupTexts, in, groupScores) )) return ( 0 ); update_group_match (groupScores,groupMatch,groupMatchScores,patGroupSize,txtGroupSize, pats, txts, i, j); } for(j=0;j<patGroupSize;j++) { if(i*patGroupSize+j<pats) { groupPatterns[0] = p[i*patGroupSize+j]; groupPatterns[1] = NULL; groupTexts[0] = t[groupMatch[j]]; groupTexts[1] = NULL; if( !( kernel_launch_l (kernel, context, cmd_queue, groupPatterns, groupTexts, in, groupScores,&out[i*patGroupSize+j] ) ) ) return ( 0 ); } } } free ( groupScores ); clReleaseContext ( context ); clReleaseCommandQueue ( cmd_queue ); clReleaseKernel(kernel); return ( 1 ); }