Jump to content

Recommended Posts

Posted
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. )

Posted

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.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...