Jump to content
Alaba

Large system simulation problem

Recommended Posts

Hello there,

I'm building a system that includes a large number of resistors.  I used  sc_vector  of elements and nodes, as I increase the number of resistors I get segmentation error.

The below example is a simpler form  of my code that also gives the same error  

 

In the code below if I use small value of N:

( N=10000):  I get the right result 

but for N=1048576:  //(large N)

I get: Segmentation fault (core dumped) 

 

------------------------------------------------------resistors in series module----------------

//            p-    r0-r1-r2-r3...rN   -n

 static const int N=1048576;
  
    sca_eln::sca_terminal n;
    sca_eln::sca_terminal p;
   
    sc_vector< sca_eln::sca_node > c_vec{"c_vec", N };  //nodes beteen resistors  
    sc_vector<sca_eln::sca_r>     rs_vec{"rs_vec",   N  };  

SC_CTOR(rmatnn):  
                            
       p("p"),n("n") // 
                
      {

    rs_vec[0].p(p); //connect  p  port of first resistor to main p port 
    rs_vec[0].n(c_vec[0]); //connect n port of first resistor to nod 0
    rs_vec[0 ].value=10;
    
    for (int i = 1; i < N-1;  i++) {
      rs_vec[i ].p(c_vec[i-1]);
      rs_vec[i ].n(c_vec[i]);
      rs_vec[i ].value=10;
          }
     rs_vec[N-1 ].p(c_vec[N-2]);
     rs_vec[N-1 ].n(n);
         rs_vec[N-1 ].value=10;
        } 
      };

Is there any limitations on the number of modules we use  for the simulation??

Thanks in advance 

 

Share this post


Link to post
Share on other sites

There is no real limitation except the available memory. Each resistor is a SystemC module which allocates some memory due the sc_module members.

I guess SystemC and SystemC AMS does not check always, that memory could be allocated - thus you get the segfault.

You can try a computer with more memory or try to setup the equation manually- for a resistive network this should be some lines of c code only - if you have inductors or capacitors you can use the state space or Ltf objects.

Share this post


Link to post
Share on other sites
12 hours ago, karsten said:

There is no real limitation except the available memory. Each resistor is a SystemC module which allocates some memory due the sc_module members.

I guess SystemC and SystemC AMS does not check always, that memory could be allocated - thus you get the segfault.

You can try a computer with more memory or try to setup the equation manually- for a resistive network this should be some lines of c code only - if you have inductors or capacitors you can use the state space or Ltf objects.

I get same problem for same value of N with system of 32GB RAM and 8GB Ram 

Share this post


Link to post
Share on other sites

I just saw, that it looks like you instantiate the modules statically. You may run into the OS stack size limitation. Allocate the modules/vectors dynamically (using new) may solves the problem (or at least increases the possible size).

May you can try similiar like this (not checked):

    sc_vector< sca_eln::sca_node >* c_vec;  //nodes beteen resistors  
    sc_vector<sca_eln::sca_r>*     rs_vec;  

SC_CTOR(rmatnn):  
                            
       p("p"),n("n") // 
                
      {

c_vec=new sc_vector< sca_eln::sca_node >("c_vec", N );

rs_vec=new sc_vector<sca_eln::sca_r>("rs_vec",   N  );

 ...
      };

 

what are the shell messages before the segfault?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×