Skip to content

Commit

Permalink
Merge pull request #18 from mhaseeb123/fix-hicops-sigabort
Browse files Browse the repository at this point in the history
Fixes sigabort due to stack overflow in hicops when running with many threads
  • Loading branch information
Prof-S authored Sep 10, 2024
2 parents 03778e1 + bc67eed commit 8681cae
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 88 deletions.
8 changes: 0 additions & 8 deletions source/apps/gicops/gicops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,6 @@ status_t main(int_t argc, char_t* argv[])
status = DSLIM_DeallocateSC();
}

/* De-initialize the ion index */
if (status == SLM_SUCCESS)
{
/* De-initialize the ion index */
for (uint_t peplen = minlen; peplen <= maxlen; peplen++)
status = DSLIM_DeallocateIonIndex(slm_index + peplen - minlen);
}

#if defined (USE_TIMEMORY)
// stop instrumentation
search_inst.stop();
Expand Down
16 changes: 4 additions & 12 deletions source/apps/hicops/hicops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ status_t main(int_t argc, char_t* argv[])
auto env_tool = tim::get_env<std::string>("HICOPS_INST_COMPONENTS", "");
auto env_enum = tim::enumerate_components(tim::delimit(env_tool));
env_enum.erase(std::remove_if(env_enum.begin(), env_enum.end(),
[](int c) { return c == WALL_CLOCK ||
[](int c) { return c == WALL_CLOCK ||
c == CPU_UTIL; }),
env_enum.end());

Expand Down Expand Up @@ -86,8 +86,8 @@ status_t main(int_t argc, char_t* argv[])
// init MPI
int provided = -1;
status = MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
// Check if desired MPI level available

// Check if desired MPI level available
if (provided != MPI_THREAD_MULTIPLE)
{
std::cout << "************************ Warning: **************************\n";
Expand Down Expand Up @@ -333,7 +333,7 @@ status_t main(int_t argc, char_t* argv[])
mem_tuple_t search_mem_inst("search");
#endif // USE_TIMEMORY

// Perform the distributed database search
// Perform the distributed database search
if (status == SLM_SUCCESS)
{
MARK_START(dslim_search);
Expand All @@ -355,14 +355,6 @@ status_t main(int_t argc, char_t* argv[])
status = DSLIM_DeallocateSC();
}

/* De-initialize the ion index */
if (status == SLM_SUCCESS)
{
/* De-initialize the ion index */
for (uint_t peplen = minlen; peplen <= maxlen; peplen++)
status = DSLIM_DeallocateIonIndex(slm_index + peplen - minlen);
}

#if defined (USE_TIMEMORY)
// stop instrumentation
search_inst.stop();
Expand Down
8 changes: 4 additions & 4 deletions source/core/cuda/superstep4/kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern gParams params;

// -------------------------------------------------------------------------------------------- //

namespace hcp
namespace hcp
{

namespace gpu
Expand All @@ -56,10 +56,10 @@ namespace s4

struct compare_dhCell
{
__host__ __device__
__host__ __device__
bool operator()(dhCell lhs, dhCell rhs)
{
return lhs.hyperscore < rhs.hyperscore;
return lhs.hyperscore < rhs.hyperscore;
}
};

Expand Down Expand Up @@ -117,7 +117,7 @@ __host__ void freed_eValues()
auto driver = hcp::gpu::cuda::driver::get_instance();

auto &&d_evalues = getd_eValues();

if (d_evalues)
{
hcp::gpu::cuda::error_check(hcp::gpu::cuda::device_free_async(d_evalues, driver->stream[DATA_STREAM]));
Expand Down
28 changes: 11 additions & 17 deletions source/core/dslim_fileout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ status_t DFile_InitFiles()
string_t filename = common + "_" + std::to_string(f) + ".tsv";
tsvs[f].open(filename);

tsvs[f] << "file\t" << "scan_num\t" << "prec_mass\t" << "charge\t"
<< "retention_time\t" << "peptide\t" << "matched_ions\t"
<< "total_ions\t" << "calc_pep_mass\t" << "mass_diff\t"
<< "mod_info\t" << "hyperscore\t" << "expectscore\t"
tsvs[f] << "file\t" << "scan_num\t" << "prec_mass\t" << "charge\t"
<< "retention_time\t" << "peptide\t" << "matched_ions\t"
<< "total_ions\t" << "calc_pep_mass\t" << "mass_diff\t"
<< "mod_info\t" << "hyperscore\t" << "expectscore\t"
<< "num_hits" << std::endl;
}
}
Expand Down Expand Up @@ -115,28 +115,22 @@ status_t DFile_PrintScore(Index *index, uint_t specid, float_t pmass, hCell *psm

Index * lclindex = index + psm->idxoffset;
int_t peplen = lclindex->pepIndex.peplen;
if (peplen < params.min_len or peplen > params.max_len)
{
throw std::runtime_error("Invalid peptide length encountered. Aborting");
}
int_t pepid = psm->psid;

/* The size is peplen + 1 to add the \0 character at the end */
char_t pepseq[peplen + 1];

/* Write the \0 character to the last position of pepseq buffer */
pepseq[peplen] = '\0';

/* Copy the rest of the string to the pepseq buffer */
strncpy((char_t *)&(pepseq[0]), lclindex->pepIndex.seqs +
(lclindex->pepEntries[psm->psid].seqID * peplen), peplen);

/* Make a string from the char [] */
string_t pep = pepseq;
auto *const pep_string = lclindex->pepIndex.seqs +
(lclindex->pepEntries[psm->psid].seqID * peplen);

/* Print the PSM info to the file */
tsvs[thno] << queryfiles[psm->fileIndex];
tsvs[thno] << '\t' << std::to_string(specid + 1);
tsvs[thno] << '\t' << std::to_string(pmass);
tsvs[thno] << '\t' << std::to_string(psm->pchg);
tsvs[thno] << '\t' << std::to_string(psm->rtime);
tsvs[thno] << '\t' << pep;
tsvs[thno] << '\t' << std::string_view(pep_string, peplen);
tsvs[thno] << '\t' << std::to_string(psm->sharedions);
tsvs[thno] << '\t' << std::to_string(psm->totalions);
tsvs[thno] << '\t' << std::to_string(lclindex->pepEntries[pepid].Mass);
Expand Down
27 changes: 6 additions & 21 deletions source/core/dslim_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ status_t DSLIM_SearchManager(Index *index)
// setup the comm and scheduling handles
//
if (status == SLM_SUCCESS)
status = DSLIM_Setup_Handles();
status = DSLIM_Setup_Handles();

//
// parallel database search
Expand Down Expand Up @@ -358,7 +358,7 @@ void GPU_DistributedSearch(Index *index)
gBatchlock.unlock();
break;
}

// increase the gBatchID
gBatchID++;

Expand Down Expand Up @@ -387,7 +387,7 @@ void GPU_DistributedSearch(Index *index)
MARK_END(penal);

auto penalty = ELAPSED_SECONDS(penal);

ptime += penalty;

#ifndef DIAGNOSE
Expand Down Expand Up @@ -532,7 +532,7 @@ status_t DistributedSearch(Index *index)
gBatchlock.unlock();
break;
}

// increase the gBatchID
gBatchID++;

Expand Down Expand Up @@ -730,27 +730,12 @@ status_t DSLIM_Destroy_Handles(Index *index)
}
#endif /* USE_MPI */

