dgemmmop160GHz.cpp 2.64 KB

/*--------------------------------------------------------*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

/*--------------------------------------------------------*/

#include <ephomo.h>
#include <eperr.h>

/*--------------------------------------------------------*/

#include "helpers.h"
#include "dgemmparams160GHz.h"

/*--------------------------------------------------------*/

int main(int argc, char** argv)
{
    if (argc != 5)
    {
       fprintf(
          stderr,
          "Usage: %s <n in granularity> <p> <verbosity> <objType>.\n"
          "if p is 0, then 2 to 64 values are evaluated.\n"
          "objtype: [0-5]\n"
          "0 - ENERGY\n"
          "1 - PERFORMANCE\n"
          "2 - MOPEP\n"
          "3 - EDP\n"
          "4 - EDDP\n"
          "5 - EDDDP.\n",
          argv[0]);
       exit(EXIT_FAILURE);
    }

    size_t n = strtoul(argv[1], NULL, 10) * deltaX;
    size_t p = strtoul(argv[2], NULL, 10);
    unsigned int verbosity = strtoul(argv[3], NULL, 10);
    HclOptObjective objType = (HclOptObjective)strtoul(argv[4], NULL, 10);

    size_t npoints = sizeof(etimes)/sizeof(size_t);
    size_t point, *psizes = (size_t*)malloc(sizeof(size_t)*npoints);

    for (point = 0; point < npoints; point++)
    {
        psizes[point] = (point + 1) * deltaX;
    }

    for (point = 0; point < npoints; point++)
    {
        energies[point] -= etimes[point] * 100.0;

        if (energies[point] < 0.0)
        {
           energies[point] = energiesSD[point];
        }
    }

    printf(
       "MOP for n:%zu, dX:%u, Num points in S:%zu.\n",
       n, deltaX, npoints);

    size_t nSolutions, nParetoSolutions;
    double* path, *paretoFront;
    int rc = hcl_mop(
                verbosity,
                objType,
                n, p, deltaX,
                npoints, psizes, etimes, energies,
                &nSolutions, &path,
                1,
                &nParetoSolutions, &paretoFront);

    if (rc != HCL_SUCCESS)
    {
       fprintf(
          stderr,
          "%s\n",
          hcl_get_error_message(rc)
       );
       exit(EXIT_FAILURE);
    }

    free(psizes);

    printf("Objective %s path.\n", hcl_get_objective_type(objType));
    printf("===============================================\n");
    printPESolutions(
       nSolutions, path
    );
	
    printf("Pareto Optimal Front.\n");
    printf("===============================================\n");
    printPESolutions(
       nParetoSolutions, paretoFront
    );

    if (nSolutions)
    {
       free(path);
    }

    if (nParetoSolutions)
    {
       free(paretoFront);
    }

    exit(EXIT_SUCCESS);
}

/*--------------------------------------------------------*/