Low Level Shared Memory Library

This section under construction.

typedef enum {
  SMEM_DEV_P2,       /* Locate the block anywhere in P2 memory */
  SMEM_DEV_P2_VRAM,  /* Locate the block in P2 VRAM memory */
  SMEM_DEV_P2_SRAM,  /* Locate the block in P2 SRAM memory */
  SMEM_DEV_STATE_CPU,   /* Locate the block in State machine 603 SRAM */
  SMEM_DEV_STATE_FLEX,  /* Locate the block in State machine FLEX SRAM */
} smem_dev;

typedef enum {
  SMEM_PROC_P2,      /* resolve into the P2's address space */
  SMEM_PROC_STREAM,  /* resolve into the indicated stream proc's adr space. */
} smem_proc;

smem_id smem_create( unsigned long size, smem_class class, smem_dev type );
int smem_attach( smem_id seg );
int smem_mark_dependent()
void *smem_resolve_id( smem_id seg, smem_dev type, smem_proc who )
int smem_detach( smem_id seg );
int smem_clear_dependent( );
int smem_destroy( smem_id seg );

Example Application

This is a segment of code from the application, that builds the parameters.

  smem_id       sp_in_buf, sp_out_buf, sp_table_ref;
  parameter_st  pars;
  short         *sp_table;
  QueueElem     *frobQE;
  ...
  if((sp_in_buf = RmanCreate( sp_buf_size, SMEM_LOCAL )) == SMEM_ID_ERROR )
    signal_error();
  if((sp_out_buf = RmanCreate( sp_buf_size, SMEM_LOCAL )) == SMEM_ID_ERROR )
    signal_error();
  if((sp_table_ref = RmanCreate( sp_table_size, SMEM_CONST)) == SMEM_ID_ERROR )
    signal_error();
  if((sp_table = (short *)RmanAttach( sp_table_ref )) == NULL )
    signal_error();
  ...
  /*  Initialize the sp table here.  */
  ...
  /* now initialize the parameter struct  */
  pars.num_parameters = 5;    /*  the number of parameters  */
  pars.p[0].ul = buf_size;
  pars.p[1].f = scale;
  pars.p[2].m = sp_table_ref;
  pars.p[3].m = sp_in_buf;
  pars.p[4].m = sp_out_buf;
   /* set a bit for each parameter that is a shared memory segment */
  pars.shared_mem = SMEM_PARAM(2) | SMEM_PARAM( 3 ) | SMEM_PARAM( 4 );

  /* Build a queue element which contains the parameters.   */
  if( (frobQE = RmanSTMGenericTwoPhase( "frobname", "generic_flood",
                                        &pars )) == NULL )
    signal_error();
  ...
  /* The structure including frobQE is passed to RmanExecute().  */

Inside the resource manager, once its dependecies (if any) have been cleared, the transfer is scheduled for execution. The shared memory management is handled by entirely by the resource manager, executing on the P2 local processor. In this particular example, the resource manager would check if any of the available state machine stream processors already had the "frobname" function loaded, or the "table" segment already resident, when choosing one for execution. If either is missing, it would allocate memory on the selected stream processor and copy the required data to the newly allocated memory.

The resource manager then replaces the memory segment id in the parameter structure with a pointer to the actual data in the stream processors address space. The desired state machine function would then be executed with the modified parameter set.

This is an example of how a state machine software routine would access its parameters :

void statemac_function( long buf_size, float scale, short *table,
                        short *input, short *output )
{
  ...
  ... = buf_size;    /* these args may just be called.  */
  ... = scale;
  ... = table[ ... ];
}


Jump to State Machine Software Overview
Jump to the State Machine Stream Processor
Jump to the Cheops Homepage
cheops-web@media.mit.edu
This is a "fix it yourself" page, located at ${CHEOPS_BASE}/WWW/statemac/software/low_smem.html