futhark-0.28.2: rts/c/context_prototypes.h
// Start of context_prototypes.h
//
// Prototypes for the functions in context.h, or that will be called
// from those functions, that need to be available very early.
struct futhark_context_config;
struct futhark_context;
struct tuning_param {
const char *name;
const char *var; // Z-encoded name.
const char *class;
bool set;
int64_t val;
};
static void set_error(struct futhark_context* ctx, char *error);
// These are called in context/config new/free functions and contain
// shared setup. They are generated by the compiler itself.
static int init_constants(struct futhark_context*);
static int free_constants(struct futhark_context*);
static void setup_program(struct futhark_context* ctx);
static void teardown_program(struct futhark_context *ctx);
// Allocate host memory. Must be freed with host_free(). Returns
// FUTHARK_OUT_OF_MEMORY (and sets an error) on failure.
static int host_alloc(struct futhark_context* ctx, size_t size, const char* tag, size_t* size_out, void** mem_out);
// Allocate memory allocated with host_alloc().
static void host_free(struct futhark_context* ctx, size_t size, const char* tag, void* mem);
// Log that a copy has occurred. The provenance may be NULL, if we do not know
// where this came from.
static void log_copy(struct futhark_context* ctx,
const char *kind, const char *provenance,
int r,
int64_t dst_offset, int64_t dst_strides[r],
int64_t src_offset, int64_t src_strides[r],
int64_t shape[r]);
// A copy that is a map(transpose). There are 'num_arrays' arrays, and in each
// of them, the source has 'rows' rows of 'cols' contiguous elements, while the
// destination has 'cols' rows of 'rows' contiguous elements. Element 'j' of row
// 'i' of source array 'l' is at index l*src_array_stride + i*src_row_stride +
// j, and is copied to index l*dst_array_stride + j*dst_row_stride + i.
struct lmad_transpose {
int64_t num_arrays, rows, cols;
int64_t dst_array_stride, dst_row_stride;
int64_t src_array_stride, src_row_stride;
};
static void log_transpose(struct futhark_context* ctx,
const struct lmad_transpose *tr);
static bool lmad_map_tr(struct lmad_transpose *tr,
int r,
const int64_t dst_strides[r],
const int64_t src_strides[r],
const int64_t shape[r]);
static bool lmad_contiguous(int r, int64_t strides[r], int64_t shape[r]);
static bool lmad_memcpyable(int r,
int64_t dst_strides[r], int64_t src_strides[r], int64_t shape[r]);
static void add_event(struct futhark_context* ctx,
const char* name,
const char* provenance,
struct kvs *kvs,
void* data,
event_report_fn f);
// Functions that must be defined by the backend.
static void backend_context_config_setup(struct futhark_context_config* cfg);
static void backend_context_config_teardown(struct futhark_context_config* cfg);
static int backend_context_setup(struct futhark_context *ctx);
static void backend_context_teardown(struct futhark_context *ctx);
// End of of context_prototypes.h