Problem with four parallel threads

Technical discussions around xCORE processors (e.g. xcore-200 & xcore.ai).
jagspaul
Experienced Member
Posts: 117
Joined: Tue Oct 18, 2011 3:28 pm

Problem with four parallel threads

Post by jagspaul »

I am making a project of RGB LED tile. Specification as following below

size:
FRAME_HEIGHT = 64
FRAME_WIDTH = 32
LED: RGB
Driver: MBI5024
Controller: XMOS L1
video source SD card


As I don’t have any L1 board having sufficient I/O so right now I am building this project on my XC-3 board. I will use core 0 and all other cores are idle.

I used four threads. Two for LED Driver, one for LED buffer and other one for SD card Video player.

When I used all the threads on Core 0 and build the project, it builds successfully without any error but practically system is not running. It is giving reading error on SD card thread. Please note that there is no coding error n SD card thread.

Code: Select all

int main(void)
{
  streaming chan c_led_data_out;
  chan c_led_data_in;
 



  par
  {
   

      on stdcore[0]: ledbuffer(c_led_data_in, c_led_data_out);

     

    on stdcore[0]: leddrive(c_led_data_out,
            p_led_out_r0, p_led_out_g0, p_led_out_b0, p_led_out_r1, p_led_out_g1, p_led_out_b1,
            p_led_out_addr, p_led_out_clk , p_led_out_ltch, p_led_out_oe ,
            b_led_clk, b_led_data, b_led_gsclk, b_ref);

   
    on stdcore[0]: sdServer(c_led_data_in);



  }
  return 0;
}


Constraint check for "stdcore[0]" (node "0", core 0):
  Stack available:   0x00005d5c,   used: 0x000055cc .  OKAY
  Threads available:          8,   used:          4 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          7 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[1]" (node "0", core 1):
  Stack available:   0x0000f06c,   used: 0x000000d4 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          1 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[2]" (node "0", core 2):
  Stack available:   0x0000ec84,   used: 0x000000d4 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          1 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[3]" (node "0", core 3):
  Stack available:   0x0000f06c,   used: 0x000000d4 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          1 .  OKAY
    Constraints checks PASSED.
Then I placed LED buffer thread on core 1 and build the project, it builds successfully without any error. And found the system is running fine.

Code: Select all

int main(void)
{
  streaming chan c_led_data_out;
  chan c_led_data_in;
 



  par
  {
   

      on stdcore[1]: ledbuffer(c_led_data_in, c_led_data_out);

     

    on stdcore[0]: leddrive(c_led_data_out,
            p_led_out_r0, p_led_out_g0, p_led_out_b0, p_led_out_r1, p_led_out_g1, p_led_out_b1,
            p_led_out_addr, p_led_out_clk , p_led_out_ltch, p_led_out_oe ,
            b_led_clk, b_led_data, b_led_gsclk, b_ref);

   
    on stdcore[0]: sdServer(c_led_data_in);



  }
  return 0;
}

Constraint check for "stdcore[0]" (node "0", core 0):
  Stack available:   0x00005e40,   used: 0x00003db0 .  OKAY
  Threads available:          8,   used:          3 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          5 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[1]" (node "0", core 1):
  Stack available:   0x0000ef38,   used: 0x00001814 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          3 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[2]" (node "0", core 2):
  Stack available:   0x0000ec84,   used: 0x000000d4 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          1 .  OKAY
    Constraints checks PASSED.
Constraint check for "stdcore[3]" (node "0", core 3):
  Stack available:   0x0000f06c,   used: 0x000000d4 .  OKAY
  Threads available:          8,   used:          1 .  OKAY
  Timers available:          10,   used:          1 .  OKAY
  Chanends available:        32,   used:          1 .  OKAY
    Constraints checks PASSED.
My question is why Core 0 is not doing well when running four threads, where as it is running well with three threads.

Regards
jags
Last edited by jagspaul on Tue Aug 21, 2012 10:24 am, edited 1 time in total.


User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

It might be a memory problem if you are dynamically allocating a lot of RAM.That means defining large arrays inside sub routines. This happens at run time so the compiler can't be sure of it. You can try moving all the large variables out to being global so they are allocated for when compiling or try reducing the size of a buffer.
jagspaul
Experienced Member
Posts: 117
Joined: Tue Oct 18, 2011 3:28 pm

Post by jagspaul »

I have made all buffer as global even I reduced the size of tile 16x32 pixel but found no improvement. I think it is not memory issue.

Then I add this "set_thread_fast_mode_on();" code to ledbuffer(....) thread and found little improvement. It is getting error after reading more than 40 frames.
jagspaul
Experienced Member
Posts: 117
Joined: Tue Oct 18, 2011 3:28 pm

Post by jagspaul »

It is really strange.

I added "set_thread_fast_mode_on();" at ledbuffer() & sd_thread() and found it's working while all threads are on core 0.

Code: Select all

void sd_thread(chanend c_led_data_in)
{
	set_thread_fast_mode_on();
	sdServer(c_led_data_in);
}


void ledbuffer(chanend cIn, streaming chanend cOut)
{
...........
.........
..........

set_thread_fast_mode_on();

................
..................
............

}

int main(void)
{
  streaming chan c_led_data_out;
  chan c_led_data_in;
 

  par
  {
    

	on stdcore[0]: ledbuffer(c_led_data_in, c_led_data_out);
	
    on stdcore[0]: leddrive(c_led_data_out,
            p_led_out_r0, p_led_out_g0, p_led_out_b0, p_led_out_r1, p_led_out_g1, p_led_out_b1,
            p_led_out_addr, p_led_out_clk , p_led_out_ltch, p_led_out_oe ,
            b_led_clk, b_led_data, b_led_gsclk, b_ref);

       
    //on stdcore[0]: sdServer(c_led_data_in);
    on stdcore[0]: sd_thread(c_led_data_in);



  }
  return 0;
}
Can anybody Please explain this strange behavior.

Thanks
jags