Graph Framework
Loading...
Searching...
No Matches
graph_c_binding.h File Reference

Header file for the c binding library. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Classes

struct  graph_c_context
 graph_c_context type. More...

Macros

#define START_GPU
#define END_GPU
#define STRUCT_TAG   struct

Typedefs

typedef void * graph_node
 Graph node type for C interface.

Enumerations

enum  graph_type { FLOAT , DOUBLE , COMPLEX_FLOAT , COMPLEX_DOUBLE }
 Graph base type.

Functions

STRUCT_TAG graph_c_context * graph_construct_context (const enum graph_type type, const bool use_safe_math)
 Construct a C context.
void graph_destroy_context (STRUCT_TAG graph_c_context *c)
 Destroy C context.
graph_node graph_variable (STRUCT_TAG graph_c_context *c, const size_t size, const char *symbol)
 Create variable node.
graph_node graph_constant (STRUCT_TAG graph_c_context *c, const double value)
 Create constant node.
void graph_set_variable (STRUCT_TAG graph_c_context *c, graph_node var, const void *source)
 Set a variable value.
graph_node graph_constant_c (STRUCT_TAG graph_c_context *c, const double real_value, const double img_value)
 Create complex constant node.
graph_node graph_pseudo_variable (STRUCT_TAG graph_c_context *c, graph_node var)
 Create a pseudo variable.
graph_node graph_remove_pseudo (STRUCT_TAG graph_c_context *c, graph_node var)
 Remove pseudo.
