Khushi Posted January 29, 2019 Report Posted January 29, 2019 Hi How can I count the number of SC_THREAD/SC_METHOD in a given simulation of a SystemC platform ? Is it possible ? Thanks Khushi Quote
Roman Popov Posted January 29, 2019 Report Posted January 29, 2019 25 minutes ago, Khushi said: How can I count the number of SC_THREAD/SC_METHOD in a given simulation of a SystemC platform ? Is it possible ? int n_methods = 0; int n_threads = 0; int n_cthreads = 0; void count_procs_recursive(sc_object * parent) { if (std::string ( parent->kind() ) == "sc_method_process" ) n_methods++; if (std::string(parent->kind()) == "sc_thread_process") n_threads++; if (std::string(parent->kind()) == "sc_cthread_process") n_cthreads++; for (sc_object * child : parent->get_child_objects()) { count_procs_recursive(child); } } void before_end_of_elaboration() override { for (sc_object * obj : sc_get_top_level_objects()) { count_procs_recursive(obj); } cout << "n_methods = " << n_methods << "\n"; cout << "n_threads = " << n_threads << "\n"; cout << "n_cthreads = " << n_cthreads << "\n"; } ( Not tested. ) Quote
David Black Posted January 29, 2019 Report Posted January 29, 2019 Caveat: That is the number of statically allocated processes. It does not account for dynamic threads or processes (i.e. sc_spawn'ed), which would be more difficult to track. Mind you, it is pretty complete and most likely static is what you are after. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.