#include "config.h"
#include "fupermod/fupermod_debug.h"
#include "fupermod/fupermod_kernel.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int n = 100;
int load(MPI_Comm comm, fupermod_process_conf* conf) {
char* subopts = strdup(conf->subopts);
char* subopts_0 = subopts;
char* tokens[] = {"h", "n"};
char* value;
while (*subopts != '\0') {
switch (getsubopt(&subopts, tokens, &value)) {
case 0: {
int root = 0;
int rank;
MPI_Comm_rank(comm, &rank);
if (rank == root)
fprintf(
stderr,
"Template for computational kernels\n"
"Suboptions:\n"
" h help\n"
" n=I option (default: %d)\n",
n
);
return FUPERMOD_FAIL;
}
case 1:
n = atoi(value);
break;
default:
fprintf(stderr, "Unknown suboption %s\n", value);
break;
}
}
free(subopts_0);
return FUPERMOD_SUCCESS;
}
int unload(MPI_Comm comm) {
NOT_USED(comm);
return FUPERMOD_SUCCESS;
}
double complexity(long long int d, void* param) {
NOT_USED(param);
return d;
}
typedef struct kernel_params {
double n;
} kernel_params;
int initialize(long long int d, void** params) {
NOT_USED(d);
*params = malloc(sizeof(kernel_params));
return FUPERMOD_SUCCESS;
}
int execute(pthread_mutex_t* mutex, void* params_) {
NOT_USED(mutex);
kernel_params* params = (kernel_params*)params_;
params->n = 0;
return FUPERMOD_SUCCESS;
}
int finalize(void* params) {
free(params);
return FUPERMOD_SUCCESS;
}
fupermod_kernel fupermod_kernel_instance = {
load,
unload,
complexity,
initialize,
execute,
finalize
};