#include <mpl.h>
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	int * addr;		/* base address of array */
	int   rank;		/* rank of array */
        int   onDPU;		/* if base address is FE or BE */
	int   extents[7];	/* extents of the array */
} DopeVector;

extern void mpl_sgemm1( 
#ifdef __STDMPL__
int, int, int, float, plural float *, plural float *, plural float *
#endif
  );
MPL_SGEMM1 ( fe, be )
    int * fe[];        /*  FE(vax) address of FE(vax) arguments */
    DopeVector * be[]; /* a BE(acu) address of BE(acu) dopevectors */
  {
    int * var1;
    int   dpuVar1;
    int * var2;
    int   dpuVar2;
    int * var3;
    int   dpuVar3;
    float * var4;
    float   dpuVar4;
    plural float  * var5;
    plural float    dpuVar5;
    plural float  * var6;
    plural float    dpuVar6;
    plural float  * var7;
    plural float    dpuVar7;
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var1 = &dpuVar1;
        copyIn( (char*)(fe+1), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var1), sizeof(*var1));
        else 
          {
            fprintf(stderr, "Error in MPL_SGEMM1.m : No address to FE argument 1 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var2 = &dpuVar2;
        copyIn( (char*)(fe+2), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var2), sizeof(*var2));
        else 
          {
            fprintf(stderr, "Error in MPL_SGEMM1.m : No address to FE argument 2 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        int * ptr;
        var3 = &dpuVar3;
        copyIn( (char*)(fe+3), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var3), sizeof(*var3));
        else 
          {
            fprintf(stderr, "Error in MPL_SGEMM1.m : No address to FE argument 3 \n");
            exit(1); 
          }
      }
      
      /* copy in scalar argument from front-end */
      {
        float * ptr;
        var4 = &dpuVar4;
        copyIn( (char*)(fe+4), (char*)(&ptr), sizeof(ptr));
        if (ptr) 
           copyIn( (char*)(ptr),(char*)(var4), sizeof(*var4));
        else 
          {
            fprintf(stderr, "Error in MPL_SGEMM1.m : No address to FE argument 4 \n");
            exit(1); 
          }
      }
      
    if (be[5]->onDPU) 
      var5 = (plural float  *)be[5]->addr;
    else  /* Arrays must be on DPU */
      { 
         fprintf(stderr, "Error in MPL_SGEMM1.m : argument 5 must be on DPU\n");
         exit(1); 
      }
     
    if (be[6]->onDPU) 
      var6 = (plural float  *)be[6]->addr;
    else  /* Arrays must be on DPU */
      { 
         fprintf(stderr, "Error in MPL_SGEMM1.m : argument 6 must be on DPU\n");
         exit(1); 
      }
     
    if (be[7]->onDPU) 
      var7 = (plural float  *)be[7]->addr;
    else  /* Arrays must be on DPU */
      { 
         fprintf(stderr, "Error in MPL_SGEMM1.m : argument 7 must be on DPU\n");
         exit(1); 
      }
     
    /* call the mpl function */ 
    mpl_sgemm1( *var1, *var2, *var3, *var4, var5, var6, var7);
  }