graph_node graph_add (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create Addition node.
graph_node graph_sub (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create Subtract node.
graph_node graph_mul (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create Multiply node.
graph_node graph_div (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create Divide node.
graph_node graph_sqrt (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create Sqrt node.
graph_node graph_exp (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create exp node.
graph_node graph_log (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create log node.
graph_node graph_pow (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create Pow node.
graph_node graph_erfi (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create imaginary error function node.
graph_node graph_sin (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create sine node.
graph_node graph_cos (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create cosine node.
graph_node graph_atan (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create arctangent node.
graph_node graph_random_state (STRUCT_TAG graph_c_context *c, const size_t size, const uint32_t seed)
 Construct a random state node.
graph_node graph_random (STRUCT_TAG graph_c_context *c, graph_node state)
 Create random node.
graph_node graph_piecewise_1D (STRUCT_TAG graph_c_context *c, graph_node arg, const double scale, const double offset, const void *source, const size_t source_size)
 Create 1D piecewise node.
graph_node graph_piecewise_2D (STRUCT_TAG graph_c_context *c, const size_t num_cols, graph_node x_arg, const double x_scale, const double x_offset, graph_node y_arg, const double y_scale, const double y_offset, const void *source, const size_t source_size)
 Create 2D piecewise node.
graph_node graph_index_1D (STRUCT_TAG graph_c_context *c, graph_node variable, graph_node arg, const double scale, const double offset)
 Create a 1D index.
graph_node graph_index_2D (STRUCT_TAG graph_c_context *c, graph_node variable, const size_t num_cols, graph_node x_arg, const double x_scale, const double x_offset, graph_node y_arg, const double y_scale, const double y_offset)
 Create a 2D index.
graph_node graph_atomic_accumulate_1D (STRUCT_TAG graph_c_context *c, graph_node variable, graph_node index, const double scale, const double offset, graph_node arg)
 Create an atomic accumulate 1D index.
graph_node graph_index (STRUCT_TAG graph_c_context *c)
 Create an index code.
graph_node graph_not (STRUCT_TAG graph_c_context *c, graph_node arg)
 Create not node.
graph_node graph_equal (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create an equal node.
graph_node graph_not_equal (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create a not equal node.
graph_node graph_greater_than (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create a greater than node.
graph_node graph_less_than (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create a less than node.
graph_node graph_greater_than_equal (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create a greater than equal node.
graph_node graph_less_than_equal (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create a less than node.
graph_node graph_and (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create an and node.
graph_node graph_or (STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
 Create an or node.
graph_node graph_if (STRUCT_TAG graph_c_context *c, graph_node condition, graph_node t, graph_node f)
 Create a if node.
size_t graph_get_max_concurrency (STRUCT_TAG graph_c_context *c)
 Create 2D piecewise node with complex arguments.
void graph_set_device_number (STRUCT_TAG graph_c_context *c, const size_t num)
 Choose the device number.
void graph_add_pre_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size)
 Add pre workflow item.
void graph_add_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size)
 Add workflow item.
void graph_add_post_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size)
 Add post workflow item.
void graph_add_pre_loop_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size, const size_t iterations)
 Add pre loop workflow item.
void graph_add_loop_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size, const size_t iterations)
 Add workflow loop item.
void graph_add_pre_converge_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size, const double tol, const size_t max_iter)
 Add a pre converge item.
void graph_add_converge_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size, const double tol, const size_t max_iter)
 Add a converge item.
void graph_add_post_converge_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node *atomics, size_t num_atomics, graph_node random_state, const char *name, const size_t size, const double tol, const size_t max_iter)
 Add a post converge item.
void graph_add_pre_zero_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs)
 Add a pre zero item.
void graph_add_zero_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs)
 Add a copy item.
void graph_add_post_zero_item (STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs)
 Add a post zero item.
void graph_add_pre_copy_item (STRUCT_TAG graph_c_context *c, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps)
 Add a pre copy item.
void graph_add_copy_item (STRUCT_TAG graph_c_context *c, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps)
 Add a copy item.
void graph_add_post_copy_item (STRUCT_TAG graph_c_context *c, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps)
 Add a post copy item.
void graph_compile (STRUCT_TAG graph_c_context *c)
 Compile the work items.
void graph_pre_run (STRUCT_TAG graph_c_context *c)
 Run pre work items.
void graph_run (STRUCT_TAG graph_c_context *c)
 Run work items.
void graph_post_run (STRUCT_TAG graph_c_context *c)
 Run post work items.
void graph_wait (STRUCT_TAG graph_c_context *c)
 Wait for work items to complete.
void graph_copy_to_device (STRUCT_TAG graph_c_context *c, graph_node node, void *source)
 Copy data to a device buffer.
void graph_copy_to_host (STRUCT_TAG graph_c_context *c, graph_node node, void *destination)
 Copy data to a host buffer.
void graph_print (STRUCT_TAG graph_c_context *c, const size_t index, graph_node *nodes, const size_t num_nodes)
 Print a value from nodes.
graph_node graph_df (STRUCT_TAG graph_c_context *c, graph_node fnode, graph_node xnode)
 Take derivative ∂f∂x.

Detailed Description

Header file for the c binding library.

Macro Definition Documentation

◆ END_GPU

#define END_GPU

Ends a Cocoa auto release pool when using the metal backend. No opt otherwise.

◆ START_GPU

#define START_GPU

Starts a Cocoa auto release pool when using the metal backend. No opt otherwise.

◆ STRUCT_TAG

#define STRUCT_TAG   struct

C++ mode needs to tag a graph_c_context as a struct.

Function Documentation

◆ graph_add()

graph_node graph_add ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create Addition node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left + right

Create Addition node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left + right

◆ graph_add_converge_item()

void graph_add_converge_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size,
const double tol,
const size_t max_iter )

Add a converge item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]tolTolerance to converge the function to.
[in]max_iterMaximum number of iterations before giving up.

◆ graph_add_copy_item()

void graph_add_copy_item ( STRUCT_TAG graph_c_context * c,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps )

Add a copy item.

Parameters
[in]cThe graph C context.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.

◆ graph_add_item()

void graph_add_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size )

Add workflow item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.

◆ graph_add_loop_item()

void graph_add_loop_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size,
const size_t iterations )

Add workflow loop item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]iterationsNumber of loop iterations.

Add workflow loop item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]iterationsNumber of loop iterations.

◆ graph_add_post_converge_item()

void graph_add_post_converge_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size,
const double tol,
const size_t max_iter )

Add a post converge item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]tolTolerance to converge the function to.
[in]max_iterMaximum number of iterations before giving up.

◆ graph_add_post_copy_item()

void graph_add_post_copy_item ( STRUCT_TAG graph_c_context * c,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps )

Add a post copy item.

Parameters
[in]cThe graph C context.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.

◆ graph_add_post_item()

void graph_add_post_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size )

Add post workflow item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.

◆ graph_add_post_zero_item()

void graph_add_post_zero_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs )

Add a post zero item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.

◆ graph_add_pre_converge_item()

void graph_add_pre_converge_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size,
const double tol,
const size_t max_iter )

Add a pre converge item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]tolTolerance to converge the function to.
[in]max_iterMaximum number of iterations before giving up.

