idle: Use barriers instead to hang the core
This commit is contained in:
@@ -12,23 +12,28 @@
|
|||||||
#define HW_TID() ({uint32_t gtid; asm volatile ("csrr %0, mhartid" : "=r" (gtid)); gtid;})
|
#define HW_TID() ({uint32_t gtid; asm volatile ("csrr %0, mhartid" : "=r" (gtid)); gtid;})
|
||||||
|
|
||||||
void kernel_body(int task_id, kernel_arg_t *__UNIFORM__ arg) {
|
void kernel_body(int task_id, kernel_arg_t *__UNIFORM__ arg) {
|
||||||
constexpr uint32_t timer = 50000;
|
// constexpr uint32_t timer = 50000;
|
||||||
uint32_t counter = 0;
|
// uint32_t counter = 0;
|
||||||
while ((counter++) < timer) {
|
// while ((counter++) < timer) {
|
||||||
asm("");
|
// asm("");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// to prevent optimize-out
|
// to prevent optimize-out
|
||||||
// reinterpret_cast<uint32_t *>(arg->addr_c)[0] = counter;
|
// reinterpret_cast<uint32_t *>(arg->addr_c)[0] = counter;
|
||||||
|
|
||||||
|
// call barrier in a divergent branch, which will hang the core
|
||||||
|
if ((vx_thread_id() % NUM_THREADS) == 0) {
|
||||||
|
vx_barrier(0, NUM_WARPS);
|
||||||
|
}
|
||||||
|
|
||||||
vx_tmc(0);
|
vx_tmc(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
kernel_arg_t *arg = (kernel_arg_t *)KERNEL_ARG_DEV_MEM_ADDR;
|
kernel_arg_t *arg = (kernel_arg_t *)KERNEL_ARG_DEV_MEM_ADDR;
|
||||||
|
|
||||||
// const uint32_t num_threads_in_cluster = NUM_THREADS_IN_CLUSTER;
|
// spawn a single warp in every core
|
||||||
// const uint32_t grid_size = num_threads_in_cluster * NUM_CLUSTERS;
|
const uint32_t grid_size = NUM_THREADS * NUM_CORES;
|
||||||
const uint32_t grid_size = 1;
|
|
||||||
#ifdef RADIANCE
|
#ifdef RADIANCE
|
||||||
vx_spawn_tasks_cluster(grid_size, (vx_spawn_tasks_cb)kernel_body, arg);
|
vx_spawn_tasks_cluster(grid_size, (vx_spawn_tasks_cb)kernel_body, arg);
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user