application exit error handing
This commit is contained in:
@@ -57,8 +57,10 @@ inline void vx_tmc(unsigned num_threads) {
|
||||
asm volatile (".insn s 0x6b, 0, x0, 0(%0)" :: "r"(num_threads));
|
||||
}
|
||||
|
||||
typedef void (*vx_wspawn_pfn)();
|
||||
|
||||
// Spawn warps
|
||||
inline void vx_wspawn(unsigned num_warps, void* func_ptr) {
|
||||
inline void vx_wspawn(unsigned num_warps, vx_wspawn_pfn func_ptr) {
|
||||
asm volatile (".insn s 0x6b, 1, %1, 0(%0)" :: "r"(num_warps), "r"(func_ptr));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,21 +18,23 @@ struct context_t {
|
||||
uint32_t work_dim;
|
||||
};
|
||||
|
||||
typedef void (*pfn_workgroup_func) (
|
||||
const void * /* args */,
|
||||
typedef void (*vx_spawn_kernel_cb) (
|
||||
const void * /* arg */,
|
||||
const struct context_t * /* context */,
|
||||
uint32_t /* group_x */,
|
||||
uint32_t /* group_y */,
|
||||
uint32_t /* group_z */
|
||||
);
|
||||
|
||||
typedef void (*pfn_callback)(int task_id, void *arg);
|
||||
typedef void (*vx_spawn_tasks_cb)(int task_id, void *arg);
|
||||
|
||||
void vx_spawn_kernel(struct context_t * ctx, pfn_workgroup_func wg_func, void * arg);
|
||||
typedef void (*vx_serial_cb)(int task_id, void *arg);
|
||||
|
||||
void vx_spawn_tasks(int num_tasks, pfn_callback callback, void * arg);
|
||||
void vx_spawn_kernel(struct context_t * ctx, vx_spawn_kernel_cb callback, void * arg);
|
||||
|
||||
void vx_serial(pfn_callback callback, void * arg);
|
||||
void vx_spawn_tasks(int num_tasks, vx_spawn_tasks_cb callback, void * arg);
|
||||
|
||||
void vx_serial(vx_serial_cb callback, void * arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ extern "C" {
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
typedef struct {
|
||||
pfn_callback callback;
|
||||
vx_spawn_tasks_cb callback;
|
||||
void * arg;
|
||||
int offset;
|
||||
int N;
|
||||
@@ -20,7 +20,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
struct context_t * ctx;
|
||||
pfn_workgroup_func wg_func;
|
||||
vx_spawn_kernel_cb callback;
|
||||
void * arg;
|
||||
int offset;
|
||||
int N;
|
||||
@@ -77,7 +77,7 @@ void spawn_remaining_tasks_callback(int nthreads) {
|
||||
vx_tmc(1);
|
||||
}
|
||||
|
||||
void vx_spawn_tasks(int num_tasks, pfn_callback callback , void * arg) {
|
||||
void vx_spawn_tasks(int num_tasks, vx_spawn_tasks_cb callback , void * arg) {
|
||||
// device specs
|
||||
int NC = vx_num_cores();
|
||||
int NW = vx_num_warps();
|
||||
@@ -159,7 +159,7 @@ static void spawn_kernel_callback() {
|
||||
int gid1 = p_wspawn_args->ctx->global_offset[1] + j;
|
||||
int gid2 = p_wspawn_args->ctx->global_offset[2] + k;
|
||||
|
||||
(p_wspawn_args->wg_func)(p_wspawn_args->arg, p_wspawn_args->ctx, gid0, gid1, gid2);
|
||||
(p_wspawn_args->callback)(p_wspawn_args->arg, p_wspawn_args->ctx, gid0, gid1, gid2);
|
||||
}
|
||||
|
||||
vx_tmc(0 == wid);
|
||||
@@ -188,12 +188,12 @@ static void spawn_kernel_remaining_callback(int nthreads) {
|
||||
int gid1 = p_wspawn_args->ctx->global_offset[1] + j;
|
||||
int gid2 = p_wspawn_args->ctx->global_offset[2] + k;
|
||||
|
||||
(p_wspawn_args->wg_func)(p_wspawn_args->arg, p_wspawn_args->ctx, gid0, gid1, gid2);
|
||||
(p_wspawn_args->callback)(p_wspawn_args->arg, p_wspawn_args->ctx, gid0, gid1, gid2);
|
||||
|
||||
vx_tmc(1);
|
||||
}
|
||||
|
||||
void vx_spawn_kernel(struct context_t * ctx, pfn_workgroup_func wg_func, void * arg) {
|
||||
void vx_spawn_kernel(struct context_t * ctx, vx_spawn_kernel_cb callback, void * arg) {
|
||||
// total number of WGs
|
||||
int X = ctx->num_groups[0];
|
||||
int Y = ctx->num_groups[1];
|
||||
@@ -241,7 +241,9 @@ void vx_spawn_kernel(struct context_t * ctx, pfn_workgroup_func wg_func, void *
|
||||
char log2X = fast_log2(X);
|
||||
|
||||
//--
|
||||
wspawn_kernel_args_t wspawn_args = { ctx, wg_func, arg, core_id * wgs_per_core, fW, rW, isXYpow2, isXpow2, log2XY, log2X };
|
||||
wspawn_kernel_args_t wspawn_args = {
|
||||
ctx, callback, arg, core_id * wgs_per_core, fW, rW, isXYpow2, isXpow2, log2XY, log2X
|
||||
};
|
||||
g_wspawn_args[core_id] = &wspawn_args;
|
||||
|
||||
//--
|
||||
|
||||
@@ -42,6 +42,11 @@ _start:
|
||||
.type _exit, @function
|
||||
.global _exit
|
||||
_exit:
|
||||
beqz a0, label_exit_next
|
||||
mv gp, a0
|
||||
ecall;
|
||||
|
||||
label_exit_next:
|
||||
# dump performance CSRs
|
||||
call vx_perf_dump
|
||||
|
||||
|
||||
Reference in New Issue
Block a user