//
// Deinitialize
//

/* Delete the scheduler object */
if (SchedHandle != nullptr)
{
/* Deallocate the scheduler module */
delete SchedHandle;
SchedHandle = nullptr;
}

/* Deinitialize the IO module */
status = DSLIM_Deinit_IO();

if (status == SLM_SUCCESS && params.nodes == 1)
{
status = DFile_DeinitFiles();

delete[] ePtrs;
ePtrs = nullptr;
}

// deinitialize MS2 prep pointers
Expand Down Expand Up @@ -994,7 +979,7 @@ status_t DSLIM_QuerySpectrum(Queries<spectype_t> *ss, Index *index, uint_t idxch
if (resPtr->cpsms >= 1)
{
/* Extract the top PSM */
hCell&& psm = resPtr->topK.getMax();
hCell& psm = resPtr->topK.getMax();

/* Put it in the list */
CandidatePSMS[currSpecID + queries] = psm;
Expand Down Expand Up @@ -1370,7 +1355,7 @@ VOID DSLIM_IO_Threads_Entry()

/* Extract a chunk and return the chunksize */
status = Query->extractbatch<int>(QCHUNK, ioPtr, rem_spec);

// update remaining Query entries
ioPtr->batchNum = Query->Curr_chunk();
ioPtr->fileNum = Query->getQfileIndex();
Expand Down
2 changes: 1 addition & 1 deletion source/core/include/dslim_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DSLIM_Comm
friend status_t DSLIM_CarryForward(Index *index, DSLIM_Comm *CommHandle, expeRT *ePtr, hCell *CandidatePSMS, int_t cpsmSize);
DSLIM_Comm();
DSLIM_Comm(int_t);
virtual ~DSLIM_Comm();
~DSLIM_Comm() = default;
status_t AddBatch(int_t, int_t, int_t);
};

Expand Down
2 changes: 1 addition & 1 deletion source/core/include/dslim_fileout.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/* Function Definitions */
status_t DFile_PrintPartials(uint_t specid, Results *resPtr);
status_t DFile_PrintScore(Index *index, uint_t specid,
status_t DFile_PrintScore(Index *index, uint_t specid,
float_t pmass, hCell *psm, double_t e_x, uint_t npsms);
status_t DFile_InitFiles();
status_t DFile_DeinitFiles();
2 changes: 1 addition & 1 deletion source/core/include/expeRT.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class expeRT
expeRT();

/* Destructor */
virtual ~expeRT();
~expeRT();

/* Function to reset the data */
VOID ResetPartialVectors();
Expand Down
2 changes: 1 addition & 1 deletion source/core/include/lwbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class lwbuff
sem_init(&lockw, 0, 1);
}

virtual ~lwbuff()
~lwbuff()
{
cap = 0;
thr_low = 0;
Expand Down
12 changes: 10 additions & 2 deletions source/core/include/lwqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

#pragma once
#pragma once

#include "common.hpp"
#include <semaphore.h>
Expand Down Expand Up @@ -56,6 +56,10 @@ class lwqueue
lwqueue(int_t dcap)
{
cap = dcap;
if (cap <= 0)
{
throw std::runtime_error("lwqueue initialized with zero capacity. Aborting");
}
arr = new T[cap];
filled = 0;
head = 0;
Expand Down Expand Up @@ -86,6 +90,10 @@ class lwqueue
lwqueue(int_t dcap, BOOL sem)
{
cap = dcap;
if (cap <= 0)
{
throw std::runtime_error("lwqueue initialized with zero capacity. Aborting");
}
arr = new T[cap];
filled = 0;
head = 0;
Expand Down Expand Up @@ -120,7 +128,7 @@ class lwqueue
}
}

virtual ~lwqueue()
~lwqueue()
{
delete[] arr;
arr = NULL;
Expand Down
9 changes: 8 additions & 1 deletion source/core/include/lwvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class lwvector
lwvector(int_t dsiz)
{
cap = dsiz;
if (cap <= 0)
throw std::runtime_error("lwvector created with zero capacity. Aborting");
arr = new T [cap];
head = 0;
tail = 0;
Expand All @@ -78,6 +80,8 @@ class lwvector
lwvector(T *p1, T *p2)
{
cap = 2 * std::distance(p1, p2);
if (cap <= 0)
throw std::runtime_error("lwvector created with zero capacity. Aborting");
arr = new T[cap];
head = 0;
tail = 0;
Expand All @@ -93,6 +97,9 @@ class lwvector

lwvector(int_t dsiz, T val)
{
if (dsiz <= 0)
throw std::runtime_error("lwvector created with zero size. Aborting");

arr = new T [dsiz];
cap = dsiz;
head = 0;
Expand Down Expand Up @@ -144,7 +151,7 @@ class lwvector
}
}

virtual ~lwvector()
~lwvector()
{
head = tail = 0;
sze = cap = 0;
Expand Down
Loading

0 comments on commit 8681cae

Please sign in to comment.