FNC_Where_Am_I Function | C Library Functions | Teradata Vantage - FNC_Where_Am_I - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantageā„¢

Provides information about the specific node ID, vproc ID, vproc type, and task ID for the currently running external routine. This is useful if an external routine organizes GLOP data according to where it is invoked from.

Returns a pointer to a Vproc_Info_t structure.

Syntax

Vproc_Info_t *
FNC_Where_Am_I (void);
Vproc_Info_t
typdedef struct
{
   unsigned short NumAMPs;
   unsigned short NumPEs;
   unsigned short NodeId;
   unsigned short VprocId;
   vproc_type     Vtype;
} Vproc_Info_t;

Syntax Elements

NumAMPs
Number of online AMPs in the system.
NumPEs
Number of PEs in the system.
NodeId
Unique number of the node.
VprocId
Unique number of the vproc.
Vtype
Type of vproc, where the vproc_type enumeration is defined as:
typedef enum
{
   UNK_VPROC = 0    /* vproc type unknown */
   AMP_VPROC = 1,   /* AMP vproc */
   PE_VPROC = 2     /* PE vproc */
} vproc_type;

Usage Notes

FNC_Where_Am_I provides information on the number vprocs of each type (AMP and PE), and what node, vproc, and type of vproc the external routine is running on. An external routine can use FNC_Where_Am_I to help configure GLOP data that might require a different set up when executing on a PE instead of an AMP or data that might need to be divided up based on the number of AMP vprocs for a global copy operation.

Example Using FNC_Where_Am_I

Here is a code excerpt that shows how an external routine might use FNC_Where_Am_I to find out what processor type it is executing on and only process transaction-related GLOP changes if it is running on an AMP.

#define TRAN_MAP  0
Sysinfo_t     SysInfoPtr;
GLOP_Map_t   *MyGLOP;
Vproc_Info_t *MyVproc_info;
int           glop_stat;

   . . .

 MyVproc_info = FNC_Where_Am_I(); 

/* only bother with GLOP map if we are running on an AMP */
if (MyVproc->Vtype == AMP_VPROC)
{
   glop_stat = FNC_Get_GLOP_Map(&MyGLOP);

   if (glop_stat)
      ... process error: Not a member of any GLOP set
   if ( MyGLOP->GLOP[TRAN_MAP].GLOP_Ptr == NULL)
   {
      ... process error: Transaction GLOP does not exist
   };
   SysInfoPtr = MyGLOP->GLOP[TRAN_MAP].GLOP_ptr;

   . . .

}
else
{
   /* do non AMP processing here */
}