CX/include/cx.h

74 lines
1.4 KiB
C
Raw Normal View History

#ifndef CX_H
#define CX_H
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <stdint.h>
2024-11-07 21:07:33 +00:00
#include <pthread.h>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
2023-12-13 09:56:21 +00:00
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
// Include project headers
2024-11-10 20:28:17 +00:00
#include <cx_thread.h>
#include <tensor.h>
#include <model.h>
#include <tensor.h>
2024-07-06 15:59:22 +00:00
#include <neural.h>
2024-11-10 20:28:17 +00:00
#include <shader.h>
2024-11-07 21:07:33 +00:00
// Declare common data structures.
2024-11-10 20:28:17 +00:00
typedef struct _cx_gl_ctx {
2024-11-20 00:00:18 +00:00
void (*free)(void *self);
uint8_t master_lock;
uint8_t *worker_locks;
CX_ThreadGroup **workers;
2024-11-07 21:07:33 +00:00
GLFWwindow *window;
2024-11-10 20:28:17 +00:00
ModelRegistry *mr;
GLuint *VertexArrayIDs;
size_t VertexArray_count;
size_t VertexArray_size;
GLuint *programIDs;
size_t ProgramID_count;
size_t ProgramID_size;
2024-11-10 20:28:17 +00:00
} CX_GL_CTX;
typedef struct _cx_nn_ctx {
2024-11-20 00:00:18 +00:00
void (*free)(void *self);
uint8_t master_lock;
uint8_t *worker_locks;
CX_ThreadGroup **workers;
2024-11-10 20:28:17 +00:00
Neural_Network *nn;
float *input_buffer;
float *output_buffer;
} CX_NN_CTX;
typedef struct _cx_ctx {
CX_ThreadGroup **threads;
CX_GL_CTX *gl_ctx;
CX_NN_CTX *nn_ctx;
2024-11-07 21:07:33 +00:00
} CX_Context;
// Declare functions
2024-11-07 21:07:33 +00:00
CX_Context *cx_context_new(void);
int cx_glinit(CX_GL_CTX **);
2024-07-06 15:59:22 +00:00
int cx_nninit(Neural_Network **);
int cx_init(CX_Context **);
2024-10-19 09:32:39 +00:00
2024-11-07 21:07:33 +00:00
int cx_run(CX_Context *);
2024-07-06 15:59:22 +00:00
#endif