◆ graph_add_pre_copy_item()

void graph_add_pre_copy_item ( STRUCT_TAG graph_c_context * c,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps )

Add a pre copy item.

Parameters
[in]cThe graph C context.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.

◆ graph_add_pre_item()

void graph_add_pre_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size )

Add pre workflow item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.

◆ graph_add_pre_loop_item()

void graph_add_pre_loop_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs,
graph_node * outputs,
size_t num_outputs,
graph_node * map_inputs,
graph_node * map_outputs,
size_t num_maps,
graph_node * atomics,
size_t num_atomics,
graph_node random_state,
const char * name,
const size_t size,
const size_t iterations )

Add pre loop workflow item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]iterationsNumber of loop iterations.

Add pre loop workflow item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.
[in]outputsArray of output nodes.
[in]num_outputsNumber of outputs.
[in]map_inputsArray of map input nodes.
[in]map_outputsArray of map output nodes.
[in]num_mapsNumber of maps.
[in]atomicsArray of atomic nodes.
[in]num_atomicsNumber of atomics.
[in]random_stateOptional random state, can be NULL if not used.
[in]nameName for the kernel.
[in]sizeNumber of elements to operate on.
[in]iterationsNumber of loop iterations.

◆ graph_add_pre_zero_item()

void graph_add_pre_zero_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs )

Add a pre zero item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.

◆ graph_add_zero_item()

void graph_add_zero_item ( STRUCT_TAG graph_c_context * c,
graph_node * inputs,
size_t num_inputs )

Add a copy item.

Parameters
[in]cThe graph C context.
[in]inputsArray of input nodes.
[in]num_inputsNumber of inputs.

◆ graph_and()

graph_node graph_and ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create an and node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left && right

◆ graph_atan()

graph_node graph_atan ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create arctangent node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
atan(left, right)

◆ graph_atomic_accumulate_1D()

graph_node graph_atomic_accumulate_1D ( STRUCT_TAG graph_c_context * c,
graph_node variable,
graph_node index,
const double scale,
const double offset,
graph_node arg )

Create an atomic accumulate 1D index.

Parameters
[in]cThe graph C context.
[in]variableThe variable to index.
[in]indexThe function argument.
[in]scaleScale factor argument.
[in]offsetOffset factor argument.
[in]argArgument.
Returns
An atomic accumulate 1D node.

◆ graph_compile()

void graph_compile ( STRUCT_TAG graph_c_context * c)

Compile the work items.

Parameters
[in]cThe graph C context.

◆ graph_constant()

graph_node graph_constant ( STRUCT_TAG graph_c_context * c,
const double value )

Create constant node.

Parameters
[in]cThe graph C context.
[in]valueThe value to create the constant.
Returns
The created constant.

◆ graph_constant_c()

graph_node graph_constant_c ( STRUCT_TAG graph_c_context * c,
const double real_value,
const double img_value )

Create complex constant node.

Parameters
[in]cThe graph C context.
[in]real_valueThe real component.
[in]img_valueThe imaginary component.
Returns
The complex constant.

◆ graph_construct_context()

STRUCT_TAG graph_c_context * graph_construct_context ( const enum graph_type type,
const bool use_safe_math )

Construct a C context.

Parameters
[in]typeBase type.
[in]use_safe_mathControl is safe math is used.
Returns
A constructed C context.
Parameters
[in]typeBase type.
[in]use_safe_mathControl is safe math is used.
Returns
A contructed C context.

◆ graph_copy_to_device()

void graph_copy_to_device ( STRUCT_TAG graph_c_context * c,
graph_node node,
void * source )

Copy data to a device buffer.

Parameters
[in]cThe graph C context.
[in]nodeNode to copy to.
[in]sourceSource to copy from.

◆ graph_copy_to_host()

void graph_copy_to_host ( STRUCT_TAG graph_c_context * c,
graph_node node,
void * destination )

Copy data to a host buffer.

Parameters
[in]cThe graph C context.
[in]nodeNode to copy from.
[in]destinationHost side buffer to copy to.

◆ graph_cos()

