Loading CMakeLists.txt +9 −1 Original line number Diff line number Diff line Loading @@ -344,6 +344,10 @@ macro (add_tool_target target) PUBLIC graph_framework ) if (${USE_PCH} AND ${BUILD_C_BINDING}) target_precompile_headers (${target} REUSE_FROM graph_c) endif () endmacro () add_subdirectory (graph_driver) Loading @@ -362,8 +366,12 @@ macro (add_test_target target) ) if (${USE_PCH}) if (${BUILD_C_BINDING}) target_precompile_headers (${target} REUSE_FROM graph_c) else () target_precompile_headers (${target} REUSE_FROM xrays) endif () endif () endmacro () add_subdirectory (graph_tests) graph_c_binding/graph_c_binding.cpp +8 −148 Original line number Diff line number Diff line Loading @@ -5,7 +5,13 @@ #include "graph_c_binding.h" #include "../graph_framework/register.hpp" #include "../graph_framework/node.hpp" #include "../graph_framework/workflow.hpp" #include "../graph_framework/arithmetic.hpp" #include "../graph_framework/math.hpp" #include "../graph_framework/trigonometry.hpp" #include "../graph_framework/piecewise.hpp" //------------------------------------------------------------------------------ /// @brief C context with specific type. Loading Loading @@ -76,9 +82,9 @@ extern "C" { //------------------------------------------------------------------------------ /// @brief Destroy C context. /// /// @param[inout] The c context to delete. /// @param[in,out] c The c context to delete. //------------------------------------------------------------------------------ void graph_destroy_node_flt(graph_c_context *c) { void graph_destroy_node(graph_c_context *c) { delete c; } Loading Loading @@ -1530,69 +1536,6 @@ extern "C" { } } //------------------------------------------------------------------------------ /// @brief Create 1D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] arg The left opperand. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 1D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_1D_c(graph_c_context *c, graph_node arg, const std::complex<double> scale, const std::complex<double> offset, const void *source, const size_t source_size) { switch (c->type) { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], static_cast<std::complex<float>> (scale), static_cast<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); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], static_cast<std::complex<float>> (scale), static_cast<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); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } case FLOAT: case DOUBLE: std::cerr << "Error: Context is non-complex." << std::endl; exit(1); } } //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node. /// Loading Loading @@ -1729,89 +1672,6 @@ extern "C" { } } //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The left opperand. /// @param[in] x_scale Scale factor argument. /// @param[in] x_offset Offset factor argument. /// @param[in] y_arg The left opperand. /// @param[in] y_scale Scale factor argument. /// @param[in] y_offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 2D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_2D_c(graph_c_context *c, const size_t num_cols, graph_node x_arg, const std::complex<double> x_scale, const std::complex<double> x_offset, graph_node y_arg, const std::complex<double> y_scale, const std::complex<double> y_offset, const void *source, const size_t source_size) { switch (c->type) { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], static_cast<std::complex<float>> (x_scale), static_cast<std::complex<float>> (x_offset), d->nodes[y_arg], static_cast<std::complex<float>> (y_scale), static_cast<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); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], static_cast<std::complex<float>> (x_scale), static_cast<std::complex<float>> (x_offset), d->nodes[y_arg], static_cast<std::complex<float>> (y_scale), static_cast<std::complex<float>> (y_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); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], x_scale, x_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<std::complex<double>> *> (c); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], x_scale, x_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } case FLOAT: case DOUBLE: std::cerr << "Error: Context is non-complex." << std::endl; exit(1); } } //****************************************************************************** // JIT //****************************************************************************** Loading graph_c_binding/graph_c_binding.h +5 −46 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ #ifndef graph_c_binding_h #define graph_c_binding_h #include <stddef.h> #include <stdint.h> extern "C" { /// Graph node type for C interface. typedef void * graph_node; Loading Loading @@ -43,9 +46,9 @@ extern "C" { //------------------------------------------------------------------------------ /// @brief Destroy C context. /// /// @param[inout] The c context to delete. /// @param[in,out] c The c context to delete. //------------------------------------------------------------------------------ void graph_destroy_node_flt(graph_c_context *c); void graph_destroy_node(graph_c_context *c); //------------------------------------------------------------------------------ /// @brief Create variable node. Loading Loading @@ -272,24 +275,6 @@ extern "C" { const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 1D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] arg The left opperand. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 1D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_1D_c(graph_c_context *c, graph_node arg, const std::complex<double> scale, const std::complex<double> offset, const void *source, const size_t source_size) ; //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node. /// Loading @@ -316,32 +301,6 @@ extern "C" { const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The left opperand. /// @param[in] x_scale Scale factor argument. /// @param[in] x_offset Offset factor argument. /// @param[in] y_arg The left opperand. /// @param[in] y_scale Scale factor argument. /// @param[in] y_offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 2D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_2D_c(graph_c_context *c, const size_t num_cols, graph_node x_arg, const std::complex<double> x_scale, const std::complex<double> x_offset, graph_node y_arg, const std::complex<double> y_scale, const std::complex<double> y_offset, const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// Loading graph_framework.xcodeproj/project.pbxproj +123 −3 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ C7B676082AA9023F005AB34C /* xrays_bench.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7B676072AA9023F005AB34C /* xrays_bench.cpp */; }; C7D12D9A2DBAB31F00925420 /* random.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C7D12D992DBAB31F00925420 /* random.hpp */; }; C7D371132A0595A40074676E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C71342682947F36100672AD4 /* Metal.framework */; }; C7DC9EEC2E39790100524F6F /* graph_c_binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */; }; C7E5644528A2A1AA000F31A2 /* backend_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E7328074F540033B488 /* backend_test.cpp */; }; C7E5645128A2A1DD000F31A2 /* dispersion_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E6B28073BCA0033B488 /* dispersion_test.cpp */; }; C7E5645D28A2A21D000F31A2 /* solver_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E6C28073BCA0033B488 /* solver_test.cpp */; }; Loading Loading @@ -149,6 +150,13 @@ remoteGlobalIDString = C79141A522DA9BF200E0BA0D; remoteInfo = graph_framework; }; C7DC9EED2E39791C00524F6F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C791419E22DA9BF200E0BA0D /* Project object */; proxyType = 1; remoteGlobalIDString = C79141A522DA9BF200E0BA0D; remoteInfo = graph_framework; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ Loading Loading @@ -378,6 +386,11 @@ C7CEA0052948EB0F00F61D09 /* cuda_context.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = cuda_context.hpp; sourceTree = "<group>"; }; C7D12D992DBAB31F00925420 /* random.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = random.hpp; sourceTree = "<group>"; }; C7D3C5B02C654AD3008AD8C6 /* efit_test.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = efit_test.cpp; sourceTree = "<group>"; }; C7DC9EE02E39768300524F6F /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; C7DC9EE12E39768300524F6F /* graph_c_binding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = graph_c_binding.h; sourceTree = "<group>"; }; C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = graph_c_binding.cpp; sourceTree = "<group>"; }; C7DC9EE82E39789900524F6F /* libgraph_c.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgraph_c.a; sourceTree = BUILT_PRODUCTS_DIR; }; C7DC9EEF2E397BE600524F6F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; C7E134492A3CB3EC0083F6A7 /* output.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = output.hpp; sourceTree = "<group>"; }; C7E5643E28A2A16F000F31A2 /* backend_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = backend_test; sourceTree = BUILT_PRODUCTS_DIR; }; C7E5644A28A2A1C5000F31A2 /* dispersion_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dispersion_test; sourceTree = BUILT_PRODUCTS_DIR; }; Loading Loading @@ -470,6 +483,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE62E39789900524F6F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; C7E5643B28A2A16F000F31A2 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; Loading Loading @@ -542,6 +562,7 @@ C71342672947F36100672AD4 /* Frameworks */ = { isa = PBXGroup; children = ( C7DC9EEF2E397BE600524F6F /* Cocoa.framework */, C71342682947F36100672AD4 /* Metal.framework */, ); name = Frameworks; Loading Loading @@ -598,6 +619,7 @@ C7931E7228073BFC0033B488 /* CMakeLists.txt */, C79141AD22DA9C0600E0BA0D /* graph_framework */, C7931E6928073BCA0033B488 /* graph_tests */, C7DC9EE32E39768300524F6F /* graph_c_binding */, C79141B422DAAD0C00E0BA0D /* graph_driver */, C74DF4582AA8BC7300319113 /* graph_benchmark */, C736E6B02C9B52CA00AAE3C0 /* graph_playground */, Loading Loading @@ -631,6 +653,7 @@ C736E6A42C9B526500AAE3C0 /* graph_playground */, C78F3D8F2DC41ACA002E3D94 /* random_test */, C78F3D9D2DC41B26002E3D94 /* graph_korc */, C7DC9EE82E39789900524F6F /* libgraph_c.a */, ); name = Products; sourceTree = "<group>"; Loading Loading @@ -698,6 +721,16 @@ path = graph_tests; sourceTree = "<group>"; }; C7DC9EE32E39768300524F6F /* graph_c_binding */ = { isa = PBXGroup; children = ( C7DC9EE02E39768300524F6F /* CMakeLists.txt */, C7DC9EE12E39768300524F6F /* graph_c_binding.h */, C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */, ); path = graph_c_binding; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ Loading Loading @@ -728,6 +761,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE42E39789900524F6F /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ Loading Loading @@ -911,6 +951,26 @@ productReference = C79141B322DAAD0C00E0BA0D /* graph_driver */; productType = "com.apple.product-type.tool"; }; C7DC9EE72E39789900524F6F /* graph_c */ = { isa = PBXNativeTarget; buildConfigurationList = C7DC9EE92E39789900524F6F /* Build configuration list for PBXNativeTarget "graph_c" */; buildPhases = ( C7DC9EE42E39789900524F6F /* Headers */, C7DC9EE52E39789900524F6F /* Sources */, C7DC9EE62E39789900524F6F /* Frameworks */, ); buildRules = ( ); dependencies = ( C7DC9EEE2E39791C00524F6F /* PBXTargetDependency */, ); name = graph_c; packageProductDependencies = ( ); productName = graph_c; productReference = C7DC9EE82E39789900524F6F /* libgraph_c.a */; productType = "com.apple.product-type.library.static"; }; C7E5643D28A2A16F000F31A2 /* backend_test */ = { isa = PBXNativeTarget; buildConfigurationList = C7E5644228A2A16F000F31A2 /* Build configuration list for PBXNativeTarget "backend_test" */; Loading Loading @@ -1080,7 +1140,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1540; LastUpgradeCheck = 1640; ORGANIZATIONNAME = "Cianciosa, Mark R."; TargetAttributes = { C7170CB82C66A10D003274E2 = { Loading Loading @@ -1113,6 +1173,9 @@ C79141B222DAAD0C00E0BA0D = { CreatedOnToolsVersion = 10.2.1; }; C7DC9EE72E39789900524F6F = { CreatedOnToolsVersion = 16.4; }; C7E5643D28A2A16F000F31A2 = { CreatedOnToolsVersion = 13.4; }; Loading Loading @@ -1174,6 +1237,7 @@ C736E6A32C9B526500AAE3C0 /* graph_playground */, C78F3D8E2DC41ACA002E3D94 /* random_test */, C78F3D9C2DC41B26002E3D94 /* graph_korc */, C7DC9EE72E39789900524F6F /* graph_c */, ); }; /* End PBXProject section */ Loading Loading @@ -1258,6 +1322,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE52E39789900524F6F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( C7DC9EEC2E39790100524F6F /* graph_c_binding.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; C7E5643A28A2A16F000F31A2 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; Loading Loading @@ -1398,6 +1470,11 @@ target = C79141A522DA9BF200E0BA0D /* graph_framework */; targetProxy = C74DF47B2AA8BD6600319113 /* PBXContainerItemProxy */; }; C7DC9EEE2E39791C00524F6F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C79141A522DA9BF200E0BA0D /* graph_framework */; targetProxy = C7DC9EED2E39791C00524F6F /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ Loading Loading @@ -1715,7 +1792,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = c17; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; Loading Loading @@ -1889,7 +1966,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = c17; GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "EFIT_FILE=\\\"/Users/m4c/Projects/graph_framework/graph_tests/efit.nc\\\"", Loading Loading @@ -2085,6 +2162,40 @@ }; name = Release; }; C7DC9EEA2E39789900524F6F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; EXECUTABLE_PREFIX = lib; GCC_C_LANGUAGE_STANDARD = gnu23; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 15.5; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Debug; }; C7DC9EEB2E39789900524F6F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; EXECUTABLE_PREFIX = lib; GCC_C_LANGUAGE_STANDARD = gnu23; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 15.5; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Release; }; C7E5644328A2A16F000F31A2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { Loading Loading @@ -2438,6 +2549,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C7DC9EE92E39789900524F6F /* Build configuration list for PBXNativeTarget "graph_c" */ = { isa = XCConfigurationList; buildConfigurations = ( C7DC9EEA2E39789900524F6F /* Debug */, C7DC9EEB2E39789900524F6F /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C7E5644228A2A16F000F31A2 /* Build configuration list for PBXNativeTarget "backend_test" */ = { isa = XCConfigurationList; buildConfigurations = ( Loading graph_framework.xcodeproj/xcshareddata/xcschemes/arithmetic_test.xcscheme +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <Scheme LastUpgradeVersion = "1540" LastUpgradeVersion = "1640" version = "1.7"> <BuildAction parallelizeBuildables = "YES" Loading Loading
CMakeLists.txt +9 −1 Original line number Diff line number Diff line Loading @@ -344,6 +344,10 @@ macro (add_tool_target target) PUBLIC graph_framework ) if (${USE_PCH} AND ${BUILD_C_BINDING}) target_precompile_headers (${target} REUSE_FROM graph_c) endif () endmacro () add_subdirectory (graph_driver) Loading @@ -362,8 +366,12 @@ macro (add_test_target target) ) if (${USE_PCH}) if (${BUILD_C_BINDING}) target_precompile_headers (${target} REUSE_FROM graph_c) else () target_precompile_headers (${target} REUSE_FROM xrays) endif () endif () endmacro () add_subdirectory (graph_tests)
graph_c_binding/graph_c_binding.cpp +8 −148 Original line number Diff line number Diff line Loading @@ -5,7 +5,13 @@ #include "graph_c_binding.h" #include "../graph_framework/register.hpp" #include "../graph_framework/node.hpp" #include "../graph_framework/workflow.hpp" #include "../graph_framework/arithmetic.hpp" #include "../graph_framework/math.hpp" #include "../graph_framework/trigonometry.hpp" #include "../graph_framework/piecewise.hpp" //------------------------------------------------------------------------------ /// @brief C context with specific type. Loading Loading @@ -76,9 +82,9 @@ extern "C" { //------------------------------------------------------------------------------ /// @brief Destroy C context. /// /// @param[inout] The c context to delete. /// @param[in,out] c The c context to delete. //------------------------------------------------------------------------------ void graph_destroy_node_flt(graph_c_context *c) { void graph_destroy_node(graph_c_context *c) { delete c; } Loading Loading @@ -1530,69 +1536,6 @@ extern "C" { } } //------------------------------------------------------------------------------ /// @brief Create 1D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] arg The left opperand. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 1D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_1D_c(graph_c_context *c, graph_node arg, const std::complex<double> scale, const std::complex<double> offset, const void *source, const size_t source_size) { switch (c->type) { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], static_cast<std::complex<float>> (scale), static_cast<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); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], static_cast<std::complex<float>> (scale), static_cast<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); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } else { auto d = reinterpret_cast<graph_c_context_type<std::complex<double>> *> (c); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_1D(buffer, d->nodes[arg], scale, offset); d->nodes[temp.get()] = temp; return temp.get(); } case FLOAT: case DOUBLE: std::cerr << "Error: Context is non-complex." << std::endl; exit(1); } } //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node. /// Loading Loading @@ -1729,89 +1672,6 @@ extern "C" { } } //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The left opperand. /// @param[in] x_scale Scale factor argument. /// @param[in] x_offset Offset factor argument. /// @param[in] y_arg The left opperand. /// @param[in] y_scale Scale factor argument. /// @param[in] y_offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 2D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_2D_c(graph_c_context *c, const size_t num_cols, graph_node x_arg, const std::complex<double> x_scale, const std::complex<double> x_offset, graph_node y_arg, const std::complex<double> y_scale, const std::complex<double> y_offset, const void *source, const size_t source_size) { switch (c->type) { case COMPLEX_FLOAT: if (c->safe_math) { auto d = reinterpret_cast<graph_c_context_type<std::complex<float>, true> *> (c); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], static_cast<std::complex<float>> (x_scale), static_cast<std::complex<float>> (x_offset), d->nodes[y_arg], static_cast<std::complex<float>> (y_scale), static_cast<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); backend::buffer<std::complex<float>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<float>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], static_cast<std::complex<float>> (x_scale), static_cast<std::complex<float>> (x_offset), d->nodes[y_arg], static_cast<std::complex<float>> (y_scale), static_cast<std::complex<float>> (y_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); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], x_scale, x_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<std::complex<double>> *> (c); backend::buffer<std::complex<double>> buffer(source_size); std::memcpy(buffer.data(), source, sizeof(std::complex<double>)*source_size); auto temp = graph::piecewise_2D(buffer, num_cols, d->nodes[x_arg], x_scale, x_offset, d->nodes[y_arg], y_scale, y_offset); d->nodes[temp.get()] = temp; return temp.get(); } case FLOAT: case DOUBLE: std::cerr << "Error: Context is non-complex." << std::endl; exit(1); } } //****************************************************************************** // JIT //****************************************************************************** Loading
graph_c_binding/graph_c_binding.h +5 −46 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ #ifndef graph_c_binding_h #define graph_c_binding_h #include <stddef.h> #include <stdint.h> extern "C" { /// Graph node type for C interface. typedef void * graph_node; Loading Loading @@ -43,9 +46,9 @@ extern "C" { //------------------------------------------------------------------------------ /// @brief Destroy C context. /// /// @param[inout] The c context to delete. /// @param[in,out] c The c context to delete. //------------------------------------------------------------------------------ void graph_destroy_node_flt(graph_c_context *c); void graph_destroy_node(graph_c_context *c); //------------------------------------------------------------------------------ /// @brief Create variable node. Loading Loading @@ -272,24 +275,6 @@ extern "C" { const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 1D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] arg The left opperand. /// @param[in] scale Scale factor argument. /// @param[in] offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 1D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_1D_c(graph_c_context *c, graph_node arg, const std::complex<double> scale, const std::complex<double> offset, const void *source, const size_t source_size) ; //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node. /// Loading @@ -316,32 +301,6 @@ extern "C" { const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// /// @param[in] c The graph C context. /// @param[in] num_cols Number of columns. /// @param[in] x_arg The left opperand. /// @param[in] x_scale Scale factor argument. /// @param[in] x_offset Offset factor argument. /// @param[in] y_arg The left opperand. /// @param[in] y_scale Scale factor argument. /// @param[in] y_offset Offset factor argument. /// @param[in] source Source buffer to fill elements. /// @param[in] source_size Number of elements in the source buffer. /// @returns A 2D piecewise node. //------------------------------------------------------------------------------ graph_node graph_create_piecewise_2D_c(graph_c_context *c, const size_t num_cols, graph_node x_arg, const std::complex<double> x_scale, const std::complex<double> x_offset, graph_node y_arg, const std::complex<double> y_scale, const std::complex<double> y_offset, const void *source, const size_t source_size); //------------------------------------------------------------------------------ /// @brief Create 2D piecewise node with complex arguments. /// Loading
graph_framework.xcodeproj/project.pbxproj +123 −3 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ C7B676082AA9023F005AB34C /* xrays_bench.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7B676072AA9023F005AB34C /* xrays_bench.cpp */; }; C7D12D9A2DBAB31F00925420 /* random.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C7D12D992DBAB31F00925420 /* random.hpp */; }; C7D371132A0595A40074676E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C71342682947F36100672AD4 /* Metal.framework */; }; C7DC9EEC2E39790100524F6F /* graph_c_binding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */; }; C7E5644528A2A1AA000F31A2 /* backend_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E7328074F540033B488 /* backend_test.cpp */; }; C7E5645128A2A1DD000F31A2 /* dispersion_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E6B28073BCA0033B488 /* dispersion_test.cpp */; }; C7E5645D28A2A21D000F31A2 /* solver_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C7931E6C28073BCA0033B488 /* solver_test.cpp */; }; Loading Loading @@ -149,6 +150,13 @@ remoteGlobalIDString = C79141A522DA9BF200E0BA0D; remoteInfo = graph_framework; }; C7DC9EED2E39791C00524F6F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C791419E22DA9BF200E0BA0D /* Project object */; proxyType = 1; remoteGlobalIDString = C79141A522DA9BF200E0BA0D; remoteInfo = graph_framework; }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ Loading Loading @@ -378,6 +386,11 @@ C7CEA0052948EB0F00F61D09 /* cuda_context.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = cuda_context.hpp; sourceTree = "<group>"; }; C7D12D992DBAB31F00925420 /* random.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = random.hpp; sourceTree = "<group>"; }; C7D3C5B02C654AD3008AD8C6 /* efit_test.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = efit_test.cpp; sourceTree = "<group>"; }; C7DC9EE02E39768300524F6F /* CMakeLists.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; C7DC9EE12E39768300524F6F /* graph_c_binding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = graph_c_binding.h; sourceTree = "<group>"; }; C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = graph_c_binding.cpp; sourceTree = "<group>"; }; C7DC9EE82E39789900524F6F /* libgraph_c.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgraph_c.a; sourceTree = BUILT_PRODUCTS_DIR; }; C7DC9EEF2E397BE600524F6F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; C7E134492A3CB3EC0083F6A7 /* output.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = output.hpp; sourceTree = "<group>"; }; C7E5643E28A2A16F000F31A2 /* backend_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = backend_test; sourceTree = BUILT_PRODUCTS_DIR; }; C7E5644A28A2A1C5000F31A2 /* dispersion_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dispersion_test; sourceTree = BUILT_PRODUCTS_DIR; }; Loading Loading @@ -470,6 +483,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE62E39789900524F6F /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; C7E5643B28A2A16F000F31A2 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; Loading Loading @@ -542,6 +562,7 @@ C71342672947F36100672AD4 /* Frameworks */ = { isa = PBXGroup; children = ( C7DC9EEF2E397BE600524F6F /* Cocoa.framework */, C71342682947F36100672AD4 /* Metal.framework */, ); name = Frameworks; Loading Loading @@ -598,6 +619,7 @@ C7931E7228073BFC0033B488 /* CMakeLists.txt */, C79141AD22DA9C0600E0BA0D /* graph_framework */, C7931E6928073BCA0033B488 /* graph_tests */, C7DC9EE32E39768300524F6F /* graph_c_binding */, C79141B422DAAD0C00E0BA0D /* graph_driver */, C74DF4582AA8BC7300319113 /* graph_benchmark */, C736E6B02C9B52CA00AAE3C0 /* graph_playground */, Loading Loading @@ -631,6 +653,7 @@ C736E6A42C9B526500AAE3C0 /* graph_playground */, C78F3D8F2DC41ACA002E3D94 /* random_test */, C78F3D9D2DC41B26002E3D94 /* graph_korc */, C7DC9EE82E39789900524F6F /* libgraph_c.a */, ); name = Products; sourceTree = "<group>"; Loading Loading @@ -698,6 +721,16 @@ path = graph_tests; sourceTree = "<group>"; }; C7DC9EE32E39768300524F6F /* graph_c_binding */ = { isa = PBXGroup; children = ( C7DC9EE02E39768300524F6F /* CMakeLists.txt */, C7DC9EE12E39768300524F6F /* graph_c_binding.h */, C7DC9EE22E39768300524F6F /* graph_c_binding.cpp */, ); path = graph_c_binding; sourceTree = "<group>"; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ Loading Loading @@ -728,6 +761,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE42E39789900524F6F /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ Loading Loading @@ -911,6 +951,26 @@ productReference = C79141B322DAAD0C00E0BA0D /* graph_driver */; productType = "com.apple.product-type.tool"; }; C7DC9EE72E39789900524F6F /* graph_c */ = { isa = PBXNativeTarget; buildConfigurationList = C7DC9EE92E39789900524F6F /* Build configuration list for PBXNativeTarget "graph_c" */; buildPhases = ( C7DC9EE42E39789900524F6F /* Headers */, C7DC9EE52E39789900524F6F /* Sources */, C7DC9EE62E39789900524F6F /* Frameworks */, ); buildRules = ( ); dependencies = ( C7DC9EEE2E39791C00524F6F /* PBXTargetDependency */, ); name = graph_c; packageProductDependencies = ( ); productName = graph_c; productReference = C7DC9EE82E39789900524F6F /* libgraph_c.a */; productType = "com.apple.product-type.library.static"; }; C7E5643D28A2A16F000F31A2 /* backend_test */ = { isa = PBXNativeTarget; buildConfigurationList = C7E5644228A2A16F000F31A2 /* Build configuration list for PBXNativeTarget "backend_test" */; Loading Loading @@ -1080,7 +1140,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 1540; LastUpgradeCheck = 1640; ORGANIZATIONNAME = "Cianciosa, Mark R."; TargetAttributes = { C7170CB82C66A10D003274E2 = { Loading Loading @@ -1113,6 +1173,9 @@ C79141B222DAAD0C00E0BA0D = { CreatedOnToolsVersion = 10.2.1; }; C7DC9EE72E39789900524F6F = { CreatedOnToolsVersion = 16.4; }; C7E5643D28A2A16F000F31A2 = { CreatedOnToolsVersion = 13.4; }; Loading Loading @@ -1174,6 +1237,7 @@ C736E6A32C9B526500AAE3C0 /* graph_playground */, C78F3D8E2DC41ACA002E3D94 /* random_test */, C78F3D9C2DC41B26002E3D94 /* graph_korc */, C7DC9EE72E39789900524F6F /* graph_c */, ); }; /* End PBXProject section */ Loading Loading @@ -1258,6 +1322,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; C7DC9EE52E39789900524F6F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( C7DC9EEC2E39790100524F6F /* graph_c_binding.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; C7E5643A28A2A16F000F31A2 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; Loading Loading @@ -1398,6 +1470,11 @@ target = C79141A522DA9BF200E0BA0D /* graph_framework */; targetProxy = C74DF47B2AA8BD6600319113 /* PBXContainerItemProxy */; }; C7DC9EEE2E39791C00524F6F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C79141A522DA9BF200E0BA0D /* graph_framework */; targetProxy = C7DC9EED2E39791C00524F6F /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ Loading Loading @@ -1715,7 +1792,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = c17; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; Loading Loading @@ -1889,7 +1966,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = c17; GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = ( "EFIT_FILE=\\\"/Users/m4c/Projects/graph_framework/graph_tests/efit.nc\\\"", Loading Loading @@ -2085,6 +2162,40 @@ }; name = Release; }; C7DC9EEA2E39789900524F6F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; EXECUTABLE_PREFIX = lib; GCC_C_LANGUAGE_STANDARD = gnu23; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 15.5; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Debug; }; C7DC9EEB2E39789900524F6F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CODE_SIGN_STYLE = Automatic; EXECUTABLE_PREFIX = lib; GCC_C_LANGUAGE_STANDARD = gnu23; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MACOSX_DEPLOYMENT_TARGET = 15.5; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; }; name = Release; }; C7E5644328A2A16F000F31A2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { Loading Loading @@ -2438,6 +2549,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C7DC9EE92E39789900524F6F /* Build configuration list for PBXNativeTarget "graph_c" */ = { isa = XCConfigurationList; buildConfigurations = ( C7DC9EEA2E39789900524F6F /* Debug */, C7DC9EEB2E39789900524F6F /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; C7E5644228A2A16F000F31A2 /* Build configuration list for PBXNativeTarget "backend_test" */ = { isa = XCConfigurationList; buildConfigurations = ( Loading
graph_framework.xcodeproj/xcshareddata/xcschemes/arithmetic_test.xcscheme +1 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <Scheme LastUpgradeVersion = "1540" LastUpgradeVersion = "1640" version = "1.7"> <BuildAction parallelizeBuildables = "YES" Loading