mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-24 13:57:17 -04:00
vx_spawn_threads implementation
This commit is contained in:
parent
8c5a783477
commit
96cb381885
5 changed files with 208 additions and 152 deletions
|
@ -14,28 +14,54 @@
|
|||
#ifndef __VX_SPAWN_H__
|
||||
#define __VX_SPAWN_H__
|
||||
|
||||
#include <VX_types.h>
|
||||
#include <vx_intrinsics.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*vx_spawn_tasks_cb)(int task_id, const void *arg);
|
||||
|
||||
typedef void (*vx_spawn_task_groups_cb)(int local_task_id, int group_id, int local_group_id, int warps_per_group, const void *arg);
|
||||
typedef void (*vx_spawn_tasks_cb)(uint32_t task_id, const void *arg);
|
||||
|
||||
typedef void (*vx_serial_cb)(const void *arg);
|
||||
|
||||
void vx_spawn_tasks(int num_tasks, vx_spawn_tasks_cb callback, const void * arg);
|
||||
void vx_spawn_tasks(uint32_t num_tasks, vx_spawn_tasks_cb callback, const void * arg);
|
||||
|
||||
void vx_spawn_task_groups(int num_groups, int group_size, vx_spawn_task_groups_cb callback, const void * arg);
|
||||
void vx_serial(vx_serial_cb callback, void * arg);
|
||||
|
||||
inline void* vx_local_malloc(int local_group_id, int size) {
|
||||
return (int8_t*)csr_read(VX_CSR_LOCAL_MEM_BASE) + local_group_id * size;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void vx_serial(vx_serial_cb callback, const void * arg);
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t z;
|
||||
};
|
||||
uint32_t m[3];
|
||||
} dim3_t;
|
||||
|
||||
extern __thread dim3_t blockIdx;
|
||||
extern __thread dim3_t threadIdx;
|
||||
extern dim3_t gridDim;
|
||||
extern dim3_t blockDim;
|
||||
|
||||
extern __thread uint32_t __local_group_id;
|
||||
extern uint32_t __groups_per_core;
|
||||
extern uint32_t __warps_per_group;
|
||||
|
||||
typedef void (*vx_kernel_func_cb)(const void *arg);
|
||||
|
||||
#define __local_mem(size) \
|
||||
(void*)((int8_t*)csr_read(VX_CSR_LOCAL_MEM_BASE) + __local_group_id * size)
|
||||
|
||||
#define __syncthreads() \
|
||||
vx_barrier(__COUNTER__ * __groups_per_core + __local_group_id, __warps_per_group)
|
||||
|
||||
int vx_spawn_threads(uint32_t dimension,
|
||||
const uint32_t* grid_dim,
|
||||
const uint32_t* block_dim,
|
||||
vx_kernel_func_cb kernel_func,
|
||||
const void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue