Commit 3fd13a40 authored by Cianciosa, Mark's avatar Cianciosa, Mark
Browse files

Add an example for adding nodes. Add a default is_match. Add developer...

Add an example for adding nodes. Add a default is_match. Add developer documentation for dispersion, solvers, and absorption. Fix spelling of timing namespace. Fix cross references and formatting. Add tutorials for language bindings.
parent 3b3e963a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ void bench_runner() {
    const size_t batch = NUM_RAYS/threads.size();
    const size_t extra = NUM_RAYS%threads.size();

    timeing::measure_diagnostic_threaded time_setup("Setup Time");
    timeing::measure_diagnostic_threaded time_init("Init Time");
    timeing::measure_diagnostic_threaded time_compile("Compile Time");
    timeing::measure_diagnostic_threaded time_steps("Time Steps");
    timing::measure_diagnostic_threaded time_setup("Setup Time");
    timing::measure_diagnostic_threaded time_init("Init Time");
    timing::measure_diagnostic_threaded time_compile("Compile Time");
    timing::measure_diagnostic_threaded time_steps("Time Steps");

    for (size_t i = 0, ie = threads.size(); i < ie; i++) {
        threads[i] = std::thread([&time_setup, &time_init, &time_compile, &time_steps, batch, extra] (const size_t thread_number) -> void {
+105 −0
Original line number Diff line number Diff line
@@ -2,6 +2,111 @@
///  @file graph_c_binding.h
///  @brief Header file for the c binding library.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
///  @page graph_c_binding Embedding in C code
///  @brief Documentation for linking into a C code base.
///  @tableofcontents
///
///  @section graph_c_binding_into Introduction
///  This section assumes the reader is already familar with developing C codes.
///  The simplist method to link framework code into a C code is to create a c++
///  function with @code extern "C" @endcode First create a header file
///  <tt><i>c_callable</i>.h</tt>
///  @code
///  extern "C" {
///      void c_callable_function();
///  }
///  @endcode
///
///  Next create a source file <tt><i>c_callable</i>.c</tt> and add the
///  framework. This example uses the line
///  @ref tutorial_workflow "making workflows" turorial.
///  @code
///  //  Include the necessary framework headers.
///
///  extern "C" {
///      void c_callable_function() {
///          auto x = graph::variable(3, "x");
///
///  // Define explicit constant.
///          auto m = graph::constant<T> (0.4);
///  // Define implicit constant.
///          const T b = 0.6;
///
///  // Equation of a line
///          auto y = m*x + b;
///
///  // Auto differentiation.
///          auto dydx = y->df(x);
///
///          x->set({1.0, 2.0, 3.0});
///
///  // Create a workflow manager.
///          workflow::manager<T> work(0);
///          work.add_item({
///              graph::variable_cast(x)
///          }, {
///              y, dydx
///          }, {}, NULL, "my_first_kernel", 3);
///          work.compile();
///
///          work.run();
///          work.print(0, {x, y, dydx});
///          work.print(1, {x, y, dydx});
///          work.print(2, {x, y, dydx});
///      }
///  }
///  @endcode
///
///  <hr>
///  @section graph_c_binding_interface C Binding Interface
///  An alternative is to use the @ref graph_c_binding.h "C Language interface".
///  The C binding interface can be enabled as one of the <tt>cmake</tt>
///  @ref build_system_user_options "conifgure options". As an example, we will
///  convert the @ref tutorial_workflow "making workflows" turorial to use the
///  C language bindings.
///  @code
///  #include <graph_c_binding.h>
///
///  void c_binding() {
///      const bool use_safe_math = 0;
///      struct graph_c_context *c_context = graph_construct_context(DOUBLE, use_safe_math);
///      graph_node x = graph_variable(c_context, 3, "x");
///
///      graph_node m = graph_constant(c_context, 0.4);
///      graph_node b = graph_constant(c_context, 0.6);
///
///      graph_node y = graph_add(c_context, graph_mul(c_context, m, x), b);
///      graph_node dydx = graph_df(c_context, y, x);
///
///      double temp[3];
///      temp[0] = 1.0;
///      temp[1] = 2.0;
///      temp[2] = 3.0;
///      graoh_set_variable(c_context, x, temp);
///
///      graph_set_device_number(c_context, 0);
///      graph_node inputs[1];
///      inputs[0] = x;
///      graph_node outputs[2];
///      outputs[0] = y;
///      outputs[1] = dydx;
///      graph_add_item(c_context, inputs, 1, outputs, 2, NULL, NULL, 0, NULL,
///                     "x", 3);
///      graph_compile(c_context);
///      graph_run(c_context);
///      graph_node inputs2[3];
///      inputs2[0] = x;
///      inputs2[1] = y;
///      inputs2[2] = dydx;
///      graph_print(c_context, 0, inputs2, 3);
///      graph_print(c_context, 1, inputs2, 3);
///      graph_print(c_context, 2, inputs2, 3);
///
///      graph_destroy_context(c_context);
///  }
///  @endcode
//------------------------------------------------------------------------------

#ifndef graph_c_binding_h
#define graph_c_binding_h
+27 −0
Original line number Diff line number Diff line
/*!
 * @page code_structure Code Structure
 * @brief Architecture of the code base.
 * @tableofcontents
 *
 * @section code_structure_intro Introduction
 * This topic covers the structure of the framework and the structure of the RF
 * Ray tracing code <tt>xrays</tt>.
 *
 * @section code_structure_framework Framework
 * The namespaces of the graph framework are:
 * * @ref graph The operation nodes.
 * * @ref workflow The routines for executing graphs.
 * * @ref jit Generic interface for Just-In-Time compiling of the graphs.
 * * @ref backend Host side buffers and operations.
 * * @ref gpu Device drivers for CPU and the GPU.
 * * @ref timeing Routines for timing.
 * * @ref output Routines for loading and saving graph to Netcdf files.
 * * @ref commandline Routines for parsing command lines.
 *
 * @section code_structure_xrays Ray Tracing code
 * The namespaces of the Ray Tracing code are:
 * * @ref equilibrium Equilibrium models.
 * * @ref dispersion Dispersion functions.
 * * @ref solver PDE integration methods and optimization methods.
 * * @ref absorption The absorption models.
 */
+12 −3
Original line number Diff line number Diff line
@@ -39,10 +39,19 @@
 * * @ref build_system "Compiling the framework."
 * * @ref general_concepts "General concepts."
 * * @ref tutorial "Tutorial"
 * * @ref graph_c_binding
 * * @ref graph_fortran_binding
 *
 * <hr>
 * @section framework_developer Framework developer guides
 * * @ref build_system "Build system."
 * * Code structure
 * * Adding new operations tutorial.
 * * @ref build_system
 * * @ref code_structure
 * * @ref new_operations_tutorial
 *
 * @subsection framework_developer_tools Developer guide for RF Ray Tracing
 * * @ref code_structure_xrays "Code Structure"
 * * @ref equilibrum_devel
 * * @ref dispersion_function_devel
 * * @ref solvers_devel
 * * @ref absorption_model_devel
 */
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
 * @page tutorial Tutorial
 * @brief Hands on tutorial for building expressions and running workflow.
 * @tableofcontents
 *
 * @section tutorial_introduction Introduction
 * In this tutorial we will put the basic @ref general_concepts of the
 * graph_into action. This will discuss building trees, generating, and
@@ -155,7 +156,7 @@ auto dydb = y->df(m*x);
 * The respective results will be @f$x@f$, @f$1@f$, and @f$0@f$ respectively.
 *
 * <hr>
 * @section tutorial_workflow Making workflow.
 * @section tutorial_workflow Making workflows.
 * In this section we will build workflow from these nodes we created. For
 * simplicity we will decrease the number of elements in variable so we can set
 * the values easier. First thing we do is create a @ref workflow::manager.
Loading