Functions for executing a benchmark. More...
#include <stdlib.h>#include <signal.h>#include <sys/signal.h>#include <pthread.h>#include <sys/time.h>#include <sys/types.h>#include <time.h>#include <paths.h>#include <sys/wait.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#include <libgen.h>#include "pmm_model.h"#include "pmm_selector.h"#include "pmm_cfgparser.h"#include "pmm_log.h"#include "pmm_util.h"Go to the source code of this file.
Functions | |
| int | my_popen (char *cmd, char **args, int n, pid_t *pid) |
| int | set_non_blocking (int fd) |
| struct pmm_benchmark * | parse_bench_output (char *output, int n_p, int *rargs) |
| int | read_benchmark_output (int fd, char **output_p, pid_t bench_pid) |
| void | sig_childexit (int sig) |
| double | calculate_flops (struct timeval tv, long long int complexity) |
| double | timeval_to_seconds (struct timeval tv) |
| void | set_executing_benchmark (int i) |
| char * | pmm_bench_exit_status_to_string (int bench_status) |
| int | spawn_benchmark_process (struct pmm_routine *r, int *params, pid_t *bench_pid) |
| void | cleanup_benchmark_process (FILE *fp, pid_t bench_pid) |
| void * | benchmark (void *scheduled_r) |
Variables | |
| int | executing_benchmark |
| daemon executing variable or not | |
| pthread_mutex_t | executing_benchmark_mutex |
| mutex for accessing executing_benchmark variable | |
| int | signal_quit |
| signal to indicate benchmark should be terminated | |
| pthread_mutex_t | signal_quit_mutex |
| mutex for accessing singal_quit | |
Functions for executing a benchmark.
This file contains code for calling a benchmark executable from the pmm daemon, dealing with the system level requirements of spawning the benchmark process and parsing the output of said benchmark.
Definition in file pmm_executor.c.
| void* benchmark | ( | void * | scheduled_r | ) |
Given a routine to benchmark, select a point, execute the benchmark and insert the new point into the model. Set the global 'executing_benchark' to false/0 when the operation is complete (or has failed).
| scheduled_r | void pointer to a routine structure that has been scheduled for a benchmark execution |
Definition at line 685 of file pmm_executor.c.
| double calculate_flops | ( | struct timeval | tv, |
| long long int | complexity | ||
| ) |
calculate (FL)OPS (floating point operations per second or any other type of operations per second)
| tv | timeval structure representing duration of computation |
| complexity | complexity of computation (volume of operations) |
Definition at line 304 of file pmm_executor.c.
| void cleanup_benchmark_process | ( | FILE * | fp, |
| pid_t | bench_pid | ||
| ) |
clean up a benchmark process
closes file handles and kills the process
| fp | file pointer to the benchmarks standard output |
| bench_pid | benchmark process id |
Definition at line 465 of file pmm_executor.c.
| int my_popen | ( | char * | cmd, |
| char ** | args, | ||
| int | n, | ||
| pid_t * | pid | ||
| ) |
Forks a process that executes and external program with a an argument string and returns a file distriptor and sets the child processes pid
| cmd | string with the full path of the program |
| args | array of strings with all arguments of the program |
| n | number of arguments in arg vector |
| pid | pointer to the pid which will be set to the pid of the external program |
TODO test for file not found
Definition at line 134 of file pmm_executor.c.
|
read |
Given the output of a benchmark execution parse and create a new benchmark structure storing all the information gained
| output | pointer to benchmark output string |
| n_p | number of parameters of benchmark |
| rargs | arguments passed to the benchmarked routine |
Definition at line 233 of file pmm_executor.c.
| char * pmm_bench_exit_status_to_string | ( | int | bench_status | ) |
convert benchmark exit status to a string
| bench_status | benchmark status represented by an int |
Definition at line 970 of file pmm_executor.c.
| int read_benchmark_output | ( | int | fd, |
| char ** | output_p, | ||
| pid_t | bench_pid | ||
| ) |
Read the output of a benchmark process
| fd | benchmark process output file descriptor |
| output_p | pointer to a character array where output will be stored |
| bench_pid | process id of the benchmark process |
Definition at line 490 of file pmm_executor.c.
| void set_executing_benchmark | ( | int | i | ) |
set the executing_benchmark variable via mutex
| i | value to set variable with |
Definition at line 952 of file pmm_executor.c.
| int set_non_blocking | ( | int | fd | ) |
a roughly portable way of setting a file descriptor for non-blocking I/O.
| fd | file descriptor to modify |
Definition at line 94 of file pmm_executor.c.
| void sig_childexit | ( | int | sig | ) |
SIGCHLD signal handler
| sig | the signal |
Definition at line 212 of file pmm_executor.c.
| int spawn_benchmark_process | ( | struct pmm_routine * | r, |
| int * | params, | ||
| pid_t * | bench_pid | ||
| ) |
Convert params to an array of strings and call my_popen
| r | pointer to routine that will be executed |
| params | pointer to array of parameters |
| bench_pid | pointer to pid_t to store spawned process pid |
Definition at line 332 of file pmm_executor.c.
| double timeval_to_seconds | ( | struct timeval | tv | ) |
convert a timeval to second in double
| tv | timeval structure |
Definition at line 316 of file pmm_executor.c.
| int executing_benchmark |
daemon executing variable or not
Definition at line 54 of file pmm_main.c.
| pthread_mutex_t executing_benchmark_mutex |
mutex for accessing executing_benchmark variable
Definition at line 55 of file pmm_main.c.
| int signal_quit |
signal to indicate benchmark should be terminated
Definition at line 57 of file pmm_main.c.
| pthread_mutex_t signal_quit_mutex |
mutex for accessing singal_quit
Definition at line 58 of file pmm_main.c.
1.8.1.2