Skip to content

Commit 81171a5

Browse files
committed
Error if GPU modules are used with non-gpu dbs
1 parent 6750af3 commit 81171a5

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/commons/Parameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Parameters {
9090
static const unsigned int DBTYPE_EXTENDED_COMPRESSED = 1;
9191
static const unsigned int DBTYPE_EXTENDED_INDEX_NEED_SRC = 2;
9292
static const unsigned int DBTYPE_EXTENDED_CONTEXT_PSEUDO_COUNTS = 4;
93+
static const unsigned int DBTYPE_EXTENDED_GPU = 8;
9394

9495
// don't forget to add new database types to DBReader::getDbTypeName and Parameters::PARAM_OUTPUT_DBTYPE
9596

src/prefiltering/ungappedprefilter.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,15 @@ int prefilterInternal(int argc, const char **argv, const Command &command, int m
391391
IndexReader * qDbrIdx = NULL;
392392
DBReader<unsigned int> * qdbr = NULL;
393393
DBReader<unsigned int> * tdbr = tDbrIdx.sequenceReader;
394+
395+
if (par.gpu == true) {
396+
const bool isGpuDb = DBReader<unsigned int>::getExtendedDbtype(tdbr->getDbtype()) & Parameters::DBTYPE_EXTENDED_GPU;
397+
if (isGpuDb == false) {
398+
Debug(Debug::ERROR) << "Database " << FileUtil::baseName(par.db2) << " is not a valid GPU database\n";
399+
EXIT(EXIT_FAILURE);
400+
}
401+
}
402+
394403
const int targetSeqType = tdbr->getDbtype();
395404
int querySeqType;
396405
if (sameDB == true) {

src/util/gpuserver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ int gpuserver(int argc, const char **argv, const Command& command) {
2929
IndexReader dbrIdx(par.db1, par.threads, IndexReader::SEQUENCES, (touch) ? (IndexReader::PRELOAD_INDEX | IndexReader::PRELOAD_DATA) : 0 );
3030
DBReader<unsigned int>* dbr = dbrIdx.sequenceReader;
3131

32+
const bool isGpuDb = DBReader<unsigned int>::getExtendedDbtype(dbr->getDbtype()) & Parameters::DBTYPE_EXTENDED_GPU;
33+
if (isGpuDb == false) {
34+
Debug(Debug::ERROR) << "Database " << FileUtil::baseName(par.db1) << " is not a valid GPU database\n";
35+
EXIT(EXIT_FAILURE);
36+
}
37+
3238
std::vector<size_t> offsets;
3339
offsets.reserve(dbr->getSize() + 1);
3440

src/util/makepaddedseqdb.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ int makepaddedseqdb(int argc, const char **argv, const Command &command) {
2323

2424
SubstitutionMatrix subMat(par.scoringMatrixFile.values.aminoacid().c_str(), 2.0, par.scoreBias);
2525

26-
DBWriter dbsw(par.db2.c_str(), par.db2Index.c_str(), par.threads, false, dbr.getDbtype());
26+
int dbType = DBReader<unsigned int>::setExtendedDbtype(dbr.getDbtype(), Parameters::DBTYPE_EXTENDED_GPU);
27+
DBWriter dbsw(par.db2.c_str(), par.db2Index.c_str(), par.threads, false, dbType);
2728
dbsw.open();
28-
DBWriter dbhw(par.hdr2.c_str(), par.hdr2Index.c_str(), par.threads, false, dbr.getDbtype());
29+
DBWriter dbhw(par.hdr2.c_str(), par.hdr2Index.c_str(), par.threads, false, Parameters::DBTYPE_GENERIC_DB);
2930
dbhw.open();
3031

3132
// need to prune low scoring k-mers through masking

0 commit comments

Comments
 (0)