This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

XLARGE memory model & generale performance

Hello community,

Using C166 / ST10 with last version of IDE (µVision V4.00a / C166 V7.00 / L166 V5.25)
We need between 100 & 200Kb data (composed of many structures / array), so we set XLARGE memory model.

General questions about this use :
Is it the best way ?
What's approximately the loss in code execution performance ?
Shall we must use the x... functions to prevent some bug from standard lib with segment boundary (e.g. xmemcpy from string.h) ?
Is there an other solution, because it's non standard functions ?

Thanks in advance.
JM

  • We need between 100 & 200Kb data (composed of many structures / array), so we set XLARGE memory model.

    That doesn't seem like sound reasoning. It's almost always preferrable to use the smallest possible memory model, then flag individual big variables (or types that are use for those) to go into the bigger memory space until it all fits just so.

    One argument supporting that strategy is that access to big objects already tends to carry most or all of the overhead coming with using large memory spaces anyway, so there's little extra price to pay for storing them there.

  • Hi HS,

    Thanks for your answer !
    Indeed it seems to be the best way, but do you have any idea about the performance ratio between XLARGE & HLARGE ?

    Which is the right instantiation for a xhuge structure ?

    typedef struct _MY_STRUCT
    {
       unsigned char *ptrArray;
       unsigned char array[128Kb];
    }MY_STRUCT;
    
    MY_STRUCT xhuge myStruct;
    


    or

    typedef struct _MY_STRUCT
    {
       unsigned char xhuge *ptrArray;
       unsigned char xhuge array[128Kb];
    }MY_STRUCT;
    
    MY_STRUCT xhuge myStruct;
    

    ptr should be set on all array

    BR,
    JM

  • Which is the right instantiation for a xhuge structure ?

    That's not the question you should be asking, given those examples. Those are two different structures, with different element types. They don't differ in instantiation --- they differ in content.

  • OK, I precise my question :

    MY_STRUCT xhuge myStruct;
    

    => instantiate myStruct and store it in XDATA

    unsigned char xhuge *ptrArray;
    

    => is a member of myStruct, so is stored in XDATA, and defined as 32bits address calculation. Able to browse all the memory !

    unsigned char array[128Kb];
    

    => is a member of myStruct, so is stored in XDATA. xhuge is not necessary ??

    I'm right ?

  • is a member of myStruct, so is stored in XDATA. xhuge is not necessary ??

    Indeed. Generally speaking, memory class specifiers on members of structs would be pointless, and therefore are usually forbidden. They wouldn't work anyway: a member must inherit the memory class of the struct. Otherwise struct members would not be consequtive in memory, as required by the language. The same holds for 'const' qualification, BTW. You can't have const members in non-const structures, nor the other way round.

    The memory space qualifiers on pointers' target types are an entirely different matter, obviously.

  • Thanks !

    And about performance ratio between xhuge and huge or far variable (stored in the same physical memory) ? Any idea ?