Create cosine node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
sin(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
cos(arg)

◆ graph_destroy_context()

void graph_destroy_context ( STRUCT_TAG graph_c_context * c)

Destroy C context.

Parameters
[in,out]cThe c context to delete.

◆ graph_df()

graph_node graph_df ( STRUCT_TAG graph_c_context * c,
graph_node fnode,
graph_node xnode )

Take derivative ∂f∂x.

Parameters
[in]cThe graph C context.
[in]fnodeThe function expression to take the derivative of.
[in]xnodeThe expression to take the derivative with respect to.

◆ graph_div()

graph_node graph_div ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create Divide node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left/right

◆ graph_equal()

graph_node graph_equal ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create an equal node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left == right

◆ graph_erfi()

graph_node graph_erfi ( STRUCT_TAG graph_c_context * c,
graph_node arg )

Create imaginary error function node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
erfi(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
erfi(arg)

◆ graph_exp()

Create exp node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
exp(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
exp(arg)

◆ graph_get_max_concurrency()

size_t graph_get_max_concurrency ( STRUCT_TAG graph_c_context * c)

Create 2D piecewise node with complex arguments.

Parameters
[in]cThe graph C context.
Returns
The number of concurrent devices.

◆ graph_greater_than()

graph_node graph_greater_than ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create a greater than node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left > right

◆ graph_greater_than_equal()

graph_node graph_greater_than_equal ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create a greater than equal node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left >= right

◆ graph_if()

Create a if node.

Parameters
[in]cThe graph C context.
[in]conditionThe logical condition.
[in]tThe true case.
[in]fThe false case.
Returns
condiiton ? t : f

◆ graph_index()

Create an index code.

Parameters
[in]cThe graph C context.
Returns
An index node.

◆ graph_index_1D()

graph_node graph_index_1D ( STRUCT_TAG graph_c_context * c,
graph_node variable,
graph_node arg,
const double scale,
const double offset )

Create a 1D index.

Parameters
[in]cThe graph C context.
[in]variableThe variable to index.
[in]argThe function argument.
[in]scaleScale factor argument.
[in]offsetOffset factor argument.
Returns
A 1D index node.
Parameters
[in]cThe graph C context.
[in]variableThe variable to index.
[in]argThe function x argument.
[in]scaleScale factor x argument.
[in]offsetOffset factor x argument.
Returns
A 1D index node.

◆ graph_index_2D()

graph_node graph_index_2D ( STRUCT_TAG graph_c_context * c,
graph_node variable,
const size_t num_cols,
graph_node x_arg,
const double x_scale,
const double x_offset,
graph_node y_arg,
const double y_scale,
const double y_offset )

Create a 2D index.

Parameters
[in]cThe graph C context.
[in]variableThe variable to index.
[in]num_colsNumber of columns.
[in]x_argThe function x argument.
[in]x_scaleScale factor x argument.
[in]x_offsetOffset factor x argument.
[in]y_argThe function y argument.
[in]y_scaleScale factor y argument.
[in]y_offsetOffset factor y argument.
Returns
A 2D index node.

◆ graph_less_than()

graph_node graph_less_than ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create a less than node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left < right

◆ graph_less_than_equal()

graph_node graph_less_than_equal ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create a less than node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left <= right

◆ graph_log()

Create log node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
log(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
log(arg)

◆ graph_mul()

graph_node graph_mul ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create Multiply node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left*right

◆ graph_not()

Create not node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
!arg

◆ graph_not_equal()

graph_node graph_not_equal ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create a not equal node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left != right

◆ graph_or()

graph_node graph_or ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create an or node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left || right

◆ graph_piecewise_1D()

graph_node graph_piecewise_1D ( STRUCT_TAG graph_c_context * c,
graph_node arg,
const double scale,
const double offset,
const void * source,
const size_t source_size )

Create 1D piecewise node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
[in]scaleScale factor argument.
[in]offsetOffset factor argument.
[in]sourceSource buffer to fill elements.
[in]source_sizeNumber of elements in the source buffer.
Returns
A 1D piecewise node.

◆ graph_piecewise_2D()

graph_node graph_piecewise_2D ( STRUCT_TAG graph_c_context * c,
const size_t num_cols,
graph_node x_arg,
const double x_scale,
const double x_offset,
graph_node y_arg,
const double y_scale,
const double y_offset,
const void * source,
const size_t source_size )

Create 2D piecewise node.

Parameters
[in]cThe graph C context.
[in]num_colsNumber of columns.
[in]x_argThe function x argument.
[in]x_scaleScale factor x argument.
[in]x_offsetOffset factor x argument.
[in]y_argThe function y argument.
[in]y_scaleScale factor y argument.
[in]y_offsetOffset factor y argument.
[in]sourceSource buffer to fill elements.
[in]source_sizeNumber of elements in the source buffer.
Returns
A 2D piecewise node.

◆ graph_post_run()

void graph_post_run ( STRUCT_TAG graph_c_context * c)

Run post work items.

Parameters
[in]cThe graph C context.

◆ graph_pow()

graph_node graph_pow ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create Pow node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
pow(left, right)

◆ graph_pre_run()

void graph_pre_run ( STRUCT_TAG graph_c_context * c)

Run pre work items.

Parameters
[in]cThe graph C context.

◆ graph_print()

void graph_print ( STRUCT_TAG graph_c_context * c,
const size_t index,
graph_node * nodes,
const size_t num_nodes )

Print a value from nodes.

Parameters
[in]cThe graph C context.
[in]indexParticle index to print.
[in]nodesNodes to print.
[in]num_nodesNumber of nodes.

◆ graph_pseudo_variable()

graph_node graph_pseudo_variable ( STRUCT_TAG graph_c_context * c,
graph_node var )

Create a pseudo variable.

Parameters
[in]cThe graph C context.
[in]varThe variable to set.
Returns
The pseudo variable.
Parameters
[in]cThe graph C context.
[in]varThe variable to set.
Returns
THe pseudo variable.

◆ graph_random()

graph_node graph_random ( STRUCT_TAG graph_c_context * c,
graph_node arg )

Create random node.

Parameters
[in]cThe graph C context.
[in]stateA random state node.
Returns
random(state)
Parameters
[in]cThe graph C context.
[in]argA random state node.
Returns
random(state)

◆ graph_random_state()

graph_node graph_random_state ( STRUCT_TAG graph_c_context * c,
const size_t size,
const uint32_t seed )

Construct a random state node.

Parameters
[in]cThe graph C context.
[in]sizeThe number of randoms needed.
[in]seedInitial random seed.
Returns
A random state node.
Parameters
[in]cThe graph C context.
[in]sizeThe number of randoms needed.
[in]seedIntial random seed.
Returns
A random state node.

◆ graph_remove_pseudo()

graph_node graph_remove_pseudo ( STRUCT_TAG graph_c_context * c,
graph_node var )

Remove pseudo.

Parameters
[in]cThe graph C context.
[in]varThe graph to remove pseudo variables.
Returns
The graph with pseudo variables removed.
Parameters
[in]cThe graph C context.
[in]varThe variable to set.
Returns
The graph with pseudo variables removed.

◆ graph_run()

void graph_run ( STRUCT_TAG graph_c_context * c)

Run work items.

Parameters
[in]cThe graph C context.

◆ graph_set_device_number()

void graph_set_device_number ( STRUCT_TAG graph_c_context * c,
const size_t num )

Choose the device number.

Parameters
[in]cThe graph C context.
[in]numThe device number.

◆ graph_set_variable()

void graph_set_variable ( STRUCT_TAG graph_c_context * c,
graph_node var,
const void * source )

Set a variable value.

Parameters
[in]cThe graph C context.
[in]varThe variable to set.
[in]sourceThe source pointer.

◆ graph_sin()

Create sine node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
sin(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
sin(arg)

◆ graph_sqrt()

graph_node graph_sqrt ( STRUCT_TAG graph_c_context * c,
graph_node arg )

Create Sqrt node.

Parameters
[in]cThe graph C context.
[in]argThe function argument.
Returns
sqrt(arg)
Parameters
[in]cThe graph C context.
[in]argThe left operand.
Returns
sqrt(arg)

◆ graph_sub()

graph_node graph_sub ( STRUCT_TAG graph_c_context * c,
graph_node left,
graph_node right )

Create Subtract node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left - right

Create Subtract node.

Parameters
[in]cThe graph C context.
[in]leftThe left operand.
[in]rightThe right operand.
Returns
left - right

◆ graph_variable()

graph_node graph_variable ( STRUCT_TAG graph_c_context * c,
const size_t size,
const char * symbol )

Create variable node.

Parameters
[in]cThe graph C context.
[in]sizeSize of the data buffer.
[in]symbolSymbol of the variable used in equations.
Returns
The created variable.

◆ graph_wait()

void graph_wait ( STRUCT_TAG graph_c_context * c)

Wait for work items to complete.

Parameters
[in]cThe graph C context.