2016-06-14 01:19:17 +02:00
|
|
|
/** VILLASfpga utility for tests and benchmarks
|
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, Steffen Vogel
|
2016-06-14 01:19:17 +02:00
|
|
|
**********************************************************************************/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2016-06-15 20:05:09 +02:00
|
|
|
#include <string.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <getopt.h>
|
|
|
|
|
|
|
|
#include <villas/log.h>
|
2017-03-12 17:01:24 -03:00
|
|
|
#include <villas/super_node.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <villas/timing.h>
|
|
|
|
#include <villas/utils.h>
|
2017-03-11 23:39:00 -03:00
|
|
|
#include <villas/memory.h>
|
2016-06-19 19:23:19 +02:00
|
|
|
#include <villas/nodes/fpga.h>
|
2016-06-26 15:27:14 +02:00
|
|
|
#include <villas/kernel/rt.h>
|
2016-06-14 01:19:17 +02:00
|
|
|
#include <villas/kernel/pci.h>
|
|
|
|
#include <villas/kernel/kernel.h>
|
|
|
|
|
2017-03-03 20:21:33 -04:00
|
|
|
#include <villas/fpga/card.h>
|
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
/* Declarations */
|
2017-03-03 20:21:33 -04:00
|
|
|
int fpga_benchmarks(int argc, char *argv[], struct fpga_card *c);
|
2016-06-26 15:33:19 +02:00
|
|
|
|
2016-10-22 20:37:02 -04:00
|
|
|
void usage()
|
2016-06-14 01:19:17 +02:00
|
|
|
{
|
2017-05-03 19:26:58 +02:00
|
|
|
printf("Usage: villas-fpga [OPTIONS] CONFIG CARD\n\n");
|
|
|
|
printf(" CONFIG path to a configuration file\n");
|
|
|
|
printf(" CARD name of the FPGA card\n");
|
|
|
|
printf(" OPTIONS is one or more of the following options:\n");
|
|
|
|
printf(" -d Set log level\n");
|
|
|
|
printf("\n");
|
2016-06-15 20:05:09 +02:00
|
|
|
print_copyright();
|
2016-06-14 01:19:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret;
|
2017-03-05 10:06:32 -04:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
struct super_node sn;
|
2017-03-03 20:21:33 -04:00
|
|
|
struct fpga_card *card;
|
2016-06-26 15:33:19 +02:00
|
|
|
|
2016-06-14 01:19:17 +02:00
|
|
|
/* Parse arguments */
|
|
|
|
char c, *endptr;
|
2017-05-03 19:26:58 +02:00
|
|
|
while ((c = getopt(argc, argv, "d:")) != -1) {
|
2016-06-14 01:19:17 +02:00
|
|
|
switch (c) {
|
|
|
|
case 'd':
|
2017-03-12 17:01:24 -03:00
|
|
|
sn.log.level = strtoul(optarg, &endptr, 10);
|
2017-05-03 19:26:58 +02:00
|
|
|
goto check;
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
case '?':
|
|
|
|
default:
|
2016-10-22 20:37:02 -04:00
|
|
|
usage();
|
2017-03-27 12:50:01 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
2016-06-14 01:19:17 +02:00
|
|
|
}
|
2017-05-03 19:26:58 +02:00
|
|
|
|
|
|
|
check: if (optarg == endptr)
|
|
|
|
error("Failed to parse parse option argument '-%c %s'", c, optarg);
|
2016-06-14 01:19:17 +02:00
|
|
|
}
|
2017-05-03 19:26:58 +02:00
|
|
|
|
|
|
|
if (argc != optind + 2) {
|
|
|
|
usage();
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *configfile = argv[optind];
|
2016-06-14 01:19:17 +02:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
super_node_init(&sn);
|
2017-05-03 19:26:58 +02:00
|
|
|
super_node_parse_uri(&sn, configfile);
|
2016-06-26 15:33:19 +02:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
log_init(&sn.log, sn.log.level, sn.log.facilities);
|
|
|
|
rt_init(sn.priority, sn.affinity);
|
|
|
|
memory_init(sn.hugepages);
|
2016-06-26 15:27:14 +02:00
|
|
|
|
2016-06-15 20:05:09 +02:00
|
|
|
/* Initialize VILLASfpga card */
|
2017-04-07 17:32:36 +02:00
|
|
|
ret = fpga_init(&sn);
|
2016-06-14 01:19:17 +02:00
|
|
|
if (ret)
|
2016-06-26 15:33:19 +02:00
|
|
|
error("Failed to initialize FPGA card");
|
2016-06-15 20:05:09 +02:00
|
|
|
|
2017-03-03 20:21:33 -04:00
|
|
|
card = fpga_lookup_card(argv[2]);
|
|
|
|
if (!card)
|
|
|
|
error("FPGA card '%s' does not exist", argv[2]);
|
|
|
|
|
|
|
|
fpga_card_dump(card);
|
2016-06-14 01:19:17 +02:00
|
|
|
|
2017-03-05 10:06:32 -04:00
|
|
|
/* Run benchmarks */
|
|
|
|
fpga_benchmarks(argc-optind-1, argv+optind+1, card);
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
/* Shutdown */
|
2017-03-03 20:21:33 -04:00
|
|
|
ret = fpga_deinit();
|
2016-06-14 01:19:17 +02:00
|
|
|
if (ret)
|
2017-03-03 20:21:33 -04:00
|
|
|
error("Failed to de-initialize FPGA card");
|
2016-07-14 09:47:00 +02:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
super_node_destroy(&sn);
|
2016-06-14 01:19:17 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|