Initial commit
This commit is contained in:
Executable
+4
@@ -0,0 +1,4 @@
|
||||
[Dolphin]
|
||||
Timestamp=2015,3,24,17,3,20
|
||||
Version=3
|
||||
ViewMode=1
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include "omp-tasks-app.h"
|
||||
|
||||
#define BOTS_APP_NAME "SparseLU (For version)"
|
||||
#define BOTS_APP_PARAMETERS_DESC "S1=%dx%d, S2=%dx%d"
|
||||
#define BOTS_APP_PARAMETERS_LIST ,bots_arg_size,bots_arg_size,bots_arg_size_1,bots_arg_size_1
|
||||
|
||||
#define BOTS_APP_USES_ARG_SIZE
|
||||
#define BOTS_APP_DEF_ARG_SIZE 50
|
||||
#define BOTS_APP_DESC_ARG_SIZE "Matrix Size"
|
||||
|
||||
#define BOTS_APP_USES_ARG_SIZE_1
|
||||
#define BOTS_APP_DEF_ARG_SIZE_1 100
|
||||
#define BOTS_APP_DESC_ARG_SIZE_1 "Submatrix Size"
|
||||
|
||||
#define BOTS_APP_INIT float **SEQ,**BENCH;
|
||||
|
||||
void sparselu_init(float ***pM, char *pass);
|
||||
void sparselu_fini(float **M, char *pass);
|
||||
void sparselu_seq_call(float **SEQ);
|
||||
void sparselu_par_call(float **BENCH, int argc, char* argv[]);
|
||||
int sparselu_check(float **SEQ, float **BENCH);
|
||||
|
||||
#define KERNEL_INIT sparselu_init(&BENCH,"benchmark");
|
||||
#define KERNEL_CALL sparselu_par_call(BENCH, argc, argv);
|
||||
#define KERNEL_FINI sparselu_fini(BENCH,"benchmark");
|
||||
|
||||
#define KERNEL_SEQ_INIT sparselu_init(&SEQ,"serial");
|
||||
#define KERNEL_SEQ_CALL sparselu_seq_call(SEQ);
|
||||
#define KERNEL_SEQ_FINI sparselu_fini(SEQ,"serial");
|
||||
|
||||
#define BOTS_APP_CHECK_USES_SEQ_RESULT
|
||||
#define KERNEL_CHECK sparselu_check(SEQ,BENCH);
|
||||
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#ifndef _BOTS_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* common flags */
|
||||
extern int bots_sequential_flag;
|
||||
extern int bots_benchmark_flag;
|
||||
extern int bots_check_flag;
|
||||
extern int bots_result;
|
||||
extern int bots_output_format;
|
||||
extern int bots_print_header;
|
||||
extern int bots_print_times;
|
||||
/* common variables */
|
||||
extern char bots_name[];
|
||||
extern char bots_parameters[];
|
||||
extern char bots_model[];
|
||||
extern char bots_resources[];
|
||||
/* compile and execution information */
|
||||
extern char bots_exec_date[];
|
||||
extern char bots_exec_message[];
|
||||
extern char bots_comp_date[];
|
||||
extern char bots_comp_message[];
|
||||
extern char bots_cc[];
|
||||
extern char bots_cflags[];
|
||||
extern char bots_ld[];
|
||||
extern char bots_ldflags[];
|
||||
/* time variables */
|
||||
extern double bots_time_program;
|
||||
extern double bots_time_sequential;
|
||||
|
||||
/* number of tasks variable */
|
||||
extern unsigned long long bots_number_of_tasks; /* forcing 8 bytes size on -m32 and -m64 */
|
||||
|
||||
extern char bots_cutoff[];
|
||||
extern int bots_cutoff_value;
|
||||
|
||||
extern int bots_app_cutoff_value;
|
||||
extern int bots_app_cutoff_value_1;
|
||||
extern int bots_app_cutoff_value_2;
|
||||
|
||||
extern int bots_arg_size;
|
||||
extern int bots_arg_size_1;
|
||||
extern int bots_arg_size_2;
|
||||
|
||||
/* function could be used in app. code but are implemented in bots_common.c */
|
||||
long bots_usecs();
|
||||
void bots_error(int error, char *message);
|
||||
void bots_warning(int warning, char *message);
|
||||
|
||||
#define BOTS_RESULT_NA 0
|
||||
#define BOTS_RESULT_SUCCESSFUL 1
|
||||
#define BOTS_RESULT_UNSUCCESSFUL 2
|
||||
#define BOTS_RESULT_NOT_REQUESTED 3
|
||||
|
||||
|
||||
typedef enum { BOTS_VERBOSE_NONE=0,
|
||||
BOTS_VERBOSE_DEFAULT,
|
||||
BOTS_VERBOSE_DEBUG } bots_verbose_mode_t;
|
||||
|
||||
extern bots_verbose_mode_t bots_verbose_mode;
|
||||
|
||||
#define bots_message(msg, ...) \
|
||||
{\
|
||||
if ( bots_verbose_mode >= BOTS_VERBOSE_DEFAULT ) {\
|
||||
fprintf(stdout, msg , ##__VA_ARGS__);\
|
||||
}\
|
||||
}
|
||||
|
||||
#ifdef BOTS_DEBUG
|
||||
#define bots_debug(msg, ...) \
|
||||
{\
|
||||
if ( bots_verbose_mode >= BOTS_VERBOSE_DEBUG ) {\
|
||||
fprintf(stdout, msg , ##__VA_ARGS__);\
|
||||
}\
|
||||
}
|
||||
#define bots_debug_with_location_info(msg, ...) \
|
||||
{\
|
||||
if ( bots_verbose_mode >= BOTS_VERBOSE_DEBUG ) {\
|
||||
fprintf(stdout, "%s:%d:%s:" msg ,__FILE__, __LINE__,__func__,##__VA_ARGS__);\
|
||||
}\
|
||||
}
|
||||
#else
|
||||
#define bots_debug(msg, ...)
|
||||
#define bots_debug_with_location_info(msg, ...)
|
||||
#endif
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Executable
+346
@@ -0,0 +1,346 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "bots_common.h"
|
||||
#include "bots_main.h"
|
||||
#include "bots.h"
|
||||
|
||||
void
|
||||
bots_error(int error, char *message)
|
||||
{
|
||||
if (message == NULL)
|
||||
{
|
||||
switch(error)
|
||||
{
|
||||
case BOTS_ERROR:
|
||||
fprintf(stderr, "Error (%d): %s\n",error,"Unspecified error.");
|
||||
break;
|
||||
case BOTS_ERROR_NOT_ENOUGH_MEMORY:
|
||||
fprintf(stderr, "Error (%d): %s\n",error,"Not enough memory.");
|
||||
break;
|
||||
case BOTS_ERROR_UNRECOGNIZED_PARAMETER:
|
||||
fprintf(stderr, "Error (%d): %s\n",error,"Unrecognized parameter.");
|
||||
bots_print_usage();
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Error (%d): %s\n",error,"Invalid error code.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else fprintf(stderr, "Error (%d): %s\n",error,message);
|
||||
exit(100+error);
|
||||
}
|
||||
|
||||
void
|
||||
bots_warning(int warning, char *message)
|
||||
{
|
||||
if (message == NULL)
|
||||
{
|
||||
switch(warning)
|
||||
{
|
||||
case BOTS_WARNING:
|
||||
fprintf(stderr, "Warning (%d): %s\n",warning,"Unspecified warning.");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Warning (%d): %s\n",warning,"Invalid warning code.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else fprintf(stderr, "Warning (%d): %s\n",warning,message);
|
||||
}
|
||||
|
||||
long bots_usecs (void)
|
||||
{
|
||||
struct timeval t;
|
||||
gettimeofday(&t,NULL);
|
||||
return t.tv_sec*1000000+t.tv_usec;
|
||||
}
|
||||
|
||||
void
|
||||
bots_get_date(char *str)
|
||||
{
|
||||
time_t now;
|
||||
time(&now);
|
||||
strftime(str, 32, "%Y/%m/%d;%H:%M", gmtime(&now));
|
||||
}
|
||||
|
||||
void bots_get_architecture(char *str)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
str = "Win32";
|
||||
#else
|
||||
int ncpus = sysconf(_SC_NPROCESSORS_CONF);
|
||||
struct utsname architecture;
|
||||
uname(&architecture);
|
||||
snprintf(str, BOTS_TMP_STR_SZ, "%s-%s;%d" ,architecture.sysname, architecture.machine, ncpus);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (DISABLED_FOR_INSIEME_TEST)
|
||||
//#if defined (__linux)
|
||||
/* ****************************************************************** */
|
||||
void bots_get_load_average(char *str)
|
||||
{
|
||||
double loadavg[3];
|
||||
getloadavg (loadavg, 3);
|
||||
snprintf(str, BOTS_TMP_STR_SZ, "%.2f;%.2f;%.2f",loadavg[0],loadavg[1],loadavg[2]);
|
||||
}
|
||||
#else
|
||||
/* ****************************************************************** */
|
||||
void bots_get_load_average(char *str) { sprintf(str,";;"); }
|
||||
#endif
|
||||
|
||||
void bots_print_results()
|
||||
{
|
||||
char str_name[BOTS_TMP_STR_SZ];
|
||||
char str_parameters[BOTS_TMP_STR_SZ];
|
||||
char str_model[BOTS_TMP_STR_SZ];
|
||||
char str_resources[BOTS_TMP_STR_SZ];
|
||||
char str_result[15];
|
||||
char str_time_program[15];
|
||||
char str_time_sequential[15];
|
||||
char str_speed_up[15];
|
||||
char str_number_of_tasks[15];
|
||||
char str_number_of_tasks_per_second[15];
|
||||
char str_exec_date[BOTS_TMP_STR_SZ];
|
||||
char str_exec_message[BOTS_TMP_STR_SZ];
|
||||
char str_architecture[BOTS_TMP_STR_SZ];
|
||||
char str_load_avg[BOTS_TMP_STR_SZ];
|
||||
char str_comp_date[BOTS_TMP_STR_SZ];
|
||||
char str_comp_message[BOTS_TMP_STR_SZ];
|
||||
char str_cc[BOTS_TMP_STR_SZ];
|
||||
char str_cflags[BOTS_TMP_STR_SZ];
|
||||
char str_ld[BOTS_TMP_STR_SZ];
|
||||
char str_ldflags[BOTS_TMP_STR_SZ];
|
||||
char str_cutoff[BOTS_TMP_STR_SZ];
|
||||
|
||||
/* compute output strings */
|
||||
sprintf(str_name, "%s", bots_name);
|
||||
sprintf(str_parameters, "%s", bots_parameters);
|
||||
sprintf(str_model, "%s", bots_model);
|
||||
sprintf(str_cutoff, "%s", bots_cutoff);
|
||||
sprintf(str_resources, "%s", bots_resources);
|
||||
switch(bots_result)
|
||||
{
|
||||
case BOTS_RESULT_NA:
|
||||
sprintf(str_result, "n/a");
|
||||
break;
|
||||
case BOTS_RESULT_SUCCESSFUL:
|
||||
sprintf(str_result, "successful");
|
||||
break;
|
||||
case BOTS_RESULT_UNSUCCESSFUL:
|
||||
sprintf(str_result, "UNSUCCESSFUL");
|
||||
break;
|
||||
case BOTS_RESULT_NOT_REQUESTED:
|
||||
sprintf(str_result, "Not requested");
|
||||
break;
|
||||
default:
|
||||
sprintf(str_result, "error");
|
||||
break;
|
||||
}
|
||||
sprintf(str_time_program, "%f", bots_time_program);
|
||||
if (bots_sequential_flag) sprintf(str_time_sequential, "%f", bots_time_sequential);
|
||||
else sprintf(str_time_sequential, "n/a");
|
||||
if (bots_sequential_flag)
|
||||
sprintf(str_speed_up, "%3.2f", bots_time_sequential/bots_time_program);
|
||||
else sprintf(str_speed_up, "n/a");
|
||||
|
||||
sprintf(str_number_of_tasks, "%3.2f", (float) bots_number_of_tasks);
|
||||
sprintf(str_number_of_tasks_per_second, "%3.2f", (float) bots_number_of_tasks/bots_time_program);
|
||||
|
||||
sprintf(str_exec_date, "%s", bots_exec_date);
|
||||
sprintf(str_exec_message, "%s", bots_exec_message);
|
||||
bots_get_architecture(str_architecture);
|
||||
bots_get_load_average(str_load_avg);
|
||||
sprintf(str_comp_date, "%s", bots_comp_date);
|
||||
sprintf(str_comp_message, "%s", bots_comp_message);
|
||||
sprintf(str_cc, "%s", bots_cc);
|
||||
sprintf(str_cflags, "%s", bots_cflags);
|
||||
sprintf(str_ld, "%s", bots_ld);
|
||||
sprintf(str_ldflags, "%s", bots_ldflags);
|
||||
|
||||
if(bots_print_header)
|
||||
{
|
||||
switch(bots_output_format)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
fprintf(stdout,
|
||||
"Benchmark;Parameters;Model;Cutoff;Resources;Result;\
|
||||
Time;Sequential;Speed-up;\
|
||||
Nodes;Nodes/Sec;\
|
||||
Exec Date;Exec Time;Exec Message;\
|
||||
Architecture;Processors;Load Avg-1;Load Avg-5;Load Avg-15;\
|
||||
Comp Date;Comp Time;Comp Message;CC;CFLAGS;LD;LDFLAGS\n");
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
fprintf(stdout,
|
||||
"Benchmark;Parameters;Model;Cutoff;Resources;Result;\
|
||||
Time;Sequential;Speed-up;\
|
||||
Nodes;Nodes/Sec;\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* print results */
|
||||
switch(bots_output_format)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Program = %s\n", str_name); /*fix*/
|
||||
fprintf(stdout, "Parameters = %s\n", str_parameters); /*fix*/
|
||||
fprintf(stdout, "Model = %s\n", str_model);
|
||||
fprintf(stdout, "Embedded cut-off = %s\n", str_cutoff);
|
||||
// fprintf(stdout, "# of Threads = %s\n", str_resources);
|
||||
fprintf(stdout, "Verification = %s\n", str_result);
|
||||
|
||||
if (bots_print_times) {
|
||||
fprintf(stdout, "Time Program = %s seconds\n", str_time_program);
|
||||
if (bots_sequential_flag) {
|
||||
fprintf(stdout, "Time Sequential = %s seconds\n", str_time_sequential);
|
||||
fprintf(stdout, "Speed-up = %s\n", str_speed_up);
|
||||
}
|
||||
}
|
||||
|
||||
if ( bots_number_of_tasks > 0 ) {
|
||||
fprintf(stdout, "Nodes = %s\n", str_number_of_tasks);
|
||||
fprintf(stdout, "Nodes/Sec = %s\n", str_number_of_tasks_per_second);
|
||||
}
|
||||
|
||||
// fprintf(stdout, "Execution Date = %s\n", str_exec_date);
|
||||
fprintf(stdout, "Execution Message = %s\n", str_exec_message);
|
||||
|
||||
fprintf(stdout, "Architecture = %s\n", str_architecture);
|
||||
// fprintf(stdout, "Load Avg [1:5:15] = %s\n", str_load_avg);
|
||||
|
||||
fprintf(stdout, "Compilation Date = %s\n", str_comp_date);
|
||||
fprintf(stdout, "Compilation Message = %s\n", str_comp_message);
|
||||
|
||||
fprintf(stdout, "Compiler = %s\n", str_cc);
|
||||
fprintf(stdout, "Compiler Flags = %s\n", str_cflags);
|
||||
fprintf(stdout, "Linker = %s\n", str_ld);
|
||||
fprintf(stdout, "Linker Flags = %s\n", str_ldflags);
|
||||
fflush(stdout);
|
||||
break;
|
||||
case 2:
|
||||
fprintf(stdout,"%s;%s;%s;%s;%s;%s;",
|
||||
str_name,
|
||||
str_parameters,
|
||||
str_model,
|
||||
str_cutoff,
|
||||
str_resources,
|
||||
str_result
|
||||
);
|
||||
fprintf(stdout,"%s;%s;%s;",
|
||||
str_time_program,
|
||||
str_time_sequential,
|
||||
str_speed_up
|
||||
);
|
||||
fprintf(stdout,"%s;%s;",
|
||||
str_number_of_tasks,
|
||||
str_number_of_tasks_per_second
|
||||
);
|
||||
fprintf(stdout,"%s;%s;",
|
||||
str_exec_date,
|
||||
str_exec_message
|
||||
);
|
||||
fprintf(stdout,"%s;%s;",
|
||||
str_architecture,
|
||||
str_load_avg
|
||||
);
|
||||
fprintf(stdout,"%s;%s;",
|
||||
str_comp_date,
|
||||
str_comp_message
|
||||
);
|
||||
fprintf(stdout,"%s;%s;%s;%s;",
|
||||
str_cc,
|
||||
str_cflags,
|
||||
str_ld,
|
||||
str_ldflags
|
||||
);
|
||||
fprintf(stdout,"\n");
|
||||
break;
|
||||
case 3:
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Program = %s\n", str_name); /*fix*/
|
||||
fprintf(stdout, "Parameters = %s\n", str_parameters); /*fix*/
|
||||
fprintf(stdout, "Model = %s\n", str_model);
|
||||
fprintf(stdout, "Embedded cut-off = %s\n", str_cutoff);
|
||||
fprintf(stdout, "# of Threads = %s\n", str_resources);
|
||||
fprintf(stdout, "Verification = %s\n", str_result);
|
||||
|
||||
fprintf(stdout, "Time Program = %s seconds\n", str_time_program);
|
||||
if (bots_sequential_flag) {
|
||||
fprintf(stdout, "Time Sequential = %s seconds\n", str_time_sequential);
|
||||
fprintf(stdout, "Speed-up = %s\n", str_speed_up);
|
||||
}
|
||||
|
||||
if ( bots_number_of_tasks > 0 ) {
|
||||
fprintf(stdout, "Nodes = %s\n", str_number_of_tasks);
|
||||
fprintf(stdout, "Nodes/Sec = %s\n", str_number_of_tasks_per_second);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
fprintf(stdout,"%s;%s;%s;%s;%s;%s;",
|
||||
str_name,
|
||||
str_parameters,
|
||||
str_model,
|
||||
str_cutoff,
|
||||
str_resources,
|
||||
str_result
|
||||
);
|
||||
fprintf(stdout,"%s;%s;%s;",
|
||||
str_time_program,
|
||||
str_time_sequential,
|
||||
str_speed_up
|
||||
);
|
||||
fprintf(stdout,"%s;%s;",
|
||||
str_number_of_tasks,
|
||||
str_number_of_tasks_per_second
|
||||
);
|
||||
fprintf(stdout,"\n");
|
||||
break;
|
||||
default:
|
||||
bots_error(BOTS_ERROR, (char*)"No valid output format\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#ifndef CC
|
||||
#define CC ""
|
||||
#endif
|
||||
#ifndef CFLAGS
|
||||
#define CFLAGS ""
|
||||
#endif
|
||||
#ifndef LD
|
||||
#define LD ""
|
||||
#endif
|
||||
#ifndef LDFLAGS
|
||||
#define LDFLAGS ""
|
||||
#endif
|
||||
#ifndef CDATE
|
||||
#define CDATE ""
|
||||
#endif
|
||||
#ifndef CMESSAGE
|
||||
#define CMESSAGE ""
|
||||
#endif
|
||||
|
||||
#define BOTS_ERROR 0
|
||||
#define BOTS_ERROR_NOT_ENOUGH_MEMORY 1
|
||||
#define BOTS_ERROR_UNRECOGNIZED_PARAMETER 2
|
||||
|
||||
#define BOTS_WARNING 0
|
||||
|
||||
void bots_get_date(char *str);
|
||||
void bots_get_architecture(char *str);
|
||||
void bots_get_load_average(char *str);
|
||||
void bots_print_results(void);
|
||||
|
||||
#define BOTS_TMP_STR_SZ 256
|
||||
|
||||
#endif
|
||||
Executable
+559
@@ -0,0 +1,559 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
/***********************************************************************
|
||||
* main function & common behaviour of the benchmark.
|
||||
**********************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <memory.h>
|
||||
#include <sys/time.h>
|
||||
#include <libgen.h>
|
||||
#include "bots_common.h"
|
||||
#include "bots_main.h"
|
||||
#include "bots.h"
|
||||
#include "app-desc.h"
|
||||
|
||||
#include <wfr/common/exceptions/exceptions.h>
|
||||
|
||||
/***********************************************************************
|
||||
* DEFAULT VALUES
|
||||
*********************************************************************/
|
||||
/* common flags */
|
||||
int bots_sequential_flag = FALSE;
|
||||
int bots_check_flag = FALSE;
|
||||
bots_verbose_mode_t bots_verbose_mode = BOTS_VERBOSE_DEFAULT;
|
||||
int bots_result = BOTS_RESULT_NOT_REQUESTED;
|
||||
int bots_output_format = 1;
|
||||
int bots_print_header = FALSE;
|
||||
/* common variables */
|
||||
char bots_name[BOTS_TMP_STR_SZ];
|
||||
char bots_execname[BOTS_TMP_STR_SZ];
|
||||
char bots_parameters[BOTS_TMP_STR_SZ];
|
||||
char bots_model[BOTS_TMP_STR_SZ];
|
||||
char bots_resources[BOTS_TMP_STR_SZ];
|
||||
/* compile and execution information */
|
||||
char bots_exec_date[BOTS_TMP_STR_SZ];
|
||||
char bots_exec_message[BOTS_TMP_STR_SZ];
|
||||
char bots_comp_date[BOTS_TMP_STR_SZ];
|
||||
char bots_comp_message[BOTS_TMP_STR_SZ];
|
||||
char bots_cc[BOTS_TMP_STR_SZ];
|
||||
char bots_cflags[BOTS_TMP_STR_SZ];
|
||||
char bots_ld[BOTS_TMP_STR_SZ];
|
||||
char bots_ldflags[BOTS_TMP_STR_SZ];
|
||||
char bots_cutoff[BOTS_TMP_STR_SZ];
|
||||
|
||||
/* time variables */
|
||||
double bots_time_program = 0.0;
|
||||
double bots_time_sequential = 0.0;
|
||||
unsigned long long bots_number_of_tasks = 0; /* forcing 8 bytes size in -m32 and -m64 */
|
||||
|
||||
/*
|
||||
* Application dependent info
|
||||
*/
|
||||
|
||||
#ifndef BOTS_APP_NAME
|
||||
#error "Application name must be defined (#define BOTS_APP_NAME)"
|
||||
#endif
|
||||
|
||||
#ifndef BOTS_APP_PARAMETERS_DESC
|
||||
#define BOTS_APP_PARAMETERS_DESC ""
|
||||
#endif
|
||||
|
||||
#ifndef BOTS_APP_PARAMETERS_LIST
|
||||
#define BOTS_APP_PARAMETERS_LIST
|
||||
#endif
|
||||
|
||||
#ifndef BOTS_APP_INIT
|
||||
#define BOTS_APP_INIT
|
||||
#endif
|
||||
|
||||
#ifndef BOTS_APP_FINI
|
||||
#define BOTS_APP_FINI
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_CALL
|
||||
#error "Initial kernell call must be specified (#define KERNEL_CALL)"
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_INIT
|
||||
#define KERNEL_INIT
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_FINI
|
||||
#define KERNEL_FINI
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_SEQ_INIT
|
||||
#define KERNEL_SEQ_INIT
|
||||
#endif
|
||||
|
||||
#ifndef KERNEL_SEQ_FINI
|
||||
#define KERNEL_SEQ_FINI
|
||||
#endif
|
||||
|
||||
#ifndef BOTS_MODEL_DESC
|
||||
#define BOTS_MODEL_DESC "Unknown"
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE
|
||||
#ifndef BOTS_APP_DEF_ARG_SIZE
|
||||
#error "Default vaule for argument size must be specified (#define BOTS_APP_DEF_ARG_SIZE)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_SIZE
|
||||
#error "Help description for argument size must be specified (#define BOTS_APP_DESC_ARG_SIZE)"
|
||||
#endif
|
||||
int bots_arg_size = BOTS_APP_DEF_ARG_SIZE;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_1
|
||||
#ifndef BOTS_APP_DEF_ARG_SIZE_1
|
||||
#error "Default vaule for argument size must be specified (#define BOTS_APP_DEF_ARG_SIZE_1)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_SIZE_1
|
||||
#error "Help description for argument size must be specified (#define BOTS_APP_DESC_ARG_SIZE_1)"
|
||||
#endif
|
||||
int bots_arg_size_1 = BOTS_APP_DEF_ARG_SIZE_1;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_2
|
||||
#ifndef BOTS_APP_DEF_ARG_SIZE_2
|
||||
#error "Default vaule for argument size must be specified (#define BOTS_APP_DEF_ARG_SIZE_2)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_SIZE_2
|
||||
#error "Help description for argument size must be specified (#define BOTS_APP_DESC_ARG_SIZE_2)"
|
||||
#endif
|
||||
int bots_arg_size_2 = BOTS_APP_DEF_ARG_SIZE_2;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_REPETITIONS
|
||||
#ifndef BOTS_APP_DEF_ARG_REPETITIONS
|
||||
#error "Default vaule for argument repetitions must be specified (#define BOTS_APP_DEF_ARG_REPETITIONS)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_REPETITIONS
|
||||
#error "Help description for argument repetitions must be specified (#define BOTS_APP_DESC_ARG_REPETITIONS)"
|
||||
#endif
|
||||
int bots_arg_repetitions = BOTS_APP_DEF_ARG_REPETITIONS;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_FILE
|
||||
#ifndef BOTS_APP_DESC_ARG_FILE
|
||||
#error "Help description for argument file must be specified (#define BOTS_APP_DESC_ARG_FILE)"
|
||||
#endif
|
||||
char bots_arg_file[255]="";
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_BLOCK
|
||||
#ifndef BOTS_APP_DEF_ARG_BLOCK
|
||||
#error "Default value for argument block must be specified (#define BOTS_APP_DEF_ARG_BLOCK)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_BLOCK
|
||||
#error "Help description for argument block must be specified (#define BOTS_APP_DESC_ARG_BLOCK)"
|
||||
#endif
|
||||
int bots_arg_block = BOTS_APP_DEF_ARG_BLOCK;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF
|
||||
#ifndef BOTS_APP_DEF_ARG_CUTOFF
|
||||
#error "Default value for argument cutoff must be specified (#define BOTS_APP_DEF_ARG_CUTOFF)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_CUTOFF
|
||||
#error "Help description for argument cutoff must be specified (#define BOTS_APP_DESC_ARG_CUTOFF)"
|
||||
#endif
|
||||
int bots_app_cutoff_value = BOTS_APP_DEF_ARG_CUTOFF;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_1
|
||||
#ifndef BOTS_APP_DEF_ARG_CUTOFF_1
|
||||
#error "Default value for argument cutoff must be specified (#define BOTS_APP_DEF_ARG_CUTOFF_1)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_CUTOFF_1
|
||||
#error "Help description for argument cutoff must be specified (#define BOTS_APP_DESC_ARG_CUTOFF_1)"
|
||||
#endif
|
||||
int bots_app_cutoff_value_1 = BOTS_APP_DEF_ARG_CUTOFF_1;
|
||||
#endif
|
||||
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_2
|
||||
#ifndef BOTS_APP_DEF_ARG_CUTOFF_2
|
||||
#error "Default value for argument cutoff must be specified (#define BOTS_APP_DEF_ARG_CUTOFF_2)"
|
||||
#endif
|
||||
#ifndef BOTS_APP_DESC_ARG_CUTOFF_2
|
||||
#error "Help description for argument cutoff must be specified (#define BOTS_APP_DESC_ARG_CUTOFF_2)"
|
||||
#endif
|
||||
int bots_app_cutoff_value_2 = BOTS_APP_DEF_ARG_CUTOFF_2;
|
||||
#endif
|
||||
|
||||
#if defined(MANUAL_CUTOFF) || defined(IF_CUTOFF) || defined(FINAL_CUTOFF)
|
||||
int bots_cutoff_value = BOTS_CUTOFF_DEF_VALUE;
|
||||
#endif
|
||||
|
||||
// a flag added to allow bots to be used within integration tests
|
||||
int bots_print_times = 1;
|
||||
|
||||
/***********************************************************************
|
||||
* print_usage:
|
||||
**********************************************************************/
|
||||
void bots_print_usage()
|
||||
{
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Usage: %s -[options]\n", bots_execname);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Where options are:\n");
|
||||
#ifdef BOTS_APP_USES_REPETITIONS
|
||||
fprintf(stderr, " -r <value> : Set the number of repetitions (default = 1).\n");
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE
|
||||
fprintf(stderr, " -n <size> : " BOTS_APP_DESC_ARG_SIZE "\n");
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_1
|
||||
fprintf(stderr, " -m <size> : " BOTS_APP_DESC_ARG_SIZE_1 "\n");
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_2
|
||||
fprintf(stderr, " -l <size> : " BOTS_APP_DESC_ARG_SIZE_2 "\n");
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_FILE
|
||||
fprintf(stderr, " -f <file> : " BOTS_APP_DESC_ARG_FILE "\n");
|
||||
#endif
|
||||
#if defined(MANUAL_CUTOFF) || defined(IF_CUTOFF) || defined(FINAL_CUTOFF)
|
||||
fprintf(stderr, " -x <value> : OpenMP tasks cut-off value (default=%d)\n",BOTS_CUTOFF_DEF_VALUE);
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF
|
||||
fprintf(stderr, " -y <value> : " BOTS_APP_DESC_ARG_CUTOFF "(default=%d)\n", BOTS_APP_DEF_ARG_CUTOFF);
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_1
|
||||
fprintf(stderr, " -a <value> : " BOTS_APP_DESC_ARG_CUTOFF_1 "(default=%d)\n", BOTS_APP_DEF_ARG_CUTOFF_1);
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_2
|
||||
fprintf(stderr, " -b <value> : " BOTS_APP_DESC_ARG_CUTOFF_2 "(default=%d)\n", BOTS_APP_DEF_ARG_CUTOFF_2);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -e <str> : Include 'str' execution message.\n");
|
||||
fprintf(stderr, " -v <level> : Set verbose level (default = 1).\n");
|
||||
fprintf(stderr, " 0 - none.\n");
|
||||
fprintf(stderr, " 1 - default.\n");
|
||||
fprintf(stderr, " 2 - debug.\n");
|
||||
fprintf(stderr, " -o <value> : Set output format mode (default = 1).\n");
|
||||
fprintf(stderr, " 0 - no benchmark output.\n");
|
||||
fprintf(stderr, " 1 - detailed list format.\n");
|
||||
fprintf(stderr, " 2 - detailed row format.\n");
|
||||
fprintf(stderr, " 3 - abridged list format.\n");
|
||||
fprintf(stderr, " 4 - abridged row format.\n");
|
||||
fprintf(stderr, " -z : Print row header (if output format is a row variant).\n");
|
||||
fprintf(stderr, "\n");
|
||||
#ifdef KERNEL_SEQ_CALL
|
||||
fprintf(stderr, " -s : Run sequential version.\n");
|
||||
#endif
|
||||
#ifdef BOTS_APP_CHECK_USES_SEQ_RESULT
|
||||
fprintf(stderr, " -c : Check mode ON (implies running sequential version).\n");
|
||||
#else
|
||||
fprintf(stderr, " -c : Check mode ON.\n");
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -h : Print program's usage (this help).\n");
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " -t : Disable printing of times (for integration tests).\n");
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
/***********************************************************************
|
||||
* bots_get_params_common:
|
||||
**********************************************************************/
|
||||
void
|
||||
bots_get_params_common(int argc, char **argv)
|
||||
{
|
||||
int i = 1;
|
||||
strcpy(bots_execname, basename(argv[0]));
|
||||
bots_get_date(bots_exec_date);
|
||||
strcpy(bots_exec_message,"");
|
||||
while (i<argc)
|
||||
{
|
||||
if (argv[i][0] == '-')
|
||||
{
|
||||
switch (argv[i][1])
|
||||
{
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_1
|
||||
case 'a':
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_app_cutoff_value_1 = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF_2
|
||||
case 'b':
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_app_cutoff_value_2 = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
case 'c': /* set/unset check mode */
|
||||
argv[i][1] = '*';
|
||||
//i++;
|
||||
//if (argc == i) { bots_print_usage(); exit(100); }
|
||||
//bots_check_flag = atoi(argv[i]);
|
||||
bots_check_flag = TRUE;
|
||||
break;
|
||||
case 'e': /* include execution message */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
strcpy(bots_exec_message, argv[i]);
|
||||
break;
|
||||
#ifdef BOTS_APP_USES_ARG_FILE
|
||||
case 'f': /* read argument file name */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
strcpy(bots_arg_file,argv[i]);
|
||||
break;
|
||||
#endif
|
||||
case 'h': /* print usage */
|
||||
argv[i][1] = '*';
|
||||
bots_print_usage();
|
||||
exit (100);
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_2
|
||||
case 'l': /* read argument size 2 */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_arg_size_2 = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE_1
|
||||
case 'm': /* read argument size 1 */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_arg_size_1 = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_SIZE
|
||||
case 'n': /* read argument size 0 */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_arg_size = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_BLOCK
|
||||
/*TODO*/
|
||||
#endif
|
||||
case 'o': /* set output mode */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_output_format = atoi(argv[i]);
|
||||
break;
|
||||
#ifdef BOTS_APP_USES_REPETITIONS
|
||||
case 'r': /* set number of repetitions */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_arg_repetition = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef KERNEL_SEQ_CALL
|
||||
case 's': /* set sequential execution */
|
||||
argv[i][1] = '*';
|
||||
//i++;
|
||||
//if (argc == i) { bots_print_usage(); exit(100); }
|
||||
//bots_sequential_flag = atoi(argv[i]);
|
||||
bots_sequential_flag = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'v': /* set/unset verbose level */
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_verbose_mode = (bots_verbose_mode_t) atoi(argv[i]);
|
||||
#ifndef BOTS_DEBUG
|
||||
if ( bots_verbose_mode > 1 ) {
|
||||
fprintf(stderr, "Error: Configure the suite using '--debug' option in order to use a verbose level greather than 1.\n");
|
||||
exit(100);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#if defined(MANUAL_CUTOFF) || defined(IF_CUTOFF) || defined(FINAL_CUTOFF)
|
||||
case 'x':
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_cutoff_value = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
#ifdef BOTS_APP_USES_ARG_CUTOFF
|
||||
case 'y':
|
||||
argv[i][1] = '*';
|
||||
i++;
|
||||
if (argc == i) { bots_print_usage(); exit(100); }
|
||||
bots_app_cutoff_value = atoi(argv[i]);
|
||||
break;
|
||||
#endif
|
||||
case 'z':
|
||||
argv[i][1] = '*';
|
||||
bots_print_header = TRUE;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
argv[i][1] = '*';
|
||||
bots_print_times = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
// As at the moment there are only common paramenters
|
||||
// we launch an error. Otherwise we have to ignore the
|
||||
// parameter and to check, after specific parameters are
|
||||
// completely read, if there are unrecognized parameters.
|
||||
//fprintf(stderr, "Error: Unrecognized parameter.\n");
|
||||
//bots_print_usage();
|
||||
//exit (100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// As at the moment there are only common paramenters
|
||||
// we launch an error. Otherwise we have to ignore the
|
||||
// parameter and to check, after specific parameters are
|
||||
// completely read, if there are unrecognized parameters.
|
||||
//fprintf(stderr, "Error: Unrecognized parameter.\n");
|
||||
//bots_print_usage();
|
||||
//exit (100);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
/***********************************************************************
|
||||
* bots_get_params_common:
|
||||
**********************************************************************/
|
||||
void
|
||||
bots_get_params(int argc, char **argv)
|
||||
{
|
||||
bots_get_params_common(argc, argv);
|
||||
// bots_get_params_specific(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* bots_set_info
|
||||
**********************************************************************/
|
||||
void bots_set_info ()
|
||||
{
|
||||
/* program specific info */
|
||||
snprintf(bots_name, BOTS_TMP_STR_SZ, BOTS_APP_NAME);
|
||||
snprintf(bots_parameters, BOTS_TMP_STR_SZ, BOTS_APP_PARAMETERS_DESC BOTS_APP_PARAMETERS_LIST);
|
||||
snprintf(bots_model, BOTS_TMP_STR_SZ, BOTS_MODEL_DESC);
|
||||
snprintf(bots_resources, BOTS_TMP_STR_SZ, "%d", omp_get_max_threads());
|
||||
|
||||
/* compilation info (do not modify) */
|
||||
snprintf(bots_comp_date, BOTS_TMP_STR_SZ, CDATE);
|
||||
snprintf(bots_comp_message, BOTS_TMP_STR_SZ, CMESSAGE);
|
||||
snprintf(bots_cc, BOTS_TMP_STR_SZ, CC);
|
||||
snprintf(bots_cflags, BOTS_TMP_STR_SZ, CFLAGS);
|
||||
snprintf(bots_ld, BOTS_TMP_STR_SZ, LD);
|
||||
snprintf(bots_ldflags, BOTS_TMP_STR_SZ, LDFLAGS);
|
||||
|
||||
#if defined(MANUAL_CUTOFF)
|
||||
snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "manual (%d)",bots_cutoff_value);
|
||||
#elif defined(IF_CUTOFF)
|
||||
snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "pragma-if (%d)",bots_cutoff_value);
|
||||
#elif defined(FINAL_CUTOFF)
|
||||
snprintf(bots_cutoff, BOTS_TMP_STR_SZ, "final (%d)",bots_cutoff_value);
|
||||
#else
|
||||
strcpy(bots_cutoff,"none");
|
||||
#endif
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* main:
|
||||
**********************************************************************/
|
||||
#if not defined (SPARSELU_SKIP_BOTS_MAIN)
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef BOTS_APP_SELF_TIMING
|
||||
long bots_t_start;
|
||||
long bots_t_end;
|
||||
#endif
|
||||
|
||||
bots_get_params(argc,argv);
|
||||
BOTS_APP_INIT;
|
||||
bots_set_info();
|
||||
|
||||
#ifdef KERNEL_SEQ_CALL
|
||||
#ifdef BOTS_APP_CHECK_USES_SEQ_RESULT
|
||||
if (bots_sequential_flag || bots_check_flag)
|
||||
#else
|
||||
if (bots_sequential_flag)
|
||||
#endif
|
||||
{
|
||||
bots_sequential_flag = 1;
|
||||
KERNEL_SEQ_INIT;
|
||||
#ifdef BOTS_APP_SELF_TIMING
|
||||
bots_time_sequential = KERNEL_SEQ_CALL;
|
||||
#else
|
||||
bots_t_start = bots_usecs();
|
||||
KERNEL_SEQ_CALL;
|
||||
bots_t_end = bots_usecs();
|
||||
bots_time_sequential = ((double)(bots_t_end-bots_t_start))/1000000;
|
||||
#endif
|
||||
KERNEL_SEQ_FINI;
|
||||
}
|
||||
#endif
|
||||
|
||||
KERNEL_INIT;
|
||||
#ifdef BOTS_APP_SELF_TIMING
|
||||
bots_time_program = KERNEL_CALL;
|
||||
#else
|
||||
bots_t_start = bots_usecs();
|
||||
KERNEL_CALL;
|
||||
bots_t_end = bots_usecs();
|
||||
bots_time_program = ((double)(bots_t_end-bots_t_start))/1000000;
|
||||
#endif
|
||||
KERNEL_FINI;
|
||||
|
||||
#ifdef KERNEL_CHECK
|
||||
if (bots_check_flag) {
|
||||
bots_result = KERNEL_CHECK;
|
||||
}
|
||||
#endif
|
||||
|
||||
BOTS_APP_FINI;
|
||||
|
||||
bots_print_results();
|
||||
switch(bots_result) {
|
||||
case BOTS_RESULT_NA:
|
||||
throw wfr::exception::wfr_fatal_error("BOTS_RESULT_NA");
|
||||
case BOTS_RESULT_SUCCESSFUL:
|
||||
break;
|
||||
case BOTS_RESULT_UNSUCCESSFUL:
|
||||
throw wfr::exception::wfr_fatal_error("BOTS_RESULT_UNSUCCESSFUL");
|
||||
case BOTS_RESULT_NOT_REQUESTED:
|
||||
break;
|
||||
default:
|
||||
throw wfr::exception::wfr_fatal_error("unknown bots results");
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#define BOTS_PARAM_TYPE_NONE 0
|
||||
#define BOTS_PARAM_TYPE_INT 1
|
||||
#define BOTS_PARAM_TYPE_BOOL 2
|
||||
#define BOTS_PARAM_TYPE_STR 3
|
||||
|
||||
#ifdef _OPENMP
|
||||
# include <omp.h>
|
||||
#else
|
||||
# define omp_get_max_threads() 1
|
||||
# define omp_get_thread_num() 0
|
||||
# define omp_set_num_threads(x)
|
||||
#endif
|
||||
|
||||
void bots_print_usage(void);
|
||||
void bots_print_usage_option(char opt, int type, char* description, char *val, int subc, char **subv);
|
||||
|
||||
/***********************************************************************
|
||||
* BENCHMARK HEADERS
|
||||
*********************************************************************/
|
||||
void bots_initialize();
|
||||
void bots_finalize();
|
||||
void bots_sequential_ini();
|
||||
long bots_sequential();
|
||||
void bots_sequential_fini();
|
||||
int bots_check_result();
|
||||
void bots_print_usage_specific();
|
||||
void bots_get_params_specific(int argc, char **argv);
|
||||
void bots_set_info();
|
||||
|
||||
void bots_get_params_common(int argc, char **argv);
|
||||
void bots_get_params(int argc, char **argv);
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
/**********************************************************************************************/
|
||||
/* This program is part of the Barcelona OpenMP Tasks Suite */
|
||||
/* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */
|
||||
/* Copyright (C) 2009 Universitat Politecnica de Catalunya */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License, or */
|
||||
/* (at your option) any later version. */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
/**********************************************************************************************/
|
||||
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#define MODEL OMP-TASKS
|
||||
|
||||
#ifdef FORCE_TIED_TASKS
|
||||
#define BOTS_MODEL_DESC "OpenMP (using tied tasks)"
|
||||
#else
|
||||
#define BOTS_MODEL_DESC "OpenMP (using tasks)"
|
||||
#endif
|
||||
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#ifndef SPARSELU_H
|
||||
#define SPARSELU_H
|
||||
|
||||
#define EPSILON 1.0E-6
|
||||
|
||||
int checkmat (float *M, float *N);
|
||||
void genmat (float *M[]);
|
||||
void print_structure(char *name, float *M[]);
|
||||
float * allocate_clean_block();
|
||||
void lu0(float *diag);
|
||||
void bdiv(float *diag, float *row);
|
||||
void bmod(float *row, float *col, float *inner);
|
||||
void fwd(float *diag, float *col);
|
||||
|
||||
void sparselu_init (float ***pBENCH, char *pass);
|
||||
void sparselu(float **BENCH);
|
||||
void sparselu_fini (float **BENCH, char *pass);
|
||||
|
||||
void sparselu_seq_call(float **BENCH);
|
||||
void sparselu_par_call(float **BENCH, int argc, char* argv[]);
|
||||
|
||||
int sparselu_check(float **SEQ, float **BENCH);
|
||||
|
||||
#endif
|
||||
Executable
+289
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* sparselu_funcs.cpp
|
||||
*
|
||||
* Created on: 30.09.2014
|
||||
* Author: matthias
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <libgen.h>
|
||||
#include "bots.h"
|
||||
#include "sparselu.h"
|
||||
|
||||
/***********************************************************************
|
||||
* checkmat:
|
||||
**********************************************************************/
|
||||
int checkmat (float *M, float *N)
|
||||
{
|
||||
int i, j;
|
||||
float r_err;
|
||||
|
||||
for (i = 0; i < bots_arg_size_1; i++)
|
||||
{
|
||||
for (j = 0; j < bots_arg_size_1; j++)
|
||||
{
|
||||
r_err = M[i*bots_arg_size_1+j] - N[i*bots_arg_size_1+j];
|
||||
if ( r_err == 0.0 ) continue;
|
||||
|
||||
if (r_err < 0.0 ) r_err = -r_err;
|
||||
|
||||
if ( M[i*bots_arg_size_1+j] == 0 )
|
||||
{
|
||||
bots_message("Checking failure: A[%d][%d]=%f B[%d][%d]=%f; \n",
|
||||
i,j, M[i*bots_arg_size_1+j], i,j, N[i*bots_arg_size_1+j]);
|
||||
return FALSE;
|
||||
}
|
||||
r_err = r_err / M[i*bots_arg_size_1+j];
|
||||
if(r_err > EPSILON)
|
||||
{
|
||||
bots_message("Checking failure: A[%d][%d]=%f B[%d][%d]=%f; Relative Error=%f\n",
|
||||
i,j, M[i*bots_arg_size_1+j], i,j, N[i*bots_arg_size_1+j], r_err);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
/***********************************************************************
|
||||
* genmat:
|
||||
**********************************************************************/
|
||||
void genmat (float *M[])
|
||||
{
|
||||
int null_entry, init_val, i, j, ii, jj;
|
||||
float *p;
|
||||
int a=0,b=0;
|
||||
|
||||
init_val = 1325;
|
||||
|
||||
/* generating the structure */
|
||||
for (ii=0; ii < bots_arg_size; ii++)
|
||||
{
|
||||
for (jj=0; jj < bots_arg_size; jj++)
|
||||
{
|
||||
/* computing null entries */
|
||||
null_entry=FALSE;
|
||||
if ((ii<jj) && (ii%3 !=0)) null_entry = TRUE;
|
||||
if ((ii>jj) && (jj%3 !=0)) null_entry = TRUE;
|
||||
if (ii%2==1) null_entry = TRUE;
|
||||
if (jj%2==1) null_entry = TRUE;
|
||||
if (ii==jj) null_entry = FALSE;
|
||||
if (ii==jj-1) null_entry = FALSE;
|
||||
if (ii-1 == jj) null_entry = FALSE;
|
||||
/* allocating matrix */
|
||||
if (null_entry == FALSE){
|
||||
a++;
|
||||
M[ii*bots_arg_size+jj] = (float *) malloc(bots_arg_size_1*bots_arg_size_1*sizeof(float));
|
||||
if ((M[ii*bots_arg_size+jj] == NULL))
|
||||
{
|
||||
bots_message("Error: Out of memory\n");
|
||||
exit(101);
|
||||
}
|
||||
/* initializing matrix */
|
||||
p = M[ii*bots_arg_size+jj];
|
||||
for (i = 0; i < bots_arg_size_1; i++)
|
||||
{
|
||||
for (j = 0; j < bots_arg_size_1; j++)
|
||||
{
|
||||
init_val = (3125 * init_val) % 65536;
|
||||
(*p) = (float)((init_val - 32768.0) / 16384.0);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b++;
|
||||
M[ii*bots_arg_size+jj] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
bots_debug("allo = %d, no = %d, total = %d, factor = %f\n",a,b,a+b,(float)((float)a/(float)(a+b)));
|
||||
}
|
||||
/***********************************************************************
|
||||
* print_structure:
|
||||
**********************************************************************/
|
||||
void print_structure(char *name, float *M[])
|
||||
{
|
||||
int ii, jj;
|
||||
//bots_message("Structure for matrix %s @ 0x%p\n",name, M);
|
||||
for (ii = 0; ii < bots_arg_size; ii++) {
|
||||
for (jj = 0; jj < bots_arg_size; jj++) {
|
||||
if (M[ii*bots_arg_size+jj]!=NULL) {bots_message("x");}
|
||||
else bots_message(" ");
|
||||
}
|
||||
bots_message("\n");
|
||||
}
|
||||
bots_message("\n");
|
||||
}
|
||||
/***********************************************************************
|
||||
* allocate_clean_block:
|
||||
**********************************************************************/
|
||||
float * allocate_clean_block()
|
||||
{
|
||||
int i,j;
|
||||
float *p, *q;
|
||||
|
||||
p = (float *) malloc(bots_arg_size_1*bots_arg_size_1*sizeof(float));
|
||||
q=p;
|
||||
if (p!=NULL){
|
||||
for (i = 0; i < bots_arg_size_1; i++)
|
||||
for (j = 0; j < bots_arg_size_1; j++){(*p)=0.0; p++;}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bots_message("Error: Out of memory\n");
|
||||
exit (101);
|
||||
}
|
||||
return (q);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* lu0:
|
||||
**********************************************************************/
|
||||
void lu0(float *diag)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (k=0; k<bots_arg_size_1; k++)
|
||||
for (i=k+1; i<bots_arg_size_1; i++)
|
||||
{
|
||||
diag[i*bots_arg_size_1+k] = diag[i*bots_arg_size_1+k] / diag[k*bots_arg_size_1+k];
|
||||
for (j=k+1; j<bots_arg_size_1; j++)
|
||||
diag[i*bots_arg_size_1+j] = diag[i*bots_arg_size_1+j] - diag[i*bots_arg_size_1+k] * diag[k*bots_arg_size_1+j];
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* bdiv:
|
||||
**********************************************************************/
|
||||
void bdiv(float *diag, float *row)
|
||||
{
|
||||
int i, j, k;
|
||||
for (i=0; i<bots_arg_size_1; i++)
|
||||
for (k=0; k<bots_arg_size_1; k++)
|
||||
{
|
||||
row[i*bots_arg_size_1+k] = row[i*bots_arg_size_1+k] / diag[k*bots_arg_size_1+k];
|
||||
for (j=k+1; j<bots_arg_size_1; j++)
|
||||
row[i*bots_arg_size_1+j] = row[i*bots_arg_size_1+j] - row[i*bots_arg_size_1+k]*diag[k*bots_arg_size_1+j];
|
||||
}
|
||||
}
|
||||
/***********************************************************************
|
||||
* bmod:
|
||||
**********************************************************************/
|
||||
void bmod(float *row, float *col, float *inner)
|
||||
{
|
||||
int i, j, k;
|
||||
for (i=0; i<bots_arg_size_1; i++)
|
||||
for (j=0; j<bots_arg_size_1; j++)
|
||||
for (k=0; k<bots_arg_size_1; k++)
|
||||
inner[i*bots_arg_size_1+j] = inner[i*bots_arg_size_1+j] - row[i*bots_arg_size_1+k]*col[k*bots_arg_size_1+j];
|
||||
}
|
||||
/***********************************************************************
|
||||
* fwd:
|
||||
**********************************************************************/
|
||||
void fwd(float *diag, float *col)
|
||||
{
|
||||
int i, j, k;
|
||||
for (j=0; j<bots_arg_size_1; j++)
|
||||
for (k=0; k<bots_arg_size_1; k++)
|
||||
for (i=k+1; i<bots_arg_size_1; i++)
|
||||
col[i*bots_arg_size_1+j] = col[i*bots_arg_size_1+j] - diag[i*bots_arg_size_1+k]*col[k*bots_arg_size_1+j];
|
||||
}
|
||||
|
||||
void sparselu_init (float ***pBENCH, char *pass)
|
||||
{
|
||||
*pBENCH = (float **) malloc(bots_arg_size*bots_arg_size*sizeof(float *));
|
||||
genmat(*pBENCH);
|
||||
print_structure(pass, *pBENCH);
|
||||
}
|
||||
|
||||
|
||||
void sparselu_seq_call(float **BENCH)
|
||||
{
|
||||
int ii, jj, kk;
|
||||
|
||||
for (kk=0; kk<bots_arg_size; kk++)
|
||||
{
|
||||
lu0(BENCH[kk*bots_arg_size+kk]);
|
||||
for (jj=kk+1; jj<bots_arg_size; jj++)
|
||||
if (BENCH[kk*bots_arg_size+jj] != NULL)
|
||||
{
|
||||
fwd(BENCH[kk*bots_arg_size+kk], BENCH[kk*bots_arg_size+jj]);
|
||||
}
|
||||
for (ii=kk+1; ii<bots_arg_size; ii++)
|
||||
if (BENCH[ii*bots_arg_size+kk] != NULL)
|
||||
{
|
||||
bdiv (BENCH[kk*bots_arg_size+kk], BENCH[ii*bots_arg_size+kk]);
|
||||
}
|
||||
for (ii=kk+1; ii<bots_arg_size; ii++)
|
||||
if (BENCH[ii*bots_arg_size+kk] != NULL)
|
||||
for (jj=kk+1; jj<bots_arg_size; jj++)
|
||||
if (BENCH[kk*bots_arg_size+jj] != NULL)
|
||||
{
|
||||
if (BENCH[ii*bots_arg_size+jj]==NULL) BENCH[ii*bots_arg_size+jj] = allocate_clean_block();
|
||||
bmod(BENCH[ii*bots_arg_size+kk], BENCH[kk*bots_arg_size+jj], BENCH[ii*bots_arg_size+jj]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sparselu_fini (float **BENCH, char *pass)
|
||||
{
|
||||
print_structure(pass, BENCH);
|
||||
}
|
||||
|
||||
int sparselu_check(float **SEQ, float **BENCH)
|
||||
{
|
||||
int ii,jj,ok=1;
|
||||
|
||||
for (ii=0; ((ii<bots_arg_size) && ok); ii++)
|
||||
{
|
||||
for (jj=0; ((jj<bots_arg_size) && ok); jj++)
|
||||
{
|
||||
if ((SEQ[ii*bots_arg_size+jj] == NULL) && (BENCH[ii*bots_arg_size+jj] != NULL)) ok = FALSE;
|
||||
if ((SEQ[ii*bots_arg_size+jj] != NULL) && (BENCH[ii*bots_arg_size+jj] == NULL)) ok = FALSE;
|
||||
if ((SEQ[ii*bots_arg_size+jj] != NULL) && (BENCH[ii*bots_arg_size+jj] != NULL)) {
|
||||
ok = checkmat(SEQ[ii*bots_arg_size+jj], BENCH[ii*bots_arg_size+jj]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ok) return BOTS_RESULT_SUCCESSFUL;
|
||||
else return BOTS_RESULT_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
#include "sparselu-wfr.h"
|
||||
extern int wfstart(toplevel_in &wfInput, toplevel_out &wfOutput, int argc, char** argv);
|
||||
|
||||
void sparselu_par_call(float **BENCH, int argc, char* argv[]) {
|
||||
int tmax = 8;
|
||||
char* tmaxenv = getenv("WFR_TMAX");
|
||||
if (tmaxenv != NULL) {
|
||||
tmax = atoi(tmaxenv);
|
||||
}
|
||||
printf("TMAX = %d\n", tmax);
|
||||
|
||||
bots_message("Computing SparseLU Factorization (%dx%d matrix with %dx%d blocks) ",
|
||||
bots_arg_size,bots_arg_size,bots_arg_size_1,bots_arg_size_1);
|
||||
|
||||
toplevel_in wfInput;
|
||||
toplevel_out wfOutput;
|
||||
|
||||
// Fill workflow input struct
|
||||
wfInput.BENCH.setValue(BENCH);
|
||||
wfInput.bots_arg_size.setValue(bots_arg_size);
|
||||
wfInput.toplevelForCounterMax.setValue(bots_arg_size-1);
|
||||
wfInput.tmax.setValue(tmax-1);
|
||||
|
||||
|
||||
wfstart(wfInput, wfOutput, argc, argv);
|
||||
// Do something with workflow output
|
||||
|
||||
}
|
||||
|
||||
Executable
+81
@@ -0,0 +1,81 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <omp.h>
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
long N = 2000;
|
||||
long iterMax = 100;
|
||||
long chunksize = -1;
|
||||
boost::program_options::options_description opts("Wavefront Options");
|
||||
opts.add_options()
|
||||
("help", "Print help message.")
|
||||
("itermax", boost::program_options::value<long>(), "Iteration count.")
|
||||
("n", boost::program_options::value<long>(), "Array size (n+1 x n+1).")
|
||||
("chunksize", boost::program_options::value<long>(), "Chunk size.");
|
||||
boost::program_options::variables_map vm;
|
||||
auto parsed = boost::program_options::command_line_parser(argc, argv).options(opts).allow_unregistered().run();
|
||||
boost::program_options::store(parsed, vm);
|
||||
boost::program_options::notify(vm);
|
||||
if (vm.count("help")) {
|
||||
std::cerr << opts << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
if (vm.count("itermax")) {
|
||||
iterMax = vm["itermax"].as<long>();
|
||||
}
|
||||
if (vm.count("n")) {
|
||||
N = vm["n"].as<long>();
|
||||
}
|
||||
if (vm.count("chunksize")) {
|
||||
chunksize = vm["chunksize"].as<long>();
|
||||
}
|
||||
long _2N2 = 2*N-2;
|
||||
if (chunksize <= 0) {
|
||||
chunksize = (_2N2/8)+1;
|
||||
}
|
||||
std::cerr << "itermax = " << iterMax << std::endl;
|
||||
std::cerr << "N = " << N << std::endl;
|
||||
std::cerr << "chunksize = " << chunksize << std::endl;
|
||||
#define Idx2D(x, y) (x)*(N+1)+(y)
|
||||
double* mat_b = (double*)malloc(sizeof(double)*(N+1)*(N+1));
|
||||
//srand(time(NULL));
|
||||
srand(20);
|
||||
for(int i=0; i<N; ++i) {
|
||||
for(int j=0; j<N; ++j) {
|
||||
mat_b[Idx2D(i, j)] = ((double)(rand() % 100) / (double)RAND_MAX) * 1000000.0;
|
||||
}
|
||||
}
|
||||
|
||||
double t = omp_get_wtime();
|
||||
int numThreads = 0;
|
||||
omp_set_schedule(omp_sched_dynamic, chunksize);
|
||||
#pragma omp parallel
|
||||
{
|
||||
numThreads = omp_get_num_threads();
|
||||
for(int iter=0; iter<iterMax; ++iter) {
|
||||
#pragma omp for schedule(runtime)
|
||||
for(int i=1; i<2*N-2; ++i) {
|
||||
if(i<N) {
|
||||
for(int j=1; j<=i; ++j) {
|
||||
int x = i-j+1;
|
||||
double old = mat_b[Idx2D(x, j)];
|
||||
mat_b[Idx2D(x, j)] = 0.8*old + 0.2*0.25*mat_b[Idx2D(x-1, j)]*mat_b[Idx2D(x+1, j)]*mat_b[Idx2D(x, j-1)]*mat_b[Idx2D(x, j+1)];
|
||||
}
|
||||
} else {
|
||||
for(int j=i-N+2; j<N; ++j) {
|
||||
int x = i-j+1;
|
||||
double old = mat_b[Idx2D(x, j)];
|
||||
mat_b[Idx2D(x, j)] = 0.9*old + 0.1*0.25*mat_b[Idx2D(x-1, j)]*mat_b[Idx2D(x+1, j)]*mat_b[Idx2D(x, j-1)]*mat_b[Idx2D(x, j+1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("OMP Complete: %8.4lf\n", omp_get_wtime()-t);
|
||||
printf("Used %d cores.\n", numThreads);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user