sort test fix.

This commit is contained in:
Blaise Tine
2021-10-18 00:41:11 -04:00
parent 0d62129d32
commit 456f1df332
3 changed files with 20 additions and 28 deletions

View File

@@ -1,26 +1,9 @@
#include <stdint.h>
#include <vx_intrinsics.h>
#include <vx_spawn.h>
#include <vx_print.h>
#include "common.h"
// Parallel Selection sort
int __attribute__((noinline)) __smaller(int index, int tid, int32_t cur_value, int32_t ref_value) {
int ret = 0;
__if (cur_value < ref_value) {
ret = 1;
} __else {
__if (cur_value == ref_value) {
__if (index < tid) {
ret = 1;
} __endif
} __endif
} __endif
return ret;
}
void kernel_body(int task_id, kernel_arg_t* arg) {
void kernel_body(int __DIVERGENT__ task_id, kernel_arg_t* arg) {
uint32_t num_points = arg->num_points;
int32_t* src_ptr = (int32_t*)arg->src_ptr;
int32_t* dst_ptr = (int32_t*)arg->dst_ptr;
@@ -30,10 +13,9 @@ void kernel_body(int task_id, kernel_arg_t* arg) {
uint32_t pos = 0;
for (uint32_t i = 0; i < num_points; ++i) {
int32_t cur_value = src_ptr[i];
pos += __smaller(i, task_id, cur_value, ref_value);
pos += (cur_value < ref_value) || ((cur_value == ref_value) && (i < task_id));
}
dst_ptr[pos] = ref_value;
vx_printf("taskid=%d, pos=%d, value=%d\n", task_id, pos, ref_value);
}
void main() {