#include <stdio.h> #include <stdlib.h> #include <math.h> #include "DIET_client.h" int main(int argc, char **argv) { int i; double factor = M_PI; /* Pi, why not ? */ double *matrix; /* The matrix to multiply */ float *time = NULL; /* To check that time is set by the server */ diet_profile_t *profile; /* Allocate the matrix: 60 lines, 100 columns */ matrix = malloc(60 * 100 * sizeof(double)); /* Fill in the matrix with dummy values (who cares ?) */ for (i = 0; i < (60 * 100); i++) { matrix[i] = 1.2 * i; } /* Initialize a DIET session */ if (diet_initialize("./client.cfg", argc, argv)) { printf("A problem occured during DIET initialization.\n" "Make sure that a configuration file named client.cfg is present in this directory.\n"); return 1; } /* Create the profile as explained in Chapter 3 */ profile = diet_profile_alloc("smprod",0, 1, 2); // last_in, last_inout, last_out /* Set profile arguments */ diet_scalar_set(diet_parameter(profile,0), &factor, 0, DIET_DOUBLE); diet_matrix_set(diet_parameter(profile,1), matrix, 0, DIET_DOUBLE, 60, 100, DIET_COL_MAJOR); diet_scalar_set(diet_parameter(profile,2), NULL, 0, DIET_FLOAT); if (!diet_call(profile)) { /* If the call has succeeded ... */ /* Get and print time */ diet_scalar_get(diet_parameter(profile,2), &time, NULL); if (time == NULL) { printf("Error: time not set !\n"); } else { printf("time = %f\n", *time); } /* Check the first non-zero element of the matrix */ if (fabs(matrix[1] - ((1.2 * 1) * factor)) > 1e-15) { printf("Error: matrix not correctly set !\n"); } } /* Free profile */ diet_profile_free(profile); diet_finalize(); free(matrix); free(time); }