├── .gitignore ├── image ├── logo.png ├── meta.png ├── cpp-task.png ├── demo_dag.png ├── demo_meta.png ├── dispatch.png ├── demo_meta_a.png ├── demo_meta_b.png └── demo_thread_data.png ├── .vscode ├── settings.json └── launch.json ├── test ├── main.cpp ├── test_find_index.cpp ├── test_type_id.cpp ├── test_executor.cpp ├── test_node.cpp ├── test_register_node.cpp ├── test_invoke_ex.cpp └── test_data_meta.cpp ├── .gitmodules ├── include ├── gparallel.h ├── executor.h ├── meta.h ├── util.h ├── glist.h ├── node_deduce.h ├── type_id.h ├── invoke_ex.h ├── node_schema.h ├── meta_decorator.h └── dag_schema.h ├── src ├── util.cpp ├── debug.cpp └── dag_schema.cpp ├── .travis.yml ├── CMakeLists.txt ├── demo └── advprocess.cpp ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/logo.png -------------------------------------------------------------------------------- /image/meta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/meta.png -------------------------------------------------------------------------------- /image/cpp-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/cpp-task.png -------------------------------------------------------------------------------- /image/demo_dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/demo_dag.png -------------------------------------------------------------------------------- /image/demo_meta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/demo_meta.png -------------------------------------------------------------------------------- /image/dispatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/dispatch.png -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools" 3 | } -------------------------------------------------------------------------------- /image/demo_meta_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/demo_meta_a.png -------------------------------------------------------------------------------- /image/demo_meta_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/demo_meta_b.png -------------------------------------------------------------------------------- /image/demo_thread_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/galois-advertising/gparallel/HEAD/image/demo_thread_data.png -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | int main(int argc, char **argv) 6 | { 7 | ::testing::InitGoogleTest(&argc, argv); 8 | return RUN_ALL_TESTS(); 9 | } -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common"] 2 | path = common 3 | url = https://github.com/galois-advertising/common 4 | branch = master 5 | [submodule "gtest"] 6 | path = gtest 7 | url = https://github.com/google/googletest.git -------------------------------------------------------------------------------- /include/gparallel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "dag_schema.h" 3 | #include "glist.h" 4 | #include "invoke_ex.h" 5 | #include "meta.h" 6 | #include "meta_decorator.h" 7 | #include "node_deduce.h" 8 | #include "executor.h" 9 | #include "node_schema.h" 10 | #include "type_id.h" 11 | #include "util.h" 12 | #include "gparallel.h" 13 | #include "log.h" -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "(lldb) gparalled", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${workspaceRoot}/build/gparallel", 9 | "args": [""], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceRoot}", 12 | "environment": [], 13 | "externalConsole": true, 14 | "MIMode": "lldb" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /test/test_find_index.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include "gparallel.h" 6 | #include "log.h" 7 | 8 | struct AA { 9 | std::string* data; 10 | AA(std::string* a) : data(a) {} 11 | }; 12 | 13 | TEST(Test, find_index) { 14 | using namespace galois::gparallel; 15 | ASSERT_EQ((find_index::index), 0); 16 | ASSERT_EQ((find_index::index), 2); 17 | ASSERT_EQ((find_index::index), 2); 18 | } -------------------------------------------------------------------------------- /test/test_type_id.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "type_id.h" 4 | struct test_tag_1 {}; 5 | struct test_tag_2 {}; 6 | TEST(Test, typeid) { 7 | using namespace galois::gparallel; 8 | std::cout<::instance().id()<::instance().name()<::instance().id()<::instance().name()<::instance().id()<::instance().name()< 4 | #include "invoke_ex.h" 5 | 6 | namespace galois::gparallel { 7 | template 8 | using executable_t = std::function; 9 | 10 | template 11 | class executor { 12 | private: 13 | static bool invoke(process_t fn, meta_storage_t* storage) { 14 | invoke_ex(fn, storage); 15 | return true; 16 | } 17 | public: 18 | static executable_t create(process_t process) { 19 | return std::bind(&invoke, process, std::placeholders::_1); 20 | } 21 | }; 22 | 23 | 24 | }; -------------------------------------------------------------------------------- /test/test_executor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "gparallel.h" 5 | using namespace galois::gparallel; 6 | 7 | struct base {}; 8 | 9 | DECL_META(A, base) { 10 | }; 11 | 12 | DECL_META(B, base, A) { 13 | }; 14 | 15 | DECL_META(C, base) { 16 | }; 17 | 18 | struct Process 19 | { 20 | static void process(input a, input b, output c) { 21 | TRACE("[gparallel] process succeed", ""); 22 | }; 23 | }; 24 | 25 | TEST(Test, executor) { 26 | using namespace galois::gparallel; 27 | base b; 28 | auto exe = executor::create(Process::process); 29 | exe(&b); 30 | 31 | } -------------------------------------------------------------------------------- /src/util.cpp: -------------------------------------------------------------------------------- 1 | // solopointer1202@gmail.com 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "util.h" 8 | #include "type_id.h" 9 | 10 | namespace galois::gparallel { 11 | #ifdef __GNUG__ 12 | #include 13 | #include 14 | // see https://stackoverflow.com/questions/281818/unmangling-the-result-of-stdtype-infoname 15 | std::string demangle(const char* name) { 16 | int status = -4; // some arbitrary value to eliminate the compiler warning 17 | // enable c++11 by passing the flag -std=c++11 to g++ 18 | std::unique_ptr res { 19 | abi::__cxa_demangle(name, NULL, NULL, &status), 20 | std::free 21 | }; 22 | return (status==0) ? res.get() : name ; 23 | } 24 | #else 25 | // does nothing if not g++ 26 | std::string demangle(const char* name) { 27 | return name; 28 | } 29 | #endif 30 | 31 | } -------------------------------------------------------------------------------- /include/meta.h: -------------------------------------------------------------------------------- 1 | // solopointer1202@gmail.com 2 | #pragma once 3 | #include "util.h" 4 | #include "log.h" 5 | 6 | namespace galois::gparallel { 7 | 8 | template class _meta_name, 10 | template class... _super_meta_names> 11 | struct meta_traits : public T { 12 | typedef meta_info_t<_meta_storage_t, _meta_name, _super_meta_names...> meta_info; 13 | typedef _meta_storage_t meta_storage_t; 14 | }; 15 | #define DECL_META(meta_name, meta_storage_t, super_meta_names...) template \ 16 | struct meta_name : public meta_traits 17 | // DECL_MEAT(MetaName, MetaType, OtherMetaName...) 18 | // MetaName[getters, setters] -> meta_traits[meta_info, meta_storage_t] -> auto_type 19 | // `data_meta_name` is essentially a T. 20 | // Between `data_meta_name` and T, there a meta_traits 21 | // for describe: 22 | // 1. Other data_meta_names which it depends. 23 | // 2. Type of this data_meta 24 | } -------------------------------------------------------------------------------- /test/test_node.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "gparallel.h" 5 | using namespace galois::gparallel; 6 | 7 | struct base {}; 8 | 9 | DECL_META(A, base) { 10 | }; 11 | 12 | DECL_META(B, base, A) { 13 | }; 14 | 15 | DECL_META(C, base, B) { 16 | }; 17 | 18 | DECL_META(D, base, A, B, C) { 19 | }; 20 | 21 | struct Process 22 | { 23 | int process(input a, input b, output c, output d) 24 | { 25 | return 0; 26 | }; 27 | }; 28 | 29 | #define SHOW(_name) \ 30 | printf(#_name"\n");\ 31 | for (auto & a : _name) {\ 32 | printf("\tkey:[%d] id:[%d] type:[%d] name:[%s]\n", \ 33 | a.first, a.second.id, a.second.type, \ 34 | typeid_manager::instance().name(a.second.id).c_str());\ 35 | }\ 36 | 37 | TEST(Test, deduce_depends) { 38 | using namespace galois::gparallel; 39 | io_description vec; 40 | deduce_depends::deduce(vec); 41 | SHOW(vec.input); 42 | SHOW(vec.output); 43 | ASSERT_EQ(vec.input.size(), 3); 44 | ASSERT_EQ(vec.output.size(), 2); 45 | } -------------------------------------------------------------------------------- /test/test_register_node.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "gparallel.h" 6 | using namespace galois::gparallel; 7 | 8 | struct base {}; 9 | DECL_META(MetaB, base) {}; 10 | 11 | DECL_META(MetaC, base) {}; 12 | 13 | DECL_META(MetaA, base, MetaC) {}; 14 | 15 | DECL_META(MetaD, base) {}; 16 | 17 | DECL_META(MetaE, base, MetaD) {}; 18 | 19 | struct NodeA 20 | { 21 | static int process(input b) { return 0; } 22 | }; 23 | 24 | struct NodeB 25 | { 26 | static int process(input a, output b) { return 0; } 27 | }; 28 | 29 | struct NodeC 30 | { 31 | static int process(output c) { return 0; } 32 | }; 33 | 34 | struct NodeD 35 | { 36 | static int process(input b, input c, output d) { return 0; } 37 | }; 38 | 39 | struct NodeE 40 | { 41 | static int process(output e) { return 0; } 42 | }; 43 | 44 | TEST(Test, register_node) { 45 | using namespace galois::gparallel; 46 | dag_schema nodes; 47 | register_node::reg(nodes); 48 | ASSERT_EQ(setup_dag_schema(nodes), true); 49 | } 50 | -------------------------------------------------------------------------------- /test/test_invoke_ex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "invoke_ex.h" 3 | #include 4 | 5 | struct A{int value=1;}; 6 | struct B{int value=2;}; 7 | struct C{int value=3;}; 8 | struct D{int value=4;}; 9 | struct E{int value=5;}; 10 | 11 | int fn(A a, B b, C c, D d) 12 | { 13 | std::cout< 2 | #include 3 | #include 4 | #include 5 | #include "gparallel.h" 6 | using namespace galois::gparallel; 7 | struct thread_data { 8 | int AAA_storage = 0; 9 | int AAB_storage = 0; 10 | int AAC_storage = 0; 11 | 12 | int ABA_storage = 0; 13 | int ABB_storage = 0; 14 | int ABC_storage = 0; 15 | 16 | int ACA_storage = 0; 17 | int ACB_storage = 0; 18 | int ACC_storage = 0; 19 | 20 | int AA_storage = 0; 21 | int AB_storage = 0; 22 | int AC_storage = 0; 23 | 24 | int A_storage = 0; 25 | thread_data(int a) {} 26 | }; 27 | 28 | DECL_META(m_aaa, thread_data){ 29 | const int & AAA_storage() const { return this->data->AAA_storage;} 30 | }; 31 | 32 | DECL_META(m_aab, thread_data){}; 33 | DECL_META(m_aac, thread_data){}; 34 | DECL_META(m_aa, thread_data, m_aaa, m_aab, m_aac){}; 35 | 36 | DECL_META(m_aba, thread_data){}; 37 | DECL_META(m_abb, thread_data){}; 38 | DECL_META(m_abc, thread_data){}; 39 | DECL_META(m_ab, thread_data, m_aba, m_abb, m_abc){}; 40 | 41 | DECL_META(m_aca, thread_data){}; 42 | DECL_META(m_acb, thread_data){}; 43 | DECL_META(m_acc, thread_data){}; 44 | DECL_META(m_ac, thread_data, m_aca, m_acb, m_acc){}; 45 | 46 | DECL_META(m_a, thread_data, m_aa, m_ab, m_ac){}; 47 | 48 | TEST(Test, meta_deduce) { 49 | using namespace galois::gparallel; 50 | io_description deps; 51 | input::meta_imp_t::deduce(deps); 52 | thread_data td(1); 53 | input input_a(&td); 54 | } -------------------------------------------------------------------------------- /include/util.h: -------------------------------------------------------------------------------- 1 | // solopointer1202@gmail.com 2 | #pragma once 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "type_id.h" 11 | 12 | namespace galois::gparallel { 13 | 14 | struct none_type {}; 15 | struct auto_type {}; 16 | 17 | 18 | std::string demangle(const char* name); 19 | 20 | enum class parameter_type { 21 | NONE = 0, INPUT, OUTPUT 22 | }; 23 | 24 | enum class meta_level_t { 25 | NONE = 0, ITEM, QUERY 26 | }; 27 | 28 | struct io_item { 29 | int id; 30 | meta_level_t meta_level; 31 | parameter_type type; 32 | }; 33 | 34 | typedef std::map node_io_map; 35 | typedef std::vector node_io_vec; 36 | struct io_description { 37 | node_io_map input; 38 | node_io_map output; 39 | }; 40 | template class... MS> struct meta_info_t {}; 41 | template