.cpp code loading on more than one tile - two startkits

All technical discussions and projects around startKIT
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

.cpp code loading on more than one tile - two startkits

Postby mhanuel » Sat Jul 26, 2014 7:24 pm

Hello,

I have a couple of .cpp files on my project and I am facing the following problem. As I have a two startkit application, I already manage to compile my code but those .cpp are near 22K of memory and are loading on both tiles. I don't have any function call on my main code for those .cpp functions, that is, I have commented everything except my .cpp code and it still compiling on both tiles.

Is there anything I am missing with .cpp files. For port resources you use on tile[0] or tile[1], but for memory program as my better understanding is that compiler automatically load the code for your tile depending on which tile you are suppose to run that code, please correct if wrong.

I really will appreciate your help,

Best,
User avatar
TSC
Experienced Member
Posts: 99
Joined: Sun Mar 06, 2011 11:39 pm

Postby TSC » Sun Jul 27, 2014 2:59 am

What are your library definitions? Maybe that's what's causing the high memory usage.
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

Postby mhanuel » Sun Jul 27, 2014 4:12 am

Hello TSC,

I am using sc_sdcard (FatFs) and sc_spi library on those .cpp files. I thought FatFs could be the issue but I don't know how to deal with it. If I comment one of those .cpp the memory just goes down to around 2K, but my doubt is about why it loads into both tiles memories in the first place.
Do you have any idea of what could I do if this is due to a library inclusion.

Please let me know,

Thank you for your answer,
User avatar
TSC
Experienced Member
Posts: 99
Joined: Sun Mar 06, 2011 11:39 pm

Postby TSC » Sun Jul 27, 2014 4:33 am

I've never used a StartKit myself; let alone two of them interconnected. Hopefully someone else with more knowledge in this area can help you.
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

Postby mhanuel » Mon Jul 28, 2014 3:51 am

Thank you anyway TSC,

How can I have more control of what code goes into a given tile, I was looking at some magic pragma perhaps. I guess this is not only an issue of startkit, I mean the libraries I am using are made for other hardware platforms too, what I have my doubts is about .cpp compiler process.

Does someone with experience have any clue, I really don't understand why I am loading a given tile with code I am not running there.

Even if I just comment all my functions calls in main.xc file, there is a .cpp compiling into both tiles, isn't that strange or is a normal behavior, what am I missing?

I will appreciate your comments,
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Postby richard » Mon Jul 28, 2014 10:29 pm

mhanuel wrote:How can I have more control of what code goes into a given tile, I was looking at some magic pragma perhaps. I guess this is not only an issue of startkit, I mean the libraries I am using are made for other hardware platforms too, what I have my doubts is about .cpp compiler process.

Does someone with experience have any clue, I really don't understand why I am loading a given tile with code I am not running there.

Even if I just comment all my functions calls in main.xc file, there is a .cpp compiling into both tiles, isn't that strange or is a normal behavior, what am I missing?

I will appreciate your comments,
The tools would normally eliminate any code and data that is not used on a tile.

Something to bear in mind when using C++ is that if you have a global variable with a non-trivial constructor / destructor then that constructor will always be duplicated on all tiles. Even if the global is not referenced it is not safe for the tools to eliminate the call to the constructor / destructor as it might have arbitrary side effects. If the constructor / destructor is not eliminated then any code / data it transitively references will also not be eliminated. Might this explain what you are seeing?
mhanuel
Member++
Posts: 16
Joined: Mon Apr 07, 2014 3:15 am

Postby mhanuel » Tue Jul 29, 2014 3:41 am

Dear Richard,

Thank you for enlightening me, you were right, I change my code to encapsulate that variable in a single C++ thread. It was actually a global variable from a non trivial class constructor as you said

I am very appreciated with you. Thank you for the comments.

Best,

Who is online

Users browsing this forum: No registered users and 3 guests