diff options
Diffstat (limited to 'BS/dpu/task.c')
-rw-r--r-- | BS/dpu/task.c | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/BS/dpu/task.c b/BS/dpu/task.c index 45c48f5..ac4ca38 100644 --- a/BS/dpu/task.c +++ b/BS/dpu/task.c @@ -17,12 +17,12 @@ __host dpu_arguments_t DPU_INPUT_ARGUMENTS; __host dpu_results_t DPU_RESULTS[NR_TASKLETS]; // Search -static DTYPE search(DTYPE *bufferA, DTYPE searching_for) { +static DTYPE search(DTYPE *bufferA, DTYPE searching_for, size_t search_size) { DTYPE found = -2; if(bufferA[0] <= searching_for) { found = -1; - for (uint32_t i = 0; i < BLOCK_SIZE / sizeof(DTYPE); i++){ + for (uint32_t i = 0; i < search_size / sizeof(DTYPE); i++){ if(bufferA[i] == searching_for) { found = i; @@ -94,13 +94,47 @@ int main_kernel1() { current_mram_block_addr_A = (start_mram_block_addr_A + end_mram_block_addr_A) / 2; current_mram_block_addr_A &= WORD_MASK; - while(!end) + + while(1) { + // Boundary check + if(current_mram_block_addr_A < (start_mram_block_addr_A + BLOCK_SIZE)) + { + //end = true; + // find (start_mram_block_addr_A, start_mram_block_addr_A + BLOCK_SIZE) + mram_read((__mram_ptr void const *) start_mram_block_addr_A, cache_A, BLOCK_SIZE); + found = search(cache_A, searching_for, BLOCK_SIZE); + + if(found > -1) + { + result->found = found + (start_mram_block_addr_A - start_mram_block_addr_aux) / sizeof(DTYPE); + printf("Tasklet %d has found %lld\n", me(), result->found + 1); + } + // find (start_mram_block_addr_A + BLOCK_SIZE, end_mram_block_addr_A) + else + { + size_t remain_bytes_to_search = end_mram_block_addr_A - (start_mram_block_addr_A + BLOCK_SIZE); + mram_read((__mram_ptr void const *) start_mram_block_addr_A + BLOCK_SIZE, cache_A, remain_bytes_to_search); + found = search(cache_A, searching_for, remain_bytes_to_search); + + if(found > -1) + { + result->found = found + (start_mram_block_addr_A + BLOCK_SIZE - start_mram_block_addr_aux) / sizeof(DTYPE); + printf("Tasklet %d has found %lld\n", me(), result->found + 1); + } + else + { + printf("%lld NOT found\n", searching_for); + } + } + break; + } + // Load cache with current MRAM block mram_read((__mram_ptr void const *) current_mram_block_addr_A, cache_A, BLOCK_SIZE); // Search inside block - found = search(cache_A, searching_for); + found = search(cache_A, searching_for, BLOCK_SIZE); // If found > -1, we found the searching_for query if(found > -1) @@ -125,43 +159,6 @@ int main_kernel1() { current_mram_block_addr_A = (current_mram_block_addr_A + end_mram_block_addr_A) / 2; current_mram_block_addr_A &= WORD_MASK; } - - // Start boundary check - if(current_mram_block_addr_A < (start_mram_block_addr_aux + BLOCK_SIZE)) - { - end = true; - mram_read((__mram_ptr void const *) current_mram_block_addr_A, cache_A, BLOCK_SIZE); - found = search(cache_A, searching_for); - - if(found > -1) - { - end = true; - result->found = found + (current_mram_block_addr_A - start_mram_block_addr_aux) / sizeof(DTYPE); - printf("Tasklet %d has found %lld\n", me(), result->found + 1); - } - else - { - printf("%lld NOT found\n", searching_for); - } - } - - // End boundary check - if(current_mram_block_addr_A > (end_mram_block_addr_A - BLOCK_SIZE)) - { - end = true; - mram_read((__mram_ptr void const *) end_mram_block_addr_A - BLOCK_SIZE, cache_A, BLOCK_SIZE); - found = search(cache_A, searching_for); - - if(found > -1) - { - result->found = found + (current_mram_block_addr_A - start_mram_block_addr_aux) / sizeof(DTYPE); - printf("Tasklet %d has found %lld\n", me(), result->found + 1); - } - else - { - printf("%lld NOT found\n", searching_for); - } - } } } return 0; |