Loading CMakeLists.txt +0 −1 Original line number Diff line number Diff line Loading @@ -212,7 +212,6 @@ add_dependencies (llvm-offload-resource-headers pull_llvm) add_dependencies (LLVMDemangle pull_llvm) add_dependencies (Remarks_exports pull_llvm) add_dependencies (LLVMSupportBlake3 pull_llvm) add_dependencies (BugpointPasses_exports pull_llvm) add_dependencies (LTO_exports pull_llvm) add_dependencies (llvm-PerfectShuffle pull_llvm) add_dependencies (SecondLib pull_llvm) Loading README.md +3 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,6 @@ For instructions to build the code consult the documentation. This framework uses a [cmake](https://cmake.org) based build system and requires the [NetCDF-C](https://www.unidata.ucar.edu/software/netcdf/) library. NOTE: macOS users will need to change the `CMAKE_CXX_COMPILER` to `clang++`. Otherwise the framework will not set the includes correctly for CPU JIT. graph_c_binding/graph_c_binding.cpp +144 −26 Original line number Diff line number Diff line Loading @@ -1681,32 +1681,138 @@ extern "C" { /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] arg The function x argument. /// @param[in] scale Scale factor x argument. /// @param[in] offset Offset factor x argument. /// @returns A 1D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, graph_node variable, graph_node arg, const double scale, const double offset) { switch (c->type) { case FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<float, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], static_cast<float> (scale), static_cast<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<float> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], static_cast<float> (scale), static_cast<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } case DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<double, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<double> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<float> (scale), std::complex<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<float> (scale), std::complex<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } case COMPLEX_DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<double> (scale), std::complex<double> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<double> (scale), std::complex<double> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } } } //------------------------------------------------------------------------------ /// @brief Create a 2D index. /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The function x argument. /// @param[in] x_scale Scale factor x argument. /// @param[in] x_offset Offset factor x argument. /// @returns A 1D index node. /// @param[in] y_arg The function y argument. /// @param[in] y_scale Scale factor y argument. /// @param[in] y_offset Offset factor y argument. /// @returns A 2D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, 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) { const double x_offset, graph_node y_arg, const double y_scale, const double y_offset) { switch (c->type) { case FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<float, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], static_cast<float> (x_scale), static_cast<float> (x_offset)); static_cast<float> (x_offset), d->nodes[y_arg], static_cast<float> (y_scale), static_cast<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<float> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], static_cast<float> (x_scale), static_cast<float> (x_offset)); static_cast<float> (x_offset), d->nodes[y_arg], static_cast<float> (y_scale), static_cast<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1714,16 +1820,16 @@ extern "C" { case DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<double, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[x_arg], x_scale, x_offset); auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], y_scale, y_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<double> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[x_arg], x_scale, x_offset); auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], y_scale, y_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1731,18 +1837,24 @@ extern "C" { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<float> (x_scale), std::complex<float> (x_offset)); std::complex<float> (x_offset), d->nodes[y_arg], std::complex<float> (y_scale), std::complex<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<float> (x_scale), std::complex<float> (x_offset)); std::complex<float> (x_offset), d->nodes[y_arg], std::complex<float> (y_scale), std::complex<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1750,18 +1862,24 @@ extern "C" { case COMPLEX_DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<double> (x_scale), std::complex<double> (x_offset)); std::complex<double> (x_offset), d->nodes[y_arg], std::complex<double> (y_scale), std::complex<double> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<double> (x_scale), std::complex<double> (x_offset)); std::complex<double> (x_offset), d->nodes[y_arg], std::complex<double> (y_scale), std::complex<double> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading graph_c_binding/graph_c_binding.h +30 −6 Original line number Diff line number Diff line Loading @@ -450,16 +450,40 @@ extern "C" { /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] arg The function argument. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @returns A 1D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, graph_node variable, graph_node arg, const double scale, const double offset); //------------------------------------------------------------------------------ /// @brief Create a 2D index. /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The function x argument. /// @param[in] x_scale Scale factor x argument. /// @param[in] x_offset Offset factor x argument. /// @returns A 1D index node. /// @param[in] y_arg The function y argument. /// @param[in] y_scale Scale factor y argument. /// @param[in] y_offset Offset factor y argument. /// @returns A 2D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, 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); const double x_offset, graph_node y_arg, const double y_scale, const double y_offset); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. Loading graph_driver/xrays.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ /// @param[in] mean Mean value. /// @param[in] sigma Sigma value. //------------------------------------------------------------------------------ template<typename T> template<jit::float_scalar T> std::normal_distribution<T> set_distribution(const T mean, const T sigma) { return std::normal_distribution<T> (mean, sigma); Loading @@ -35,7 +35,7 @@ std::normal_distribution<T> set_distribution(const T mean, /// @param[in] mean Mean value. /// @param[in] sigma Sigma value. //------------------------------------------------------------------------------ template<typename T> template<jit::float_scalar T> std::normal_distribution<std::complex<T>> set_distribution(const std::complex<T> mean, const std::complex<T> sigma) { return std::normal_distribution<T> (std::real(mean), std::real(sigma)); Loading @@ -53,7 +53,7 @@ std::normal_distribution<std::complex<T>> set_distribution(const std::complex<T> /// @param[in,out] engine Random engine. /// @param[in] num_rays Numbers of rays. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH> template<jit::float_scalar T, bool SAFE_MATH> void set_variable(const commandline::parser &cl, graph::shared_leaf<T, SAFE_MATH> var, const std::string &name, Loading Loading @@ -82,7 +82,7 @@ void set_variable(const commandline::parser &cl, /// @param[in,out] engine Random engine. /// @param[in] num_rays Numbers of rays. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH> template<jit::float_scalar T, bool SAFE_MATH> void set_xy_variables(const commandline::parser &cl, graph::shared_leaf<T, SAFE_MATH> x, graph::shared_leaf<T, SAFE_MATH> y, Loading Loading
CMakeLists.txt +0 −1 Original line number Diff line number Diff line Loading @@ -212,7 +212,6 @@ add_dependencies (llvm-offload-resource-headers pull_llvm) add_dependencies (LLVMDemangle pull_llvm) add_dependencies (Remarks_exports pull_llvm) add_dependencies (LLVMSupportBlake3 pull_llvm) add_dependencies (BugpointPasses_exports pull_llvm) add_dependencies (LTO_exports pull_llvm) add_dependencies (llvm-PerfectShuffle pull_llvm) add_dependencies (SecondLib pull_llvm) Loading
README.md +3 −0 Original line number Diff line number Diff line Loading @@ -40,3 +40,6 @@ For instructions to build the code consult the documentation. This framework uses a [cmake](https://cmake.org) based build system and requires the [NetCDF-C](https://www.unidata.ucar.edu/software/netcdf/) library. NOTE: macOS users will need to change the `CMAKE_CXX_COMPILER` to `clang++`. Otherwise the framework will not set the includes correctly for CPU JIT.
graph_c_binding/graph_c_binding.cpp +144 −26 Original line number Diff line number Diff line Loading @@ -1681,32 +1681,138 @@ extern "C" { /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] arg The function x argument. /// @param[in] scale Scale factor x argument. /// @param[in] offset Offset factor x argument. /// @returns A 1D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, graph_node variable, graph_node arg, const double scale, const double offset) { switch (c->type) { case FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<float, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], static_cast<float> (scale), static_cast<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<float> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], static_cast<float> (scale), static_cast<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } case DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<double, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<double> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<float> (scale), std::complex<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<float> (scale), std::complex<float> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } case COMPLEX_DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<double> (scale), std::complex<double> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[arg], std::complex<double> (scale), std::complex<double> (offset)); d->nodes[temp.get()] = temp; return temp.get(); } } } //------------------------------------------------------------------------------ /// @brief Create a 2D index. /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The function x argument. /// @param[in] x_scale Scale factor x argument. /// @param[in] x_offset Offset factor x argument. /// @returns A 1D index node. /// @param[in] y_arg The function y argument. /// @param[in] y_scale Scale factor y argument. /// @param[in] y_offset Offset factor y argument. /// @returns A 2D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, 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) { const double x_offset, graph_node y_arg, const double y_scale, const double y_offset) { switch (c->type) { case FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<float, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], static_cast<float> (x_scale), static_cast<float> (x_offset)); static_cast<float> (x_offset), d->nodes[y_arg], static_cast<float> (y_scale), static_cast<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<float> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], static_cast<float> (x_scale), static_cast<float> (x_offset)); static_cast<float> (x_offset), d->nodes[y_arg], static_cast<float> (y_scale), static_cast<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1714,16 +1820,16 @@ extern "C" { case DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<double, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[x_arg], x_scale, x_offset); auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], y_scale, y_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<double> *> (c); auto temp = graph::index_1D(d->nodes[variable], d->nodes[x_arg], x_scale, x_offset); auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], y_scale, y_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1731,18 +1837,24 @@ extern "C" { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<float> (x_scale), std::complex<float> (x_offset)); std::complex<float> (x_offset), d->nodes[y_arg], std::complex<float> (y_scale), std::complex<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<float> (x_scale), std::complex<float> (x_offset)); std::complex<float> (x_offset), d->nodes[y_arg], std::complex<float> (y_scale), std::complex<float> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading @@ -1750,18 +1862,24 @@ extern "C" { case COMPLEX_DOUBLE: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>, true> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<double> (x_scale), std::complex<double> (x_offset)); std::complex<double> (x_offset), d->nodes[y_arg], std::complex<double> (y_scale), std::complex<double> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); auto temp = graph::index_1D(d->nodes[variable], auto temp = graph::index_2D(d->nodes[variable], num_cols, d->nodes[x_arg], std::complex<double> (x_scale), std::complex<double> (x_offset)); std::complex<double> (x_offset), d->nodes[y_arg], std::complex<double> (y_scale), std::complex<double> (y_offset)); d->nodes[temp.get()] = temp; return temp.get(); } Loading
graph_c_binding/graph_c_binding.h +30 −6 Original line number Diff line number Diff line Loading @@ -450,16 +450,40 @@ extern "C" { /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] arg The function argument. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @returns A 1D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, graph_node variable, graph_node arg, const double scale, const double offset); //------------------------------------------------------------------------------ /// @brief Create a 2D index. /// /// @param[in] c The graph C context. /// @param[in] variable The variable to index. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The function x argument. /// @param[in] x_scale Scale factor x argument. /// @param[in] x_offset Offset factor x argument. /// @returns A 1D index node. /// @param[in] y_arg The function y argument. /// @param[in] y_scale Scale factor y argument. /// @param[in] y_offset Offset factor y argument. /// @returns A 2D index node. //------------------------------------------------------------------------------ graph_node graph_index_1D(STRUCT_TAG graph_c_context *c, 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); const double x_offset, graph_node y_arg, const double y_scale, const double y_offset); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. Loading
graph_driver/xrays.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ /// @param[in] mean Mean value. /// @param[in] sigma Sigma value. //------------------------------------------------------------------------------ template<typename T> template<jit::float_scalar T> std::normal_distribution<T> set_distribution(const T mean, const T sigma) { return std::normal_distribution<T> (mean, sigma); Loading @@ -35,7 +35,7 @@ std::normal_distribution<T> set_distribution(const T mean, /// @param[in] mean Mean value. /// @param[in] sigma Sigma value. //------------------------------------------------------------------------------ template<typename T> template<jit::float_scalar T> std::normal_distribution<std::complex<T>> set_distribution(const std::complex<T> mean, const std::complex<T> sigma) { return std::normal_distribution<T> (std::real(mean), std::real(sigma)); Loading @@ -53,7 +53,7 @@ std::normal_distribution<std::complex<T>> set_distribution(const std::complex<T> /// @param[in,out] engine Random engine. /// @param[in] num_rays Numbers of rays. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH> template<jit::float_scalar T, bool SAFE_MATH> void set_variable(const commandline::parser &cl, graph::shared_leaf<T, SAFE_MATH> var, const std::string &name, Loading Loading @@ -82,7 +82,7 @@ void set_variable(const commandline::parser &cl, /// @param[in,out] engine Random engine. /// @param[in] num_rays Numbers of rays. //------------------------------------------------------------------------------ template<typename T, bool SAFE_MATH> template<jit::float_scalar T, bool SAFE_MATH> void set_xy_variables(const commandline::parser &cl, graph::shared_leaf<T, SAFE_MATH> x, graph::shared_leaf<T, SAFE_MATH> y, Loading