diff --git a/.vscode/ipch/856c69690c514632/KMER.ipch b/.vscode/ipch/856c69690c514632/KMER.ipch index e65a7ca..5e6bbb1 100644 Binary files a/.vscode/ipch/856c69690c514632/KMER.ipch and b/.vscode/ipch/856c69690c514632/KMER.ipch differ diff --git a/.vscode/ipch/b49c1e8b711f08aa/HASH_TABLE.ipch b/.vscode/ipch/b49c1e8b711f08aa/HASH_TABLE.ipch index 71cb803..510b9a5 100644 Binary files a/.vscode/ipch/b49c1e8b711f08aa/HASH_TABLE.ipch and b/.vscode/ipch/b49c1e8b711f08aa/HASH_TABLE.ipch differ diff --git a/.vscode/ipch/c0e71cfe49f0fe81/ASSEMBLY.ipch b/.vscode/ipch/c0e71cfe49f0fe81/ASSEMBLY.ipch index 62ad212..c11c872 100644 Binary files a/.vscode/ipch/c0e71cfe49f0fe81/ASSEMBLY.ipch and b/.vscode/ipch/c0e71cfe49f0fe81/ASSEMBLY.ipch differ diff --git a/.vscode/ipch/f2b98741f94c3e10/MAIN.ipch b/.vscode/ipch/f2b98741f94c3e10/MAIN.ipch index db8d684..fc39927 100644 Binary files a/.vscode/ipch/f2b98741f94c3e10/MAIN.ipch and b/.vscode/ipch/f2b98741f94c3e10/MAIN.ipch differ diff --git a/Assembly.cpp b/Assembly.cpp index adbabb6..1caed77 100644 --- a/Assembly.cpp +++ b/Assembly.cpp @@ -75,7 +75,6 @@ void Verify_Counting() } -/********************************for debug***************************************/ @@ -83,6 +82,10 @@ void Verify_Counting() void* Perform_Counting(void* arg) { int thr_ID = *((int*)arg); + + ///debug_mode(101, thr_ID, thread_num); + + int i = 0; HPC_seq HPC_read; @@ -91,6 +94,7 @@ void* Perform_Counting(void* arg) init_R_buffer_block(&curr_sub_block); long long read_number = 0; + long long select_k_mer_number = 0 ; long long k_mer_number = 0 ; int file_flag = 1; @@ -126,8 +130,13 @@ void* Perform_Counting(void* arg) if (avalible_k>=k_mer_length) { ///插入 - insert_Total_Count_Table(&TCB, &k_code, k_mer_length); + if(insert_Total_Count_Table(&TCB, &k_code, k_mer_length)) + { + select_k_mer_number++; + } + k_mer_number++; + } } @@ -148,7 +157,8 @@ void* Perform_Counting(void* arg) destory_R_buffer_block(&curr_sub_block); free(arg); - fprintf(stdout, "thr_ID: %d, read_number: %lld, k_mer_number: %lld\n",thr_ID, read_number, k_mer_number); + fprintf(stdout, "thr_ID: %d, read_number: %lld, select_k_mer_number: %lld, k_mer_number: %lld\n", + thr_ID, read_number, select_k_mer_number, k_mer_number); } @@ -167,7 +177,6 @@ void* Perform_Counting(void* arg) - void Counting_multiple_thr() { diff --git a/Assembly.h b/Assembly.h index e7205de..19bd8e4 100644 --- a/Assembly.h +++ b/Assembly.h @@ -6,6 +6,5 @@ void Counting_multiple_thr(); /********************************for debug***************************************/ void Verify_Counting(); -/********************************for debug***************************************/ #endif diff --git a/Hash_Table.cpp b/Hash_Table.cpp index ce5c2a5..6180dc9 100644 --- a/Hash_Table.cpp +++ b/Hash_Table.cpp @@ -58,7 +58,27 @@ void destory_Total_Count_Table(Total_Count_Table* TCB) } +/********************************for debug***************************************/ +void debug_mode(uint64_t d, uint64_t thread_ID, uint64_t thread_num) +{ + fprintf(stderr, "#%llu: Start debug_mode...\n", thread_ID); + uint64_t i; + + for (i = thread_ID; i < 4,294,967,296; i = i + thread_num) + { + if(i%d != mod_d(0, i, d)) + { + fprintf(stderr, "ERROR mode, i: %llu\n", i); + fprintf(stderr, "i mod d: %llu\n", i%d); + fprintf(stderr, "mod_d(0, i, d): %llu\n", mod_d(0, i, d)); + } + + } + + fprintf(stderr, "#%llu: Finish debug_mode\n", thread_ID); + +} /********************************for debug***************************************/ @@ -111,4 +131,3 @@ void test_COUNT64() } -/********************************for debug***************************************/ diff --git a/Hash_Table.h b/Hash_Table.h index bd9e5da..6f46d5c 100644 --- a/Hash_Table.h +++ b/Hash_Table.h @@ -9,6 +9,7 @@ typedef khash_t(COUNT64) Count_Table; #define PREFIX_BITS 16 #define MAX_SUFFIX_BITS 64 +#define MODE_VALUE 101 typedef struct { @@ -40,9 +41,20 @@ inline void print_64bit(uint64_t x) fprintf(stderr, "\n"); } -/********************************for debug***************************************/ -inline void get_sub_table(uint64_t* get_sub_ID, uint64_t* get_sub_key, Total_Count_Table* TCB, Hash_code* code, int k) +inline uint64_t mod_d(uint64_t h_key, uint64_t low_key, uint64_t d) +{ + uint64_t result = (h_key >> 32) % d; + result = ((result << 32) + (h_key & (uint64_t)0xffffffff)) % d; + result = ((result << 32) + (low_key >> 32)) % d; + result = ((result << 32) + (low_key & (uint64_t)0xffffffff)) % d; + + return result; +} + + + +inline int get_sub_table(uint64_t* get_sub_ID, uint64_t* get_sub_key, Total_Count_Table* TCB, Hash_code* code, int k) { uint64_t h_key, low_key; ///k有可能是64,所以可能会有问题 @@ -51,6 +63,12 @@ inline void get_sub_table(uint64_t* get_sub_ID, uint64_t* get_sub_key, Total_Cou //k不可能为0, 所以这个右移不会有问题 h_key = code->x[1] >> (64 - k); + if(mod_d(h_key, low_key, MODE_VALUE) > 3) + { + return 0; + } + + ///注意suffix_bits最大就是64 ///前一个右移不安全,因为TCB->suffix_bits有可能为64 ///后一个左移安全,因为TCB->suffix_bits不可能为0 @@ -61,13 +79,18 @@ inline void get_sub_table(uint64_t* get_sub_ID, uint64_t* get_sub_key, Total_Cou *get_sub_ID = sub_ID; *get_sub_key = sub_key; + return 1; + } -inline void insert_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int k) +inline int insert_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int k) { uint64_t sub_ID, sub_key; - get_sub_table(&sub_ID, &sub_key, TCB, code, k); + if(!get_sub_table(&sub_ID, &sub_key, TCB, code, k)) + { + return 0; + } khint_t t; ///这就是个迭代器 int absent; @@ -90,13 +113,18 @@ inline void insert_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, in } __sync_lock_release(&TCB->sub_h_lock[sub_ID].lock); + + return 1; } inline int get_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int k) { uint64_t sub_ID, sub_key; - get_sub_table(&sub_ID, &sub_key, TCB, code, k); + if(!get_sub_table(&sub_ID, &sub_key, TCB, code, k)) + { + return 0; + } khint_t t; ///这就是个迭代器 int absent; @@ -113,13 +141,18 @@ inline int get_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int k) return -1; } + return 1; + } /********************************for debug***************************************/ inline int verify_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int k) { uint64_t sub_ID, sub_key; - get_sub_table(&sub_ID, &sub_key, TCB, code, k); + if(!get_sub_table(&sub_ID, &sub_key, TCB, code, k)) + { + return 0; + } khint_t t; ///这就是个迭代器 int absent; @@ -144,7 +177,6 @@ inline int verify_Total_Count_Table(Total_Count_Table* TCB, Hash_code* code, int return -1; } } -/********************************for debug***************************************/ /********************************for debug***************************************/ inline int Traverse_Total_Count_Table(Total_Count_Table* TCB) @@ -174,7 +206,6 @@ inline int Traverse_Total_Count_Table(Total_Count_Table* TCB) fprintf(stdout, "non_empty_k_mer: %lld\n", non_empty_k_mer); } -/********************************for debug***************************************/ void init_Total_Count_Table(int k, Total_Count_Table* TCB); @@ -184,6 +215,9 @@ void init_Count_Table(Count_Table** table); /********************************for debug***************************************/ void test_COUNT64(); + /********************************for debug***************************************/ +void debug_mode(uint64_t d, uint64_t thread_ID, uint64_t thread_num); + #endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index c704208..7307e84 100644 --- a/main.cpp +++ b/main.cpp @@ -13,7 +13,6 @@ void debug_Counting() fprintf(stderr, "debug over!\n"); destory_kseq(); } -/********************************for debug***************************************/ int main(int argc, char *argv[])