ccubes-cl/test_ccubes.c

118 lines
3.1 KiB
C
Raw Normal View History

2025-03-20 19:32:25 +02:00
/*
2025-03-26 11:50:07 +02:00
* Copyright (c) 2011-2016, 2025 Paul Irofti <paul@irofti.net>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2025-03-20 19:32:25 +02:00
*/
#include <stdio.h>
#include <string.h>
#include "real.h"
#include "cl_setup.h"
#include "clccubes.h"
#include "config.h"
#include "logging.h"
int
parse_args(char *argv[], int argc,
uint32_t *signals, uint32_t *atoms, uint32_t *problem_size,
uint32_t *sparsity, uint32_t *iters, uint32_t *patoms, uint32_t *pcoding,
real *rmse)
{
int i = 1;
while (i < argc) {
if (strcmp(argv[i], "-signals") == 0) {
*signals = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-atoms") == 0) {
*atoms = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-problem") == 0) {
*problem_size = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-sparsity") == 0) {
*sparsity = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-iterations") == 0) {
*iters = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-patoms") == 0) {
*patoms = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-pcoding") == 0) {
*pcoding = strtoul(argv[++i], NULL, 0);
} else if (strcmp(argv[i], "-rmse") == 0) {
sscanf(argv[++i], "%f", rmse);
} else {
printf("Unrecognized option %s\n", argv[i]);
return 1;
}
i++;
}
return 0;
}
void
usage(char *program)
{
printf("USAGE: %s [-signals sigs] [-atoms atoms] "
"[-problem problem_size] [-sparsity s] [-iterations iters] "
"[-patoms p] [-pcoding c]\n",
program);
exit(1);
}
int main(int argc, char *argv[])
{
int rc = 0;
real *zeroes = NULL;
uint64_t start, stop;
char log[100] = {0};
char *program;
struct ccubes_context ccubesctx;
/* Inputs */
/* Outputs */
/* Rounding */
/* Logging */
config_set_int("log", LOG_LEVEL_WARN);
config_set_int("log:ccubes", LOG_LEVEL_WARN);
config_set_int("log:test", LOG_LEVEL_WARN);
config_set_int("cl", LOG_LEVEL_DEBUG);
#if 0
rc = parse_args(argv, argc,
&signals, &atoms, &problem_size, &sparsity, &iters,
&patoms, &pcoding, &target_error);
if (rc != 0) {
usage(argv[0]);
}
if (strstr(argv[0], "test_ccubes") != NULL)
program = "ccubes";
sprintf(log, "log-%s-p%d-n%d-m%d-k%d-i%d-pa%d", program,
problem_size, atoms, signals, sparsity, iters, patoms);
config_set_string("out", log);
#endif
log_debug("test", "Starting ccubes...");
2025-03-21 18:52:41 +02:00
ccubes();
2025-03-20 19:32:25 +02:00
fflush(stdout);
err:
return rc;
}