File: 0003-fixed-smem-memory-rellocation-issue-issue167.patch

package info (click to toggle)
bwa-mem2 2.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,400 kB
  • sloc: cpp: 17,653; ansic: 14,839; makefile: 248; sh: 11
file content (55 lines) | stat: -rw-r--r-- 2,221 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From: Vasimuddin <wasim.mzr@gmail.com>
Date: Sun, 12 Dec 2021 21:56:48 -0800
Subject: fixed smem memory rellocation issue (issue167)

Origin: upstream, https://github.com/bwa-mem2/bwa-mem2/commit/edc703f883e8aaed83067100d8e54e0e9e810ef5
Forwarded: not-needed
---
 src/bwamem.cpp | 8 ++++----
 src/macro.h    | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/bwamem.cpp b/src/bwamem.cpp
index 4a18aff..76d4148 100644
--- a/src/bwamem.cpp
+++ b/src/bwamem.cpp
@@ -924,13 +924,13 @@ int mem_kernel1_core(FMI_search *fmi,
         for (i = 0; i < len; ++i)
             seq[i] = seq[i] < 4? seq[i] : nst_nt4_table[(int)seq[i]]; //nst_nt4??       
     }
-
+    tot_len *= N_SMEM_KERNEL;
     // This covers enc_qdb/SMEM reallocs
     if (tot_len >= mmc->wsize_mem[tid])
     {
         fprintf(stderr, "[%0.4d] Re-allocating SMEM data structures due to enc_qdb\n", tid);
         int64_t tmp = mmc->wsize_mem[tid];
-        mmc->wsize_mem[tid] *= 2;
+        mmc->wsize_mem[tid] = tot_len;
         mmc->matchArray[tid]   = (SMEM *) _mm_realloc(mmc->matchArray[tid],
                                                       tmp, mmc->wsize_mem[tid], sizeof(SMEM));
             //realloc(mmc->matchArray[tid], mmc->wsize_mem[tid] *   sizeof(SMEM));
@@ -966,8 +966,8 @@ int mem_kernel1_core(FMI_search *fmi,
                      num_smem);
 
     if (num_smem >= *wsize_mem){
-        fprintf(stderr, "num_smem: %ld\n", num_smem);
-        assert(num_smem < *wsize_mem);
+        fprintf(stderr, "Error [bug]: num_smem: %ld are more than allocated space.\n", num_smem);
+        exit(EXIT_FAILURE);
     }
     printf_(VER, "6. Done! mem_collect_smem, num_smem: %ld\n", num_smem);
     tprof[MEM_COLLECT][tid] += __rdtsc() - tim; 
diff --git a/src/macro.h b/src/macro.h
index d2da0cc..4adc980 100644
--- a/src/macro.h
+++ b/src/macro.h
@@ -48,7 +48,7 @@ Authors: Vasimuddin Md <vasimuddin.md@intel.com>; Sanchit Misra <sanchit.misra@i
 #define BATCH_SIZE 512               /* Block of reads alloacted to a thread for processing*/
 #define BATCH_MUL 20
 #define SEEDS_PER_CHAIN 1
-
+#define N_SMEM_KERNEL 3
 #define READ_LEN 151
 
 #define SEQ_LEN8 128   // redundant??