1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2025-03-25 09:37:10 +00:00

Remove unused files

This commit is contained in:
Steffo 2022-11-28 17:02:03 +01:00
parent 2bcfb17f7d
commit 9972695a9f
Signed by: steffo
GPG key ID: 6965406171929D01
156 changed files with 4 additions and 3539242 deletions

Binary file not shown.

Before

(image error) Size: 5.6 KiB

Binary file not shown.

Before

(image error) Size: 4.8 KiB

View file

@ -8,21 +8,21 @@ Per compilare il codice a noi assegnato, è necessario:
1. Accedere alla cartella in cui è contenuto:
```console
$ cd ./OpenMP/linear-algebra/kernels/atax
$ cd ./atax
```
2. Eseguire il Makefile:
```console
$ make clean all
$ make atax.elf
```
## Come debuggare e profilare
Ho configurato il [Makefile](OpenMP/linear-algebra/kernels/atax/Makefile) con un phony target che esegue il programma 9 volte e calcola il tempo di esecuzione medio:
Ho configurato il [Makefile](OpenMP/linear-algebra/kernels/atax/Makefile) con un phony target che esegue il programma 25 volte e calcola il tempo di esecuzione medio:
1. Accedere alla cartella in cui è contenuto:
```console
$ cd ./OpenMP/linear-algebra/kernels/atax
$ cd ./atax
```
2. Eseguire il Makefile:

View file

@ -1,85 +0,0 @@
# PolyBench/GPU-OpenMP 1.0
> Copyright (c) 2013 the University of Delaware.
> Contact: William Killian <killian@udel.edu>
> Copyright (c) 2011-2012 the Ohio State University.
> Contact: Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
## Available Benchmarks
### `datamining`
* `datamining/correlation`
* `datamining/covariance`
### `linear-algebra/kernels`
* `linear-algebra/kernels/2mm`
* `linear-algebra/kernels/3mm`
* `linear-algebra/kernels/atax`
* `linear-algebra/kernels/bicg`
* `linear-algebra/kernels/cholesky`
* `linear-algebra/kernels/doitgen`
* `linear-algebra/kernels/gemm`
* `linear-algebra/kernels/gemver`
* `linear-algebra/kernels/gesummv`
* `linear-algebra/kernels/mvt`
* `linear-algebra/kernels/symm`
* `linear-algebra/kernels/syr2k`
* `linear-algebra/kernels/syrk`
* `linear-algebra/kernels/trisolv`
* `linear-algebra/kernels/trmm`
### `linear-algebra/solvers`
* `linear-algebra/solvers/durbin`
* `linear-algebra/solvers/dynprog`
* `linear-algebra/solvers/gramschmidt`
* `linear-algebra/solvers/lu`
* `linear-algebra/solvers/ludcmp`
### `stencils`
* `stencils/adi`
* `stencils/convolution-2d`
* `stencils/convolution-3d`
* `stencils/fdtd-2d`
* `stencils/jacobi-1d-imper`
* `stencils/jacobi-2d-imper`
* `stencils/seidel-2d`
## Modifying Codes
Parameters such as the input sizes, data type, and threshold for GPU-CPU output comparison can be modified using constants
within the codes and .h files. After modifying, run `make clean` then `make` on relevant code for modifications to take effect in resulting executable.
### Parameter Configuration
#### Input Size
By default the `STANDARD_DATASET` as defined in the `.cuh/.h` file is used as the input size. The dataset choice can be adjusted from `STANDARD_DATASET` to other
options (`MINI_DATASET`, `SMALL_DATASET`, etc) in the `.cuh/.h` file, the dataset size can be adjusted by defining the input size manually in the `.cuh/.h` file, or
the input size can be changed by simply adjusting the `STANDARD_DATASET` so the program has different input dimensions.
#### `DATA_TYPE` (in `.cuh/.h` files):
By default, the `DATA_TYPE` used in these codes are `float` that can be changed to `double` by changing the `DATA_TYPE` typedef. Note that in OpenCL, the `DATA_TYPE` needs to be changed in both the .h and .cl files, as the .cl files contain the kernel code and is compiled separately at run-time.
#### Other available options
These are passed as macro definitions during compilation time
(e.g `-Dname_of_the_option`) or can be added with a `#define` to the code.
- `POLYBENCH_STACK_ARRAYS` (only applies to allocation on host):
use stack allocation instead of malloc [default: off]
- `POLYBENCH_DUMP_ARRAYS`: dump all live-out arrays on stderr [default: off]
- `POLYBENCH_CYCLE_ACCURATE_TIMER`: Use Time Stamp Counter to monitor
the execution time of the kernel [default: off]
- `MINI_DATASET`, `SMALL_DATASET`, `STANDARD_DATASET`, `LARGE_DATASET`,
`EXTRALARGE_DATASET`: set the dataset size to be used
[default: `STANDARD_DATASET`]
- `POLYBENCH_USE_C99_PROTO`: Use standard C99 prototype for the functions.
- `POLYBENCH_USE_SCALAR_LB`: Use scalar loop bounds instead of parametric ones.

View file

@ -1,14 +0,0 @@
# C compiler
CC = g++
CC_FLAGS = -g -fopenmp -O2
all: bfs
bfs: bfs.cpp
$(CC) $(CC_FLAGS) bfs.cpp -o bfs
clean:
rm -f bfs bfs_offload result.txt
run: bfs
./run

View file

@ -1,171 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <omp.h>
FILE *fp;
//Structure to hold a node information
struct Node
{
int starting;
int no_of_edges;
};
void BFSGraph(int argc, char** argv);
void Usage(int argc, char**argv){
fprintf(stderr,"Usage: %s <num_threads> <input_file>\n", argv[0]);
}
////////////////////////////////////////////////////////////////////////////////
// Main Program
////////////////////////////////////////////////////////////////////////////////
int main( int argc, char** argv)
{
BFSGraph( argc, argv);
}
////////////////////////////////////////////////////////////////////////////////
//Apply BFS on a Graph using CUDA
////////////////////////////////////////////////////////////////////////////////
void BFSGraph( int argc, char** argv)
{
int no_of_nodes = 0;
int edge_list_size = 0;
char *input_f;
int num_omp_threads;
if(argc!=3){
Usage(argc, argv);
exit(0);
}
num_omp_threads = atoi(argv[1]);
input_f = argv[2];
printf("Reading File\n");
//Read in Graph from a file
fp = fopen(input_f,"r");
if(!fp)
{
printf("Error Reading graph file\n");
return;
}
int source = 0;
fscanf(fp,"%d",&no_of_nodes);
// allocate host memory
Node* h_graph_nodes = (Node*) malloc(sizeof(Node)*no_of_nodes);
bool *h_graph_mask = (bool*) malloc(sizeof(bool)*no_of_nodes);
bool *h_updating_graph_mask = (bool*) malloc(sizeof(bool)*no_of_nodes);
bool *h_graph_visited = (bool*) malloc(sizeof(bool)*no_of_nodes);
int start, edgeno;
// initalize the memory
for( unsigned int i = 0; i < no_of_nodes; i++)
{
fscanf(fp,"%d %d",&start,&edgeno);
h_graph_nodes[i].starting = start;
h_graph_nodes[i].no_of_edges = edgeno;
h_graph_mask[i]=false;
h_updating_graph_mask[i]=false;
h_graph_visited[i]=false;
}
//read the source node from the file
fscanf(fp,"%d",&source);
// source=0; //tesing code line
//set the source node as true in the mask
h_graph_mask[source]=true;
h_graph_visited[source]=true;
fscanf(fp,"%d",&edge_list_size);
int id,cost;
int* h_graph_edges = (int*) malloc(sizeof(int)*edge_list_size);
for(int i=0; i < edge_list_size ; i++)
{
fscanf(fp,"%d",&id);
fscanf(fp,"%d",&cost);
h_graph_edges[i] = id;
}
if(fp)
fclose(fp);
// allocate mem for the result on host side
int* h_cost = (int*) malloc( sizeof(int)*no_of_nodes);
for(int i=0;i<no_of_nodes;i++)
h_cost[i]=-1;
h_cost[source]=0;
printf("Start traversing the tree\n");
int k=0;
double start_time = omp_get_wtime();
bool stop;
do
{
//if no thread changes this value then the loop stops
stop=false;
for(int tid = 0; tid < no_of_nodes; tid++ )
{
if (h_graph_mask[tid] == true){
h_graph_mask[tid]=false;
for(int i=h_graph_nodes[tid].starting; i<(h_graph_nodes[tid].no_of_edges + h_graph_nodes[tid].starting); i++)
{
int id = h_graph_edges[i];
if(!h_graph_visited[id])
{
h_cost[id]=h_cost[tid]+1;
h_updating_graph_mask[id]=true;
}
}
}
}
for(int tid=0; tid< no_of_nodes ; tid++ )
{
if (h_updating_graph_mask[tid] == true){
h_graph_mask[tid]=true;
h_graph_visited[tid]=true;
stop=true;
h_updating_graph_mask[tid]=false;
}
}
k++;
}
while(stop);
double end_time = omp_get_wtime();
printf("Compute time: %lf\n", (end_time - start_time));
//Store the result into a file
FILE *fpo = fopen("result.txt","w");
for(int i=0;i<no_of_nodes;i++)
fprintf(fpo,"%d) cost:%d\n",i,h_cost[i]);
fclose(fpo);
printf("Result stored in result.txt\n");
// cleanup memory
free( h_graph_nodes);
free( h_graph_edges);
free( h_graph_mask);
free( h_updating_graph_mask);
free( h_graph_visited);
free( h_cost);
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,8 +0,0 @@
FLAGS := -std=c++0x -fopenmp
graphgen: graphgen.cpp
g++ $(FLAGS) -o $@ $<
clean:
rm graphgen

View file

@ -1,18 +0,0 @@
#!/bin/bash
./graphgen 1024 1k
./graphgen 2048 2k
./graphgen 4096 4k
./graphgen 8192 8k
./graphgen 16384 16k
./graphgen 32768 32k
./graphgen 65536 64k
./graphgen 131072 128k
./graphgen 261444 256k
./graphgen 524288 512k
./graphgen 1048576 1M
./graphgen 2097152 2M
./graphgen 4194304 4M
./graphgen 8388608 8M
./graphgen 16777216 16M

View file

@ -1,125 +0,0 @@
/*
* graphgen.cpp
* by Sam Kauffman - Univeristy of Virginia
*
* This program generates graphs of the format described in GraphFormat.txt
* and SampleGraph.jpg for use with BFS (breadth-first search) in Rodinia.
*
* The graph is not guaranteed to be connected, are there may be multiple edges
* and loops.
*
* Usage:
* graphgen <num> [<filename_bit>]
* num = number of nodes
* Output filename is "graph<filename_bit>.txt". filename_bit defaults to num.
*
* This program uses the TR1 header <random>.
*
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <random>
#include <cstdlib>
#include <ctime>
#include <climits>
// These names may vary by implementation
#define LINEAR_CONGRUENTIAL_ENGINE linear_congruential_engine
//#define LINEAR_CONGRUENTIAL_ENGINE linear_congruential
#define UNIFORM_INT_DISTRIBUTION uniform_int_distribution
//#define UNIFORM_INT_DISTRIBUTION uniform_int
using namespace std;
#define MIN_NODES 20
#define MAX_NODES ULONG_MAX
#define MIN_EDGES 2
#define MAX_INIT_EDGES 4 // Nodes will have, on average, 2*MAX_INIT_EDGES edges
#define MIN_WEIGHT 1
#define MAX_WEIGHT 10
typedef unsigned int uint;
typedef unsigned long ulong;
struct edge; // forward declaration
typedef vector<edge> node;
struct edge {
ulong dest;
uint weight;
};
int main( int argc, char ** argv )
{
// Parse command lined
ulong numNodes;
string s;
if ( argc < 2 )
{
cerr << "Error: enter a number of nodes.\n";
exit( 1 );
}
numNodes = strtoul( argv[1], NULL, 10 );
if ( numNodes < MIN_NODES || numNodes > MAX_NODES || argv[1][0] == '-' )
{
cerr << "Error: Invalid argument: " << argv[1] << "\n";
exit( 1 );
}
s = argc > 2 ? argv[2] : argv[1]; // filename bit
string filename = "graph" + s + ".txt";
cout << "Generating graph with " << numNodes << " nodes...\n";
node * graph;
graph = new node[numNodes];
// Initialize random number generators
// C RNG for numbers of edges and weights
srand( time( NULL ) );
// TR1 RNG for choosing edge destinations
LINEAR_CONGRUENTIAL_ENGINE<ulong, 48271, 0, ULONG_MAX> gen( time( NULL ) );
UNIFORM_INT_DISTRIBUTION<ulong> randNode( 0, numNodes - 1 );
// Generate graph
uint numEdges;
ulong nodeID;
uint weight;
ulong i;
uint j;
for ( i = 0; i < numNodes; i++ )
{
numEdges = rand() % ( MAX_INIT_EDGES - MIN_EDGES + 1 ) + MIN_EDGES;
for ( j = 0; j < numEdges; j++ )
{
nodeID = randNode( gen );
weight = rand() % ( MAX_WEIGHT - MIN_WEIGHT + 1 ) + MIN_WEIGHT;
graph[i].push_back( edge() );
graph[i].back().dest = nodeID;
graph[i].back().weight = weight;
graph[nodeID].push_back( edge() );
graph[nodeID].back().dest = i;
graph[nodeID].back().weight = weight;
}
}
// Output
cout << "Writing to file \"" << filename << "\"...\n";
ofstream outf( filename );
outf << numNodes << "\n";
ulong totalEdges = 0;
for ( uint i = 0; i < numNodes; i++ )
{
numEdges = graph[i].size();
outf << totalEdges << " " << numEdges << "\n";
totalEdges += numEdges;
}
outf << "\n" << randNode( gen ) << "\n\n";
outf << totalEdges << "\n";
for ( ulong i = 0; i < numNodes; i++ )
for ( uint j = 0; j < graph[i].size(); j++ )
outf << graph[i][j].dest << " " << graph[i][j].weight << "\n";
outf.close();
delete[] graph;
}

View file

@ -1 +0,0 @@
./bfs 4 data/graph1MW_6.txt

View file

@ -1,8 +0,0 @@
# CFD Solver
The CFD solver is an unstructured grid finite volume solver for the three-dimensional Euler equations for compressible flow. Effective GPU memory bandwidth is improved by reducing total global memory access and overlapping redundant computation, as well as using an appropriate numbering scheme and data layout.
We'd like to acknowledge Andrew Corrigan, Fernando Camelli, Rainald Lohner and John Wallin from George Mason University to contribute their codes to Rodinia.
For more details about this application, please visit http://web.cos.gmu.edu/~acorriga/pubs/gpu_cfd/
Paper: Andrew Corrigan, Fernando Camelli, Rainald Lohner and John Wallin. Running Unstructured Grid CFD Solvers on Modern Graphics Hardware. In Proceedings of the 19th AIAA Computational Fluid Dynamics Conference, June 2009.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,473 +0,0 @@
// Copyright 2009, Andrew Corrigan, acorriga@gmu.edu
// This code is from the AIAA-2009-4001 paper
#include <iostream>
#include <fstream>
#include <cmath>
#include <omp.h>
struct float3
{
float x, y, z;
};
#ifndef block_length
#define block_length 1
#endif
/*
* Options
*
*/
#define GAMMA 1.4
#define iterations 2000
#define NDIM 3
#define NNB 4
#define RK 3 // 3rd order RK
#define ff_mach 1.2
#define deg_angle_of_attack 0.0f
/*
* not options
*/
#define VAR_DENSITY 0
#define VAR_MOMENTUM 1
#define VAR_DENSITY_ENERGY (VAR_MOMENTUM + NDIM)
#define NVAR (VAR_DENSITY_ENERGY + 1)
#ifdef restrict
#define __restrict restrict
#else
#define __restrict
#endif
/*
* Generic functions
*/
template <typename T>
T *alloc(int N)
{
return new T[N];
}
template <typename T>
void dealloc(T *array)
{
delete[] array;
}
template <typename T>
void copy(T *dst, T *src, int N)
{
for (int i = 0; i < N; i++)
{
dst[i] = src[i];
}
}
void dump(float *variables, int nel, int nelr)
{
{
std::ofstream file("density");
file << nel << " " << nelr << std::endl;
for (int i = 0; i < nel; i++)
file << variables[i + VAR_DENSITY * nelr] << std::endl;
}
{
std::ofstream file("momentum");
file << nel << " " << nelr << std::endl;
for (int i = 0; i < nel; i++)
{
for (int j = 0; j != NDIM; j++)
file << variables[i + (VAR_MOMENTUM + j) * nelr] << " ";
file << std::endl;
}
}
{
std::ofstream file("density_energy");
file << nel << " " << nelr << std::endl;
for (int i = 0; i < nel; i++)
file << variables[i + VAR_DENSITY_ENERGY * nelr] << std::endl;
}
}
void initialize_variables(int nelr, float *variables, float *ff_variable)
{
for (int i = 0; i < nelr; i++)
{
for (int j = 0; j < NVAR; j++)
variables[i + j * nelr] = ff_variable[j];
}
}
inline void compute_flux_contribution(float &density, float3 &momentum, float &density_energy, float &pressure, float3 &velocity, float3 &fc_momentum_x, float3 &fc_momentum_y, float3 &fc_momentum_z, float3 &fc_density_energy)
{
fc_momentum_x.x = velocity.x * momentum.x + pressure;
fc_momentum_x.y = velocity.x * momentum.y;
fc_momentum_x.z = velocity.x * momentum.z;
fc_momentum_y.x = fc_momentum_x.y;
fc_momentum_y.y = velocity.y * momentum.y + pressure;
fc_momentum_y.z = velocity.y * momentum.z;
fc_momentum_z.x = fc_momentum_x.z;
fc_momentum_z.y = fc_momentum_y.z;
fc_momentum_z.z = velocity.z * momentum.z + pressure;
float de_p = density_energy + pressure;
fc_density_energy.x = velocity.x * de_p;
fc_density_energy.y = velocity.y * de_p;
fc_density_energy.z = velocity.z * de_p;
}
inline void compute_velocity(float &density, float3 &momentum, float3 &velocity)
{
velocity.x = momentum.x / density;
velocity.y = momentum.y / density;
velocity.z = momentum.z / density;
}
inline float compute_speed_sqd(float3 &velocity)
{
return velocity.x * velocity.x + velocity.y * velocity.y + velocity.z * velocity.z;
}
inline float compute_pressure(float &density, float &density_energy, float &speed_sqd)
{
return (float(GAMMA) - float(1.0f)) * (density_energy - float(0.5f) * density * speed_sqd);
}
inline float compute_speed_of_sound(float &density, float &pressure)
{
return std::sqrt(float(GAMMA) * pressure / density);
}
void compute_step_factor(int nelr, float *__restrict variables, float *areas, float *__restrict step_factors)
{
for (int blk = 0; blk < nelr / block_length; ++blk)
{
int b_start = blk * block_length;
int b_end = (blk + 1) * block_length > nelr ? nelr : (blk + 1) * block_length;
for (int i = b_start; i < b_end; i++)
{
float density = variables[i + VAR_DENSITY * nelr];
float3 momentum;
momentum.x = variables[i + (VAR_MOMENTUM + 0) * nelr];
momentum.y = variables[i + (VAR_MOMENTUM + 1) * nelr];
momentum.z = variables[i + (VAR_MOMENTUM + 2) * nelr];
float density_energy = variables[i + VAR_DENSITY_ENERGY * nelr];
float3 velocity;
compute_velocity(density, momentum, velocity);
float speed_sqd = compute_speed_sqd(velocity);
float pressure = compute_pressure(density, density_energy, speed_sqd);
float speed_of_sound = compute_speed_of_sound(density, pressure);
// dt = float(0.5f) * std::sqrt(areas[i]) / (||v|| + c).... but when we do time stepping, this later would need to be divided by the area, so we just do it all at once
step_factors[i] = float(0.5f) / (std::sqrt(areas[i]) * (std::sqrt(speed_sqd) + speed_of_sound));
}
}
}
/*
*
*
*/
void compute_flux(int nelr, int *elements_surrounding_elements, float *normals, float *variables, float *fluxes, float *ff_variable, float3 ff_flux_contribution_momentum_x, float3 ff_flux_contribution_momentum_y, float3 ff_flux_contribution_momentum_z, float3 ff_flux_contribution_density_energy)
{
const float smoothing_coefficient = float(0.2f);
for (int blk = 0; blk < nelr / block_length; ++blk)
{
int b_start = blk * block_length;
int b_end = (blk + 1) * block_length > nelr ? nelr : (blk + 1) * block_length;
for (int i = b_start; i < b_end; ++i)
{
float density_i = variables[i + VAR_DENSITY * nelr];
float3 momentum_i;
momentum_i.x = variables[i + (VAR_MOMENTUM + 0) * nelr];
momentum_i.y = variables[i + (VAR_MOMENTUM + 1) * nelr];
momentum_i.z = variables[i + (VAR_MOMENTUM + 2) * nelr];
float density_energy_i = variables[i + VAR_DENSITY_ENERGY * nelr];
float3 velocity_i;
compute_velocity(density_i, momentum_i, velocity_i);
float speed_sqd_i = compute_speed_sqd(velocity_i);
float speed_i = std::sqrt(speed_sqd_i);
float pressure_i = compute_pressure(density_i, density_energy_i, speed_sqd_i);
float speed_of_sound_i = compute_speed_of_sound(density_i, pressure_i);
float3 flux_contribution_i_momentum_x, flux_contribution_i_momentum_y, flux_contribution_i_momentum_z;
float3 flux_contribution_i_density_energy;
compute_flux_contribution(density_i, momentum_i, density_energy_i, pressure_i, velocity_i, flux_contribution_i_momentum_x, flux_contribution_i_momentum_y, flux_contribution_i_momentum_z, flux_contribution_i_density_energy);
float flux_i_density = float(0.0f);
float3 flux_i_momentum;
flux_i_momentum.x = float(0.0f);
flux_i_momentum.y = float(0.0f);
flux_i_momentum.z = float(0.0f);
float flux_i_density_energy = float(0.0f);
float3 velocity_nb;
float density_nb, density_energy_nb;
float3 momentum_nb;
float3 flux_contribution_nb_momentum_x, flux_contribution_nb_momentum_y, flux_contribution_nb_momentum_z;
float3 flux_contribution_nb_density_energy;
float speed_sqd_nb, speed_of_sound_nb, pressure_nb;
#pragma unroll
for (int j = 0; j < NNB; j++)
{
float3 normal;
float normal_len;
float factor;
int nb = elements_surrounding_elements[i + j * nelr];
normal.x = normals[i + (j + 0 * NNB) * nelr];
normal.y = normals[i + (j + 1 * NNB) * nelr];
normal.z = normals[i + (j + 2 * NNB) * nelr];
normal_len = std::sqrt(normal.x * normal.x + normal.y * normal.y + normal.z * normal.z);
if (nb >= 0) // a legitimate neighbor
{
density_nb = variables[nb + VAR_DENSITY * nelr];
momentum_nb.x = variables[nb + (VAR_MOMENTUM + 0) * nelr];
momentum_nb.y = variables[nb + (VAR_MOMENTUM + 1) * nelr];
momentum_nb.z = variables[nb + (VAR_MOMENTUM + 2) * nelr];
density_energy_nb = variables[nb + VAR_DENSITY_ENERGY * nelr];
compute_velocity(density_nb, momentum_nb, velocity_nb);
speed_sqd_nb = compute_speed_sqd(velocity_nb);
pressure_nb = compute_pressure(density_nb, density_energy_nb, speed_sqd_nb);
speed_of_sound_nb = compute_speed_of_sound(density_nb, pressure_nb);
compute_flux_contribution(density_nb, momentum_nb, density_energy_nb, pressure_nb, velocity_nb, flux_contribution_nb_momentum_x, flux_contribution_nb_momentum_y, flux_contribution_nb_momentum_z, flux_contribution_nb_density_energy);
// artificial viscosity
factor = -normal_len * smoothing_coefficient * float(0.5f) * (speed_i + std::sqrt(speed_sqd_nb) + speed_of_sound_i + speed_of_sound_nb);
flux_i_density += factor * (density_i - density_nb);
flux_i_density_energy += factor * (density_energy_i - density_energy_nb);
flux_i_momentum.x += factor * (momentum_i.x - momentum_nb.x);
flux_i_momentum.y += factor * (momentum_i.y - momentum_nb.y);
flux_i_momentum.z += factor * (momentum_i.z - momentum_nb.z);
// accumulate cell-centered fluxes
factor = float(0.5f) * normal.x;
flux_i_density += factor * (momentum_nb.x + momentum_i.x);
flux_i_density_energy += factor * (flux_contribution_nb_density_energy.x + flux_contribution_i_density_energy.x);
flux_i_momentum.x += factor * (flux_contribution_nb_momentum_x.x + flux_contribution_i_momentum_x.x);
flux_i_momentum.y += factor * (flux_contribution_nb_momentum_y.x + flux_contribution_i_momentum_y.x);
flux_i_momentum.z += factor * (flux_contribution_nb_momentum_z.x + flux_contribution_i_momentum_z.x);
factor = float(0.5f) * normal.y;
flux_i_density += factor * (momentum_nb.y + momentum_i.y);
flux_i_density_energy += factor * (flux_contribution_nb_density_energy.y + flux_contribution_i_density_energy.y);
flux_i_momentum.x += factor * (flux_contribution_nb_momentum_x.y + flux_contribution_i_momentum_x.y);
flux_i_momentum.y += factor * (flux_contribution_nb_momentum_y.y + flux_contribution_i_momentum_y.y);
flux_i_momentum.z += factor * (flux_contribution_nb_momentum_z.y + flux_contribution_i_momentum_z.y);
factor = float(0.5f) * normal.z;
flux_i_density += factor * (momentum_nb.z + momentum_i.z);
flux_i_density_energy += factor * (flux_contribution_nb_density_energy.z + flux_contribution_i_density_energy.z);
flux_i_momentum.x += factor * (flux_contribution_nb_momentum_x.z + flux_contribution_i_momentum_x.z);
flux_i_momentum.y += factor * (flux_contribution_nb_momentum_y.z + flux_contribution_i_momentum_y.z);
flux_i_momentum.z += factor * (flux_contribution_nb_momentum_z.z + flux_contribution_i_momentum_z.z);
}
else if (nb == -1) // a wing boundary
{
flux_i_momentum.x += normal.x * pressure_i;
flux_i_momentum.y += normal.y * pressure_i;
flux_i_momentum.z += normal.z * pressure_i;
}
else if (nb == -2) // a far field boundary
{
factor = float(0.5f) * normal.x;
flux_i_density += factor * (ff_variable[VAR_MOMENTUM + 0] + momentum_i.x);
flux_i_density_energy += factor * (ff_flux_contribution_density_energy.x + flux_contribution_i_density_energy.x);
flux_i_momentum.x += factor * (ff_flux_contribution_momentum_x.x + flux_contribution_i_momentum_x.x);
flux_i_momentum.y += factor * (ff_flux_contribution_momentum_y.x + flux_contribution_i_momentum_y.x);
flux_i_momentum.z += factor * (ff_flux_contribution_momentum_z.x + flux_contribution_i_momentum_z.x);
factor = float(0.5f) * normal.y;
flux_i_density += factor * (ff_variable[VAR_MOMENTUM + 1] + momentum_i.y);
flux_i_density_energy += factor * (ff_flux_contribution_density_energy.y + flux_contribution_i_density_energy.y);
flux_i_momentum.x += factor * (ff_flux_contribution_momentum_x.y + flux_contribution_i_momentum_x.y);
flux_i_momentum.y += factor * (ff_flux_contribution_momentum_y.y + flux_contribution_i_momentum_y.y);
flux_i_momentum.z += factor * (ff_flux_contribution_momentum_z.y + flux_contribution_i_momentum_z.y);
factor = float(0.5f) * normal.z;
flux_i_density += factor * (ff_variable[VAR_MOMENTUM + 2] + momentum_i.z);
flux_i_density_energy += factor * (ff_flux_contribution_density_energy.z + flux_contribution_i_density_energy.z);
flux_i_momentum.x += factor * (ff_flux_contribution_momentum_x.z + flux_contribution_i_momentum_x.z);
flux_i_momentum.y += factor * (ff_flux_contribution_momentum_y.z + flux_contribution_i_momentum_y.z);
flux_i_momentum.z += factor * (ff_flux_contribution_momentum_z.z + flux_contribution_i_momentum_z.z);
}
}
fluxes[i + VAR_DENSITY * nelr] = flux_i_density;
fluxes[i + (VAR_MOMENTUM + 0) * nelr] = flux_i_momentum.x;
fluxes[i + (VAR_MOMENTUM + 1) * nelr] = flux_i_momentum.y;
fluxes[i + (VAR_MOMENTUM + 2) * nelr] = flux_i_momentum.z;
fluxes[i + VAR_DENSITY_ENERGY * nelr] = flux_i_density_energy;
}
}
}
void time_step(int j, int nelr, float *old_variables, float *variables, float *step_factors, float *fluxes)
{
for (int blk = 0; blk < nelr / block_length; ++blk)
{
int b_start = blk * block_length;
int b_end = (blk + 1) * block_length > nelr ? nelr : (blk + 1) * block_length;
for (int i = b_start; i < b_end; ++i)
{
float factor = step_factors[i] / float(RK + 1 - j);
variables[i + VAR_DENSITY * nelr] = old_variables[i + VAR_DENSITY * nelr] + factor * fluxes[i + VAR_DENSITY * nelr];
variables[i + (VAR_MOMENTUM + 0) * nelr] = old_variables[i + (VAR_MOMENTUM + 0) * nelr] + factor * fluxes[i + (VAR_MOMENTUM + 0) * nelr];
variables[i + (VAR_MOMENTUM + 1) * nelr] = old_variables[i + (VAR_MOMENTUM + 1) * nelr] + factor * fluxes[i + (VAR_MOMENTUM + 1) * nelr];
variables[i + (VAR_MOMENTUM + 2) * nelr] = old_variables[i + (VAR_MOMENTUM + 2) * nelr] + factor * fluxes[i + (VAR_MOMENTUM + 2) * nelr];
variables[i + VAR_DENSITY_ENERGY * nelr] = old_variables[i + VAR_DENSITY_ENERGY * nelr] + factor * fluxes[i + VAR_DENSITY_ENERGY * nelr];
}
}
}
/*
* Main function
*/
int main(int argc, char **argv)
{
if (argc < 2)
{
std::cout << "specify data file name" << std::endl;
return 0;
}
const char *data_file_name = argv[1];
float ff_variable[NVAR];
float3 ff_flux_contribution_momentum_x, ff_flux_contribution_momentum_y, ff_flux_contribution_momentum_z, ff_flux_contribution_density_energy;
// set far field conditions
{
const float angle_of_attack = float(3.1415926535897931 / 180.0f) * float(deg_angle_of_attack);
ff_variable[VAR_DENSITY] = float(1.4);
float ff_pressure = float(1.0f);
float ff_speed_of_sound = sqrt(GAMMA * ff_pressure / ff_variable[VAR_DENSITY]);
float ff_speed = float(ff_mach) * ff_speed_of_sound;
float3 ff_velocity;
ff_velocity.x = ff_speed * float(cos((float)angle_of_attack));
ff_velocity.y = ff_speed * float(sin((float)angle_of_attack));
ff_velocity.z = 0.0f;
ff_variable[VAR_MOMENTUM + 0] = ff_variable[VAR_DENSITY] * ff_velocity.x;
ff_variable[VAR_MOMENTUM + 1] = ff_variable[VAR_DENSITY] * ff_velocity.y;
ff_variable[VAR_MOMENTUM + 2] = ff_variable[VAR_DENSITY] * ff_velocity.z;
ff_variable[VAR_DENSITY_ENERGY] = ff_variable[VAR_DENSITY] * (float(0.5f) * (ff_speed * ff_speed)) + (ff_pressure / float(GAMMA - 1.0f));
float3 ff_momentum;
ff_momentum.x = *(ff_variable + VAR_MOMENTUM + 0);
ff_momentum.y = *(ff_variable + VAR_MOMENTUM + 1);
ff_momentum.z = *(ff_variable + VAR_MOMENTUM + 2);
compute_flux_contribution(ff_variable[VAR_DENSITY], ff_momentum, ff_variable[VAR_DENSITY_ENERGY], ff_pressure, ff_velocity, ff_flux_contribution_momentum_x, ff_flux_contribution_momentum_y, ff_flux_contribution_momentum_z, ff_flux_contribution_density_energy);
}
int nel;
int nelr;
// read in domain geometry
float *areas;
int *elements_surrounding_elements;
float *normals;
{
std::ifstream file(data_file_name);
file >> nel;
nelr = block_length * ((nel / block_length) + std::min(1, nel % block_length));
areas = new float[nelr];
elements_surrounding_elements = new int[nelr * NNB];
normals = new float[NDIM * NNB * nelr];
// read in data
for (int i = 0; i < nel; i++)
{
file >> areas[i];
for (int j = 0; j < NNB; j++)
{
file >> elements_surrounding_elements[i + j * nelr];
if (elements_surrounding_elements[i + j * nelr] < 0)
elements_surrounding_elements[i + j * nelr] = -1;
elements_surrounding_elements[i + j * nelr]--; // it's coming in with Fortran numbering
for (int k = 0; k < NDIM; k++)
{
file >> normals[i + (j + k * NNB) * nelr];
normals[i + (j + k * NNB) * nelr] = -normals[i + (j + k * NNB) * nelr];
}
}
}
// fill in remaining data
int last = nel - 1;
for (int i = nel; i < nelr; i++)
{
areas[i] = areas[last];
for (int j = 0; j < NNB; j++)
{
// duplicate the last element
elements_surrounding_elements[i + j * nelr] = elements_surrounding_elements[last + j * nelr];
for (int k = 0; k < NDIM; k++)
normals[i + (j + k * NNB) * nelr] = normals[last + (j + k * NNB) * nelr];
}
}
}
// Create arrays and set initial conditions
float *variables = alloc<float>(nelr * NVAR);
initialize_variables(nelr, variables, ff_variable);
float *old_variables = alloc<float>(nelr * NVAR);
float *fluxes = alloc<float>(nelr * NVAR);
float *step_factors = alloc<float>(nelr);
// these need to be computed the first time in order to compute time step
std::cout << "Starting..." << std::endl;
// Begin iterations
for (int i = 0; i < iterations; i++)
{
copy<float>(old_variables, variables, nelr * NVAR);
// for the first iteration we compute the time step
compute_step_factor(nelr, variables, areas, step_factors);
for (int j = 0; j < RK; j++)
{
compute_flux(nelr, elements_surrounding_elements, normals, variables, fluxes, ff_variable, ff_flux_contribution_momentum_x, ff_flux_contribution_momentum_y, ff_flux_contribution_momentum_z, ff_flux_contribution_density_energy);
time_step(j, nelr, old_variables, variables, step_factors, fluxes);
}
}
std::cout << "Saving solution..." << std::endl;
dump(variables, nel, nelr);
std::cout << "Saved solution..." << std::endl;
std::cout << "Cleaning up..." << std::endl;
dealloc<float>(areas);
dealloc<int>(elements_surrounding_elements);
dealloc<float>(normals);
dealloc<float>(variables);
dealloc<float>(old_variables);
dealloc<float>(fluxes);
dealloc<float>(step_factors);
std::cout << "Done..." << std::endl;
return 0;
}

View file

@ -1,11 +0,0 @@
all: euler3d_cpu
euler3d_cpu: euler3d_cpu.cpp
g++ -O3 -fopenmp euler3d_cpu.cpp -o euler3d_cpu
run: euler3d_cpu
./run
clean:
rm -rf euler3d_cpu
rm -rf density density_energy momentum

View file

@ -1 +0,0 @@
./euler3d_cpu data/fvcorr.domn.193K

View file

@ -1,27 +0,0 @@
# C compiler
CC = gcc
CC_FLAGS = -g -fopenmp -O2
kmeans: cluster.o getopt.o kmeans.o kmeans_clustering.o
$(CC) $(CC_FLAGS) cluster.o getopt.o kmeans.o kmeans_clustering.o -o kmeans
%.o: %.[ch]
$(CC) $(CC_FLAGS) $< -c
cluster.o: cluster.c
$(CC) $(CC_FLAGS) cluster.c -c
getopt.o: getopt.c
$(CC) $(CC_FLAGS) getopt.c -c
kmeans.o: kmeans.c
$(CC) $(CC_FLAGS) kmeans.c -c
kmeans_clustering.o: kmeans_clustering.c kmeans.h
$(CC) $(CC_FLAGS) kmeans_clustering.c -c
clean:
rm -f *.o *~ kmeans
run: kmeans
./run

View file

@ -1,5 +0,0 @@
Usage: ./kmeans [switches] -i filename
-i filename : file containing data to be clustered
-b : input file is in binary format
-k : number of clusters (default is 8)
-t threshold : threshold value

View file

@ -1,112 +0,0 @@
/*****************************************************************************/
/*IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. */
/*By downloading, copying, installing or using the software you agree */
/*to this license. If you do not agree to this license, do not download, */
/*install, copy or use the software. */
/* */
/* */
/*Copyright (c) 2005 Northwestern University */
/*All rights reserved. */
/*Redistribution of the software in source and binary forms, */
/*with or without modification, is permitted provided that the */
/*following conditions are met: */
/* */
/*1 Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/*2 Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution.*/
/* */
/*3 Neither the name of Northwestern University nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* */
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS */
/*IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND */
/*FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL */
/*NORTHWESTERN UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, */
/*INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
/*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
/*HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
/*STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/*POSSIBILITY OF SUCH DAMAGE. */
/******************************************************************************/
/*************************************************************************/
/** File: cluster.c **/
/** Description: Takes as input a file, containing 1 data point per **/
/** per line, and performs a fuzzy c-means clustering **/
/** on the data. Fuzzy clustering is performed using **/
/** min to max clusters and the clustering that gets **/
/** the best score according to a compactness and **/
/** separation criterion are returned. **/
/** Author: Brendan McCane **/
/** James Cook University of North Queensland. **/
/** Australia. email: mccane@cs.jcu.edu.au **/
/** **/
/** Edited by: Jay Pisharath, Wei-keng Liao **/
/** Northwestern University. **/
/** **/
/** ================================================================ **/
/** **/
/** Edited by: Sang-Ha Lee **/
/** University of Virginia **/
/** **/
/** Description: No longer supports fuzzy c-means clustering; **/
/** only regular k-means clustering. **/
/** Simplified for main functionality: regular k-means **/
/** clustering. **/
/** **/
/*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <float.h>
#include "kmeans.h"
/*---< cluster() >-----------------------------------------------------------*/
int cluster(int numObjects, /* number of input objects */
int numAttributes, /* size of attribute of each object */
float **attributes, /* [numObjects][numAttributes] */
int num_nclusters,
float threshold, /* in: */
float ***cluster_centres /* out: [best_nclusters][numAttributes] */
)
{
int nclusters;
int *membership;
float **tmp_cluster_centres;
membership = (int *)malloc(numObjects * sizeof(int));
nclusters = num_nclusters;
srand(7);
tmp_cluster_centres = kmeans_clustering(attributes,
numAttributes,
numObjects,
nclusters,
threshold,
membership);
if (*cluster_centres)
{
free((*cluster_centres)[0]);
free(*cluster_centres);
}
*cluster_centres = tmp_cluster_centres;
free(membership);
return 0;
}

View file

@ -1,100 +0,0 @@
1 0 273 18347 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 2 255 1.00 0.00 0.50 0.03 0.00 0.00 0.00 0.00
1 0 270 3557 0 0 0 0 0 0 0 0 0 0 0 0 12 12 0.00 0.00 0.00 0.00 1.00 0.00 0.00 12 255 1.00 0.00 0.08 0.03 0.00 0.00 0.00 0.00
1 0 296 9308 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 22 255 1.00 0.00 0.05 0.03 0.00 0.00 0.00 0.00
1 0 302 4776 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 32 255 1.00 0.00 0.03 0.02 0.00 0.00 0.00 0.00
1 0 248 6196 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 42 255 1.00 0.00 0.02 0.02 0.00 0.00 0.00 0.00
1 0 202 18347 0 0 0 0 0 0 0 0 0 0 0 0 3 7 0.33 0.14 0.00 0.14 1.00 0.00 0.29 52 255 1.00 0.00 0.02 0.02 0.02 0.00 0.00 0.00
1 0 201 1235 0 0 0 0 0 0 0 0 0 0 0 0 13 20 0.08 0.05 0.00 0.05 1.00 0.00 0.10 62 255 1.00 0.00 0.02 0.02 0.02 0.00 0.00 0.00
1 0 211 4743 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 72 255 1.00 0.00 0.01 0.02 0.01 0.00 0.00 0.00
1 0 168 3030 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 82 255 1.00 0.00 0.01 0.02 0.01 0.00 0.00 0.00
1 0 213 10087 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0.00 0.00 0.33 0.33 1.00 0.00 0.00 92 255 1.00 0.00 0.01 0.02 0.01 0.00 0.01 0.00
1 0 223 376 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 2 255 1.00 0.00 0.50 0.03 0.00 0.00 0.00 0.00
1 0 301 1376 0 0 0 0 0 0 0 0 0 0 0 0 10 10 0.00 0.00 0.00 0.00 1.00 0.00 0.00 10 255 1.00 0.00 0.10 0.03 0.00 0.00 0.00 0.00
1 0 296 1415 0 0 0 0 0 0 0 0 0 0 0 0 20 20 0.00 0.00 0.00 0.00 1.00 0.00 0.00 20 255 1.00 0.00 0.05 0.03 0.00 0.00 0.00 0.00
1 0 298 1293 0 0 0 0 0 0 0 0 0 0 0 0 30 30 0.00 0.00 0.00 0.00 1.00 0.00 0.00 30 255 1.00 0.00 0.03 0.03 0.00 0.00 0.00 0.00
1 0 296 3752 0 0 0 0 0 0 0 0 0 0 0 0 40 40 0.00 0.00 0.00 0.00 1.00 0.00 0.00 40 255 1.00 0.00 0.03 0.03 0.00 0.00 0.00 0.00
1 0 292 1091 0 0 0 0 0 0 0 0 0 0 0 0 50 50 0.00 0.00 0.00 0.00 1.00 0.00 0.00 50 255 1.00 0.00 0.02 0.03 0.00 0.00 0.00 0.00
1 0 300 1376 0 0 0 0 0 0 0 0 0 0 0 0 56 56 0.00 0.00 0.00 0.00 1.00 0.00 0.00 60 255 1.00 0.00 0.02 0.03 0.00 0.00 0.00 0.00
1 0 230 2130 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0.00 0.00 0.00 0.00 1.00 0.00 0.00 70 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 297 1346 0 0 0 0 0 0 0 0 0 0 0 0 13 13 0.00 0.00 0.00 0.00 1.00 0.00 0.00 80 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 290 1091 0 0 0 0 0 0 0 0 0 0 0 0 23 23 0.00 0.00 0.00 0.00 1.00 0.00 0.00 90 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 294 1093 0 0 0 0 0 0 0 0 0 0 0 0 33 33 0.00 0.00 0.00 0.00 1.00 0.00 0.00 100 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 294 1420 0 0 0 0 0 0 0 0 0 0 0 0 43 44 0.00 0.00 0.00 0.00 1.00 0.00 0.05 110 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 296 1426 0 0 0 0 0 0 0 0 0 0 0 0 53 54 0.00 0.00 0.00 0.00 1.00 0.00 0.04 120 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 294 1439 0 0 0 0 0 0 0 0 0 0 0 0 63 64 0.00 0.00 0.00 0.00 1.00 0.00 0.03 130 255 1.00 0.00 0.01 0.03 0.00 0.00 0.00 0.00
1 0 203 27130 0 0 0 0 0 0 0 0 0 0 0 0 6 7 0.00 0.00 0.00 0.00 1.00 0.00 0.29 6 255 1.00 0.00 0.17 0.03 0.00 0.00 0.00 0.00
1 0 277 1684 0 0 0 0 0 0 0 0 0 0 0 0 10 10 0.00 0.00 0.00 0.00 1.00 0.00 0.00 10 255 1.00 0.00 0.10 0.03 0.00 0.00 0.00 0.00
1 0 294 2542 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0.00 0.00 0.00 0.00 1.00 0.00 0.00 5 255 1.00 0.00 0.20 0.03 0.00 0.00 0.00 0.00
1 0 230 3165 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 1 255 1.00 0.00 1.00 0.04 0.00 0.00 0.00 0.00
1 0 305 3234 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 11 255 1.00 0.00 0.09 0.04 0.00 0.00 0.00 0.00
1 0 311 2170 0 0 0 0 0 0 0 0 0 0 0 0 3 5 0.00 0.00 0.00 0.00 1.00 0.00 0.40 3 255 1.00 0.00 0.33 0.05 0.00 0.00 0.00 0.00
1 0 308 11121 0 0 0 0 0 0 0 0 0 0 0 0 13 13 0.00 0.00 0.00 0.00 1.00 0.00 0.00 13 255 1.00 0.00 0.08 0.05 0.00 0.00 0.00 0.00
1 0 313 2142 0 0 0 0 0 0 0 0 0 0 0 0 8 8 0.00 0.00 0.00 0.00 1.00 0.00 0.00 23 255 1.00 0.00 0.04 0.05 0.00 0.00 0.00 0.00
1 0 285 330 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0.00 0.00 0.00 0.00 1.00 0.00 0.00 3 255 1.00 0.00 0.33 0.06 0.00 0.00 0.00 0.00
1 0 286 531 0 0 0 0 0 0 0 0 0 0 0 0 13 13 0.00 0.00 0.00 0.00 1.00 0.00 0.00 13 255 1.00 0.00 0.08 0.06 0.00 0.00 0.00 0.00
1 0 283 324 0 0 0 0 0 0 0 0 0 0 0 0 23 23 0.00 0.00 0.00 0.00 1.00 0.00 0.00 23 255 1.00 0.00 0.04 0.06 0.00 0.00 0.00 0.00
1 0 258 1205 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 33 255 1.00 0.00 0.03 0.06 0.00 0.00 0.00 0.00
1 0 284 9133 0 0 0 0 0 0 0 0 0 0 0 0 10 10 0.00 0.00 0.00 0.00 1.00 0.00 0.00 10 255 1.00 0.00 0.10 0.05 0.00 0.00 0.00 0.00
1 0 276 2903 0 0 0 0 0 0 0 0 0 0 0 0 20 20 0.00 0.00 0.00 0.00 1.00 0.00 0.00 20 255 1.00 0.00 0.05 0.05 0.00 0.00 0.00 0.00
1 0 190 1603 0 0 0 0 0 0 0 0 0 0 0 0 9 10 0.00 0.00 0.00 0.00 1.00 0.00 0.20 30 255 1.00 0.00 0.03 0.05 0.00 0.00 0.00 0.00
1 0 196 393 0 0 0 0 0 0 0 0 0 0 0 0 19 25 0.00 0.00 0.00 0.00 1.00 0.00 0.12 40 255 1.00 0.00 0.03 0.05 0.00 0.00 0.00 0.00
1 0 284 393 0 0 0 0 0 0 0 0 0 0 0 0 8 8 0.00 0.00 0.00 0.00 1.00 0.00 0.00 50 255 1.00 0.00 0.02 0.05 0.00 0.00 0.00 0.00
1 0 275 442 0 0 0 0 0 0 0 0 0 0 0 0 18 18 0.00 0.00 0.00 0.00 1.00 0.00 0.00 60 255 1.00 0.00 0.02 0.05 0.00 0.00 0.00 0.00
1 0 142 3842 0 0 0 0 0 0 0 0 0 0 0 0 4 9 0.00 0.00 0.00 0.00 1.00 0.00 0.33 4 255 1.00 0.00 0.25 0.06 0.00 0.00 0.00 0.00
1 0 281 170 0 0 0 0 0 0 0 0 0 0 0 0 4 15 0.00 0.00 0.00 0.00 1.00 0.00 0.20 4 255 1.00 0.00 0.25 0.07 0.00 0.00 0.00 0.00
1 0 279 168 0 0 0 0 0 0 0 0 0 0 0 0 14 29 0.00 0.00 0.00 0.00 1.00 0.00 0.10 14 255 1.00 0.00 0.07 0.07 0.00 0.00 0.00 0.00
1 0 302 191 0 0 0 0 0 0 0 0 0 0 0 0 24 39 0.00 0.00 0.00 0.00 1.00 0.00 0.08 24 255 1.00 0.00 0.04 0.07 0.00 0.00 0.00 0.00
1 120 279 168 0 0 0 0 0 0 0 0 0 0 0 0 2 28 0.00 0.00 0.00 0.00 1.00 0.00 0.11 34 255 1.00 0.00 0.03 0.07 0.00 0.00 0.00 0.00
1 0 275 247 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0.00 0.00 0.00 0.00 1.00 0.00 1.00 2 255 1.00 0.00 0.50 0.08 0.00 0.00 0.00 0.00
1 0 337 7451 0 0 0 0 0 0 0 0 0 0 0 0 1 19 0.00 0.00 0.00 0.00 1.00 0.00 0.16 5 255 1.00 0.00 0.20 0.09 0.00 0.00 0.20 0.00
1 0 295 406 0 0 0 0 0 0 0 0 0 0 0 0 1 4 0.00 0.00 0.00 0.00 1.00 0.00 0.75 5 255 1.00 0.00 0.20 0.09 0.00 0.00 0.00 0.00
1 0 145 432 0 0 0 0 0 0 0 0 0 0 0 0 1 11 0.00 0.00 0.00 0.00 1.00 0.00 0.18 1 255 1.00 0.00 1.00 0.11 0.00 0.00 0.00 0.00
1 0 201 62535 0 0 0 0 0 0 0 0 0 0 0 0 10 10 0.00 0.00 0.00 0.00 1.00 0.00 0.00 10 255 1.00 0.00 0.10 0.10 0.00 0.00 0.00 0.00
1 0 320 485 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 7 255 1.00 0.00 0.14 0.11 0.00 0.00 0.00 0.00
1 0 235 5754 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 4 255 1.00 0.00 0.25 0.11 0.00 0.00 0.00 0.00
1 0 303 150638 0 0 0 0 0 0 0 0 0 0 0 0 10 35 0.00 0.00 0.00 0.00 1.00 0.00 0.06 10 255 1.00 0.00 0.10 0.10 0.00 0.00 0.00 0.00
1 0 325 27811 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 20 255 1.00 0.00 0.05 0.10 0.00 0.00 0.00 0.00
1 0 258 6496 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 30 255 1.00 0.00 0.03 0.10 0.00 0.00 0.00 0.00
1 0 303 150638 0 0 0 0 0 0 0 0 0 0 0 0 11 21 0.00 0.00 0.00 0.00 1.00 0.00 0.24 40 255 1.00 0.00 0.03 0.10 0.00 0.00 0.00 0.00
1 0 323 1075 0 0 0 0 0 0 0 0 0 0 0 0 5 6 0.00 0.00 0.00 0.00 1.00 0.00 0.33 5 255 1.00 0.00 0.20 0.10 0.00 0.00 0.00 0.00
1 0 328 324 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 15 255 1.00 0.00 0.07 0.10 0.00 0.00 0.00 0.00
1 0 326 4660 0 0 0 0 0 0 0 0 0 0 0 0 8 9 0.00 0.00 0.00 0.00 1.00 0.00 0.22 25 255 1.00 0.00 0.04 0.10 0.00 0.00 0.00 0.00
1 0 334 2684 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 35 255 1.00 0.00 0.03 0.09 0.00 0.00 0.00 0.00
1 0 331 1417 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 45 255 1.00 0.00 0.02 0.09 0.00 0.00 0.00 0.00
1 0 333 35187 0 0 0 0 0 0 0 0 0 0 0 0 11 12 0.00 0.00 0.00 0.00 1.00 0.00 0.17 55 255 1.00 0.00 0.02 0.09 0.00 0.00 0.00 0.00
1 0 197 1571 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 4 255 1.00 0.00 0.25 0.10 0.00 0.00 0.00 0.00
1 0 197 13802 0 0 0 0 0 0 0 0 0 0 0 0 3 3 0.00 0.00 0.00 0.00 1.00 0.00 0.00 3 255 1.00 0.00 0.33 0.11 0.00 0.00 0.00 0.00
1 0 215 2941 0 0 0 0 0 0 0 0 0 0 0 0 3 4 0.00 0.00 0.00 0.00 1.00 0.00 0.50 8 255 1.00 0.00 0.12 0.11 0.00 0.00 0.00 0.00
1 0 214 3687 0 0 0 0 0 0 0 0 0 0 0 0 6 7 0.00 0.00 0.00 0.00 1.00 0.00 0.29 18 255 1.00 0.00 0.06 0.11 0.00 0.00 0.00 0.00
1 0 297 599 0 0 0 0 0 0 0 0 0 0 0 0 4 4 0.00 0.00 0.00 0.00 1.00 0.00 0.00 4 255 1.00 0.00 0.25 0.11 0.00 0.00 0.00 0.00
1 0 296 540 0 0 0 0 0 0 0 0 0 0 0 0 14 14 0.00 0.00 0.00 0.00 1.00 0.00 0.00 14 255 1.00 0.00 0.07 0.10 0.00 0.00 0.00 0.00
1 0 296 617 0 0 0 0 0 0 0 0 0 0 0 0 24 24 0.00 0.00 0.00 0.00 1.00 0.00 0.00 24 255 1.00 0.00 0.04 0.10 0.00 0.00 0.00 0.00
1 0 294 29288 0 0 0 0 0 0 0 0 0 0 0 0 34 34 0.00 0.00 0.00 0.00 1.00 0.00 0.00 34 255 1.00 0.00 0.03 0.10 0.00 0.00 0.00 0.00
1 0 285 34557 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 7 255 1.00 0.00 0.14 0.10 0.00 0.00 0.00 0.00
1 0 316 3665 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 17 255 1.00 0.00 0.06 0.09 0.00 0.00 0.00 0.00
1 0 335 10440 0 0 0 0 0 0 0 0 0 0 0 0 6 7 0.00 0.00 0.00 0.00 1.00 0.00 0.29 27 255 1.00 0.00 0.04 0.08 0.00 0.00 0.00 0.00
1 0 284 10592 0 0 0 0 0 0 0 0 0 0 0 0 5 5 0.00 0.00 0.00 0.00 1.00 0.00 0.00 37 255 1.00 0.00 0.03 0.07 0.00 0.00 0.00 0.00
1 0 242 7066 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 47 255 1.00 0.00 0.02 0.05 0.00 0.00 0.00 0.00
1 0 223 3707 0 0 0 0 0 0 0 0 0 0 0 0 9 9 0.00 0.00 0.00 0.00 1.00 0.00 0.00 9 255 1.00 0.00 0.11 0.05 0.00 0.00 0.00 0.00
1 0 204 1731 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0.00 0.00 0.00 0.00 1.00 0.00 0.00 19 255 1.00 0.00 0.05 0.04 0.00 0.00 0.00 0.00
1 0 148 1122 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 3 255 1.00 0.00 0.33 0.04 0.00 0.00 0.00 0.00
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 0.50 0.12 0.00 0.12 1.00 0.00 0.25 13 255 1.00 0.00 0.15 0.04 0.08 0.00 0.08 0.00
1 0 215 2649 0 0 0 0 0 0 0 0 0 0 0 0 6 12 0.00 0.00 0.00 0.00 1.00 0.00 0.33 23 255 1.00 0.00 0.04 0.04 0.04 0.00 0.04 0.00
1 0 341 326 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 1 255 1.00 0.00 1.00 0.05 0.00 0.01 0.00 0.00
1 0 341 1943 0 0 0 0 0 0 0 0 0 0 0 0 11 11 0.00 0.00 0.00 0.00 1.00 0.00 0.00 11 255 1.00 0.00 0.09 0.05 0.00 0.01 0.00 0.00
1 0 341 1663 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0.00 0.00 0.00 0.00 1.00 0.00 0.00 21 255 1.00 0.00 0.05 0.05 0.00 0.01 0.00 0.00
1 0 235 501 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 2 255 1.00 0.00 0.50 0.05 0.00 0.01 0.00 0.00
1 0 320 13828 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0.00 0.00 0.00 0.00 1.00 0.00 0.00 10 255 1.00 0.00 0.10 0.05 0.00 0.01 0.00 0.00
1 0 319 1435 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0.00 0.00 0.00 0.00 1.00 0.00 0.00 6 255 1.00 0.00 0.17 0.07 0.00 0.01 0.00 0.00
1 0 335 3435 0 0 0 0 0 0 0 0 0 0 0 0 6 35 0.00 0.00 0.00 0.00 1.00 0.00 0.09 16 255 1.00 0.00 0.06 0.07 0.00 0.01 0.00 0.00
1 0 291 236 0 0 0 0 0 0 0 0 0 0 0 0 8 8 0.00 0.00 0.00 0.00 1.00 0.00 0.00 26 255 1.00 0.00 0.04 0.06 0.00 0.01 0.00 0.00
1 0 308 662 0 0 0 0 0 0 0 0 0 0 0 0 8 10 0.00 0.00 0.00 0.00 1.00 0.00 0.30 36 255 1.00 0.00 0.03 0.06 0.00 0.01 0.00 0.00
1 0 291 1862 0 0 0 0 0 0 0 0 0 0 0 0 10 11 0.00 0.00 0.00 0.00 1.00 0.00 0.18 46 255 1.00 0.00 0.02 0.05 0.00 0.01 0.00 0.00
1 0 289 244 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 56 255 1.00 0.00 0.02 0.05 0.00 0.01 0.00 0.00
1 0 306 662 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0.00 0.00 0.00 0.00 1.00 0.00 0.00 66 255 1.00 0.00 0.02 0.05 0.00 0.01 0.00 0.00
1 0 289 1862 0 0 0 0 0 0 0 0 0 0 0 0 4 12 0.00 0.00 0.00 0.00 1.00 0.00 0.25 76 255 1.00 0.00 0.01 0.05 0.00 0.01 0.00 0.00
1 0 310 1881 0 0 0 0 0 0 0 0 0 0 0 0 4 5 0.00 0.00 0.00 0.00 1.00 0.00 0.40 86 255 1.00 0.00 0.01 0.05 0.00 0.01 0.00 0.00
1 0 282 2286 0 0 0 0 0 0 0 0 0 0 0 0 6 6 0.00 0.00 0.00 0.00 1.00 0.00 0.00 6 255 1.00 0.00 0.17 0.05 0.00 0.01 0.00 0.00
1 0 203 1200 0 0 0 0 0 0 0 0 0 0 0 0 6 18 0.17 0.11 0.00 0.00 1.00 0.00 0.17 16 255 1.00 0.00 0.06 0.05 0.06 0.01 0.00 0.00
1 0 291 1200 0 0 0 0 0 0 0 0 0 0 0 0 6 12 0.00 0.00 0.00 0.00 1.00 0.00 0.17 26 255 1.00 0.00 0.04 0.05 0.04 0.01 0.00 0.00
1 0 219 1234 0 0 0 0 0 0 0 0 0 0 0 0 6 35 0.00 0.00 0.00 0.00 1.00 0.00 0.14 6 255 1.00 0.00 0.17 0.05 0.00 0.01 0.00 0.00

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
datagen: datagen.cpp
g++ -o $@ $<
clean:
rm datagen

View file

@ -1,82 +0,0 @@
/*
* datagen.cpp
* by Sam Kauffman - University of Virginia
*
* This program generates datasets for Rodinia's kmeans
*
* Usage:
* datagen <numObjects> [ <numFeatures> ] [-f]
*
* numFeatures defaults to 34
* Features are integers from 0 to 255 by default
* With -f, features are floats from 0.0 to 1.0
* Output file is "<numObjects>_<numFeatures>.txt"
* One object per line. The first number in each line is an object ID and is
* ignored by kmeans.
*
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
int main( int argc, char * argv[] )
{
if ( argc < 2 )
{
cerr << "Error: Specify a number of objects to generate.\n";
exit( 1 );
}
int nObj = atoi( argv[1] );
int nFeat = 0;
if ( argc > 2 )
nFeat = atoi( argv[2] );
if ( nFeat == 0 && argc > 3 )
nFeat = atoi( argv[3] );
if ( nFeat == 0 )
nFeat = 34;
if ( nObj < 1 || nFeat < 1 )
{
cerr << "Error: Invalid argument(s).\n";
exit( 1 );
}
bool floats = false;
if ( ( argc > 2 && strcmp( argv[2], "-f" ) == 0 ) || ( argc > 3 && strcmp( argv[2], "-f" ) == 0 ) )
floats = true;
stringstream ss;
string f = floats ? "f" : "";
ss << nObj << "_" << nFeat << f << ".txt";
ofstream outf( ss.str().c_str(), ios::out | ios::trunc );
srand( time( NULL ) );
if ( !floats )
for ( int i = 0; i < nObj; i++ )
{
outf << i << " ";
for ( int j = 0; j < nFeat; j++ )
outf << ( rand() % 256 ) << " ";
outf << endl;
}
else
{
outf.precision( 4 );
outf.setf( ios::fixed );
for ( int i = 0; i < nObj; i++ )
{
outf << i << " ";
for ( int j = 0; j < nFeat; j++ )
outf << ( (float)rand() / (float)RAND_MAX ) << " ";
outf << endl;
}
}
outf.close();
string type = floats ? " \"float\"" : " \"int\"";
cout << "Generated " << nObj << " objects with " << nFeat << type << " features in " << ss.str() << ".\n";
}

View file

@ -1,25 +0,0 @@
#!/bin/bash
./datagen 100
./datagen 300
./datagen 1000
./datagen 3000
./datagen 10000
./datagen 30000
./datagen 100000
./datagen 300000
./datagen 1000000
./datagen 3000000
./datagen 10000000
./datagen 100 -f
./datagen 300 -f
./datagen 1000 -f
./datagen 3000 -f
./datagen 10000 -f
./datagen 30000 -f
./datagen 100000 -f
./datagen 300000 -f
./datagen 1000000 -f
./datagen 3000000 -f
./datagen 10000000 -f

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,191 +0,0 @@
/* getopt.h */
/* Declarations for getopt.
Copyright (C) 1989-1994, 1996-1999, 2001 Free Software
Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute
it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software
Foundation; either version 2.1 of the License, or
(at your option) any later version.
The GNU C Library 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General
Public License along with the GNU C Library; if not, write
to the Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA. */
#ifndef _GETOPT_H
#ifndef __need_getopt
# define _GETOPT_H 1
#endif
/* If __GNU_LIBRARY__ is not already defined, either we are being used
standalone, or this is the first header included in the source file.
If we are being used with glibc, we need to include <features.h>, but
that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
not defined, include <ctype.h>, which will pull in <features.h> for us
if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
doesn't flood the namespace with stuff the way some other headers do.) */
#if !defined __GNU_LIBRARY__
# include <ctype.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns -1, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
#ifndef __need_getopt
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
# if (defined __STDC__ && __STDC__) || defined __cplusplus
const char *name;
# else
char *name;
# endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
# define no_argument 0
# define required_argument 1
# define optional_argument 2
#endif /* need getopt */
/* Get definitions and prototypes for functions to process the
arguments in ARGV (ARGC of them, minus the program name) for
options given in OPTS.
Return the option character from OPTS just read. Return -1 when
there are no more options. For unrecognized options, or options
missing arguments, `optopt' is set to the option letter, and '?' is
returned.
The OPTS string is a list of characters which are recognized option
letters, optionally followed by colons, specifying that that letter
takes an argument, to be placed in `optarg'.
If a letter in OPTS is followed by two colons, its argument is
optional. This behavior is specific to the GNU `getopt'.
The argument `--' causes premature termination of argument
scanning, explicitly telling `getopt' that there are no more
options.
If OPTS begins with `--', then non-option arguments are treated as
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */
#if (defined __STDC__ && __STDC__) || defined __cplusplus
# ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts);
# else /* not __GNU_LIBRARY__ */
extern int getopt ();
# endif /* __GNU_LIBRARY__ */
# ifndef __need_getopt
extern int getopt_long (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
extern int getopt_long_only (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
int __long_only);
# endif
#else /* not __STDC__ */
extern int getopt ();
# ifndef __need_getopt
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
# endif
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
/* Make sure we later can get all the definitions and declarations. */
#undef __need_getopt
#endif /* getopt.h */

View file

@ -1,254 +0,0 @@
/*****************************************************************************/
/*IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. */
/*By downloading, copying, installing or using the software you agree */
/*to this license. If you do not agree to this license, do not download, */
/*install, copy or use the software. */
/* */
/* */
/*Copyright (c) 2005 Northwestern University */
/*All rights reserved. */
/*Redistribution of the software in source and binary forms, */
/*with or without modification, is permitted provided that the */
/*following conditions are met: */
/* */
/*1 Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/*2 Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution.*/
/* */
/*3 Neither the name of Northwestern University nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* */
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS */
/*IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND */
/*FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL */
/*NORTHWESTERN UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, */
/*INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
/*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
/*HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
/*STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/*POSSIBILITY OF SUCH DAMAGE. */
/******************************************************************************/
/*************************************************************************/
/** File: example.c **/
/** Description: Takes as input a file: **/
/** ascii file: containing 1 data point per line **/
/** binary file: first int is the number of objects **/
/** 2nd int is the no. of features of each **/
/** object **/
/** This example performs a fuzzy c-means clustering **/
/** on the data. Fuzzy clustering is performed using **/
/** min to max clusters and the clustering that gets **/
/** the best score according to a compactness and **/
/** separation criterion are returned. **/
/** Author: Wei-keng Liao **/
/** ECE Department Northwestern University **/
/** email: wkliao@ece.northwestern.edu **/
/** **/
/** Edited by: Jay Pisharath **/
/** Northwestern University. **/
/** **/
/** ================================================================ **/
/** **/
/** Edited by: Sang-Ha Lee **/
/** University of Virginia **/
/** **/
/** Description: No longer supports fuzzy c-means clustering; **/
/** only regular k-means clustering. **/
/** Simplified for main functionality: regular k-means **/
/** clustering. **/
/** **/
/*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <sys/types.h>
#include <fcntl.h>
#include <omp.h>
#include "getopt.h"
#include "kmeans.h"
extern double wtime(void);
/*---< usage() >------------------------------------------------------------*/
void usage(char *argv0)
{
char *help =
"Usage: %s [switches] -i filename\n"
" -i filename : file containing data to be clustered\n"
" -b :input file is in binary format\n"
" -k : number of clusters (default is 8) \n"
" -t threshold : threshold value\n";
fprintf(stderr, help, argv0);
exit(-1);
}
/*---< main() >-------------------------------------------------------------*/
int main(int argc, char **argv)
{
int opt;
extern char *optarg;
extern int optind;
int nclusters = 5;
char *filename = 0;
float *buf;
float **attributes;
float **cluster_centres = NULL;
int i, j;
int numAttributes;
int numObjects;
char line[1024];
int isBinaryFile = 0;
int nloops;
float threshold = 0.001;
double timing;
while ((opt = getopt(argc, argv, "i:k:t:b")) != EOF)
{
switch (opt)
{
case 'i':
filename = optarg;
break;
case 'b':
isBinaryFile = 1;
break;
case 't':
threshold = atof(optarg);
break;
case 'k':
nclusters = atoi(optarg);
break;
case '?':
usage(argv[0]);
break;
default:
usage(argv[0]);
break;
}
}
if (filename == 0)
usage(argv[0]);
numAttributes = numObjects = 0;
/* from the input file, get the numAttributes and numObjects ------------*/
if (isBinaryFile)
{
int infile;
if ((infile = open(filename, O_RDONLY, "0600")) == -1)
{
fprintf(stderr, "Error: no such file (%s)\n", filename);
exit(1);
}
read(infile, &numObjects, sizeof(int));
read(infile, &numAttributes, sizeof(int));
/* allocate space for attributes[] and read attributes of all objects */
buf = (float *)malloc(numObjects * numAttributes * sizeof(float));
attributes = (float **)malloc(numObjects * sizeof(float *));
attributes[0] = (float *)malloc(numObjects * numAttributes * sizeof(float));
for (i = 1; i < numObjects; i++)
attributes[i] = attributes[i - 1] + numAttributes;
read(infile, buf, numObjects * numAttributes * sizeof(float));
close(infile);
}
else
{
FILE *infile;
if ((infile = fopen(filename, "r")) == NULL)
{
fprintf(stderr, "Error: no such file (%s)\n", filename);
exit(1);
}
while (fgets(line, 1024, infile) != NULL)
if (strtok(line, " \t\n") != 0)
numObjects++;
rewind(infile);
while (fgets(line, 1024, infile) != NULL)
{
if (strtok(line, " \t\n") != 0)
{
/* ignore the id (first attribute): numAttributes = 1; */
while (strtok(NULL, " ,\t\n") != NULL)
numAttributes++;
break;
}
}
/* allocate space for attributes[] and read attributes of all objects */
buf = (float *)malloc(numObjects * numAttributes * sizeof(float));
attributes = (float **)malloc(numObjects * sizeof(float *));
attributes[0] = (float *)malloc(numObjects * numAttributes * sizeof(float));
for (i = 1; i < numObjects; i++)
attributes[i] = attributes[i - 1] + numAttributes;
rewind(infile);
i = 0;
while (fgets(line, 1024, infile) != NULL)
{
if (strtok(line, " \t\n") == NULL)
continue;
for (j = 0; j < numAttributes; j++)
{
buf[i] = atof(strtok(NULL, " ,\t\n"));
i++;
}
}
fclose(infile);
}
nloops = 1;
printf("I/O completed\n");
memcpy(attributes[0], buf, numObjects * numAttributes * sizeof(float));
timing = omp_get_wtime();
for (i = 0; i < nloops; i++)
{
cluster_centres = NULL;
cluster(numObjects,
numAttributes,
attributes, /* [numObjects][numAttributes] */
nclusters,
threshold,
&cluster_centres);
}
timing = omp_get_wtime() - timing;
printf("number of Clusters %d\n", nclusters);
printf("number of Attributes %d\n\n", numAttributes);
/*printf("Cluster Centers Output\n");
printf("The first number is cluster number and the following data is arribute value\n");
printf("=============================================================================\n\n");
for (i=0; i<nclusters; i++) {
printf("%d: ", i);
for (j=0; j<numAttributes; j++)
printf("%f ", cluster_centres[i][j]);
printf("\n\n");
}*/
printf("Time for process: %f\n", timing);
free(attributes);
free(cluster_centres[0]);
free(cluster_centres);
free(buf);
return (0);
}

View file

@ -1,54 +0,0 @@
/*****************************************************************************/
/*IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. */
/*By downloading, copying, installing or using the software you agree */
/*to this license. If you do not agree to this license, do not download, */
/*install, copy or use the software. */
/* */
/* */
/*Copyright (c) 2005 Northwestern University */
/*All rights reserved. */
/*Redistribution of the software in source and binary forms, */
/*with or without modification, is permitted provided that the */
/*following conditions are met: */
/* */
/*1 Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/*2 Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution.*/
/* */
/*3 Neither the name of Northwestern University nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* */
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS */
/*IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND */
/*FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL */
/*NORTHWESTERN UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, */
/*INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
/*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
/*HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
/*STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/*POSSIBILITY OF SUCH DAMAGE. */
/******************************************************************************/
#ifndef _H_KMEANS
#define _H_KMEANS
#ifndef FLT_MAX
#define FLT_MAX 3.40282347e+38
#endif
/* cluster.c */
int cluster(int, int, float**, int, float, float***);
/* kmeans_clustering.c */
float **kmeans_clustering(float**, int, int, int, float, int*);
float euclid_dist_2 (float*, float*, int);
int find_nearest_point (float* , int, float**, int);
#endif

View file

@ -1,197 +0,0 @@
/*****************************************************************************/
/*IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. */
/*By downloading, copying, installing or using the software you agree */
/*to this license. If you do not agree to this license, do not download, */
/*install, copy or use the software. */
/* */
/* */
/*Copyright (c) 2005 Northwestern University */
/*All rights reserved. */
/*Redistribution of the software in source and binary forms, */
/*with or without modification, is permitted provided that the */
/*following conditions are met: */
/* */
/*1 Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/*2 Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in the */
/* documentation and/or other materials provided with the distribution.*/
/* */
/*3 Neither the name of Northwestern University nor the names of its */
/* contributors may be used to endorse or promote products derived */
/* from this software without specific prior written permission. */
/* */
/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS */
/*IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT AND */
/*FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL */
/*NORTHWESTERN UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, */
/*INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/*(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
/*SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) */
/*HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, */
/*STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/*POSSIBILITY OF SUCH DAMAGE. */
/******************************************************************************/
/*************************************************************************/
/** File: kmeans_clustering.c **/
/** Description: Implementation of regular k-means clustering **/
/** algorithm **/
/** Author: Wei-keng Liao **/
/** ECE Department, Northwestern University **/
/** email: wkliao@ece.northwestern.edu **/
/** **/
/** Edited by: Jay Pisharath **/
/** Northwestern University. **/
/** **/
/** ================================================================ **/
/** **/
/** Edited by: Sang-Ha Lee **/
/** University of Virginia **/
/** **/
/** Description: No longer supports fuzzy c-means clustering; **/
/** only regular k-means clustering. **/
/** Simplified for main functionality: regular k-means **/
/** clustering. **/
/** **/
/*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include "kmeans.h"
#include <omp.h>
#define RANDOM_MAX 2147483647
#ifndef FLT_MAX
#define FLT_MAX 3.40282347e+38
#endif
extern double wtime(void);
int find_nearest_point(float *pt, /* [nfeatures] */
int nfeatures,
float **pts, /* [npts][nfeatures] */
int npts)
{
int index, i;
float min_dist = FLT_MAX;
/* find the cluster center id with min distance to pt */
for (i = 0; i < npts; i++)
{
float dist;
dist = euclid_dist_2(pt, pts[i], nfeatures); /* no need square root */
if (dist < min_dist)
{
min_dist = dist;
index = i;
}
}
return (index);
}
/*----< euclid_dist_2() >----------------------------------------------------*/
/* multi-dimensional spatial Euclid distance square */
__inline float euclid_dist_2(float *pt1,
float *pt2,
int numdims)
{
int i;
float ans = 0.0;
for (i = 0; i < numdims; i++)
ans += (pt1[i] - pt2[i]) * (pt1[i] - pt2[i]);
return (ans);
}
/*----< kmeans_clustering() >---------------------------------------------*/
float **kmeans_clustering(float **feature, /* in: [npoints][nfeatures] */
int nfeatures,
int npoints,
int nclusters,
float threshold,
int *membership) /* out: [npoints] */
{
int i, j, n = 0, index, loop = 0;
int *new_centers_len; /* [nclusters]: no. of points in each cluster */
float delta;
float **clusters; /* out: [nclusters][nfeatures] */
float **new_centers; /* [nclusters][nfeatures] */
/* allocate space for returning variable clusters[] */
clusters = (float **)malloc(nclusters * sizeof(float *));
clusters[0] = (float *)malloc(nclusters * nfeatures * sizeof(float));
for (i = 1; i < nclusters; i++)
clusters[i] = clusters[i - 1] + nfeatures;
/* randomly pick cluster centers */
for (i = 0; i < nclusters; i++)
{
// n = (int)rand() % npoints;
for (j = 0; j < nfeatures; j++)
clusters[i][j] = feature[n][j];
n++;
}
for (i = 0; i < npoints; i++)
membership[i] = -1;
/* need to initialize new_centers_len and new_centers[0] to all 0 */
new_centers_len = (int *)calloc(nclusters, sizeof(int));
new_centers = (float **)malloc(nclusters * sizeof(float *));
new_centers[0] = (float *)calloc(nclusters * nfeatures, sizeof(float));
for (i = 1; i < nclusters; i++)
new_centers[i] = new_centers[i - 1] + nfeatures;
do
{
delta = 0.0;
for (i = 0; i < npoints; i++)
{
/* find the index of nestest cluster centers */
index = find_nearest_point(feature[i], nfeatures, clusters, nclusters);
/* if membership changes, increase delta by 1 */
if (membership[i] != index)
delta += 1.0;
/* assign the membership to object i */
membership[i] = index;
/* update new cluster centers : sum of objects located within */
new_centers_len[index]++;
for (j = 0; j < nfeatures; j++)
new_centers[index][j] += feature[i][j];
}
/* replace old cluster centers with new_centers */
for (i = 0; i < nclusters; i++)
{
for (j = 0; j < nfeatures; j++)
{
if (new_centers_len[i] > 0)
clusters[i][j] = new_centers[i][j] / new_centers_len[i];
new_centers[i][j] = 0.0; /* set back to 0 */
}
new_centers_len[i] = 0; /* set back to 0 */
}
// delta /= npoints;
} while (delta > threshold);
free(new_centers[0]);
free(new_centers);
free(new_centers_len);
return clusters;
}

View file

@ -1 +0,0 @@
./kmeans -i data/kdd_cup

View file

@ -1,10 +0,0 @@
#makefile
all: particle_filter.c
gcc -O3 -fopenmp particle_filter.c -o particle_filter -lm
clean:
rm -rf particle_filter
run: all
./run

View file

@ -1,599 +0,0 @@
/**
* @file ex_particle_OPENMP_seq.c
* @author Michael Trotter & Matt Goodrum
* @brief Particle filter implementation in C/OpenMP
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <sys/time.h>
#include <omp.h>
#include <limits.h>
#define PI 3.1415926535897932
/**
@var M value for Linear Congruential Generator (LCG); use GCC's value
*/
long M = INT_MAX;
/**
@var A value for LCG
*/
int A = 1103515245;
/**
@var C value for LCG
*/
int C = 12345;
/*****************************
*GET_TIME
*returns a long int representing the time
*****************************/
long long get_time() {
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000000) + tv.tv_usec;
}
// Returns the number of seconds elapsed between the two specified times
float elapsed_time(long long start_time, long long end_time) {
return (float) (end_time - start_time) / (1000 * 1000);
}
/**
* Takes in a double and returns an integer that approximates to that double
* @return if the mantissa < .5 => return value < input value; else return value > input value
*/
double roundDouble(double value){
int newValue = (int)(value);
if(value - newValue < .5)
return newValue;
else
return newValue++;
}
/**
* Set values of the 3D array to a newValue if that value is equal to the testValue
* @param testValue The value to be replaced
* @param newValue The value to replace testValue with
* @param array3D The image vector
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
*/
void setIf(int testValue, int newValue, int * array3D, int * dimX, int * dimY, int * dimZ){
int x, y, z;
for(x = 0; x < *dimX; x++){
for(y = 0; y < *dimY; y++){
for(z = 0; z < *dimZ; z++){
if(array3D[x * *dimY * *dimZ+y * *dimZ + z] == testValue)
array3D[x * *dimY * *dimZ + y * *dimZ + z] = newValue;
}
}
}
}
/**
* Generates a uniformly distributed random number using the provided seed and GCC's settings for the Linear Congruential Generator (LCG)
* @see http://en.wikipedia.org/wiki/Linear_congruential_generator
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a uniformly distributed number [0, 1)
*/
double randu(int * seed, int index)
{
int num = A*seed[index] + C;
seed[index] = num % M;
return fabs(seed[index]/((double) M));
}
/**
* Generates a normally distributed random number using the Box-Muller transformation
* @note This function is thread-safe
* @param seed The seed array
* @param index The specific index of the seed to be advanced
* @return a double representing random number generated using the Box-Muller algorithm
* @see http://en.wikipedia.org/wiki/Normal_distribution, section computing value for normal random distribution
*/
double randn(int * seed, int index){
/*Box-Muller algorithm*/
double u = randu(seed, index);
double v = randu(seed, index);
double cosine = cos(2*PI*v);
double rt = -2*log(u);
return sqrt(rt)*cosine;
}
/**
* Sets values of 3D matrix using randomly generated numbers from a normal distribution
* @param array3D The video to be modified
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param seed The seed array
*/
void addNoise(int * array3D, int * dimX, int * dimY, int * dimZ, int * seed){
int x, y, z;
for(x = 0; x < *dimX; x++){
for(y = 0; y < *dimY; y++){
for(z = 0; z < *dimZ; z++){
array3D[x * *dimY * *dimZ + y * *dimZ + z] = array3D[x * *dimY * *dimZ + y * *dimZ + z] + (int)(5*randn(seed, 0));
}
}
}
}
/**
* Fills a radius x radius matrix representing the disk
* @param disk The pointer to the disk to be made
* @param radius The radius of the disk to be made
*/
void strelDisk(int * disk, int radius)
{
int diameter = radius*2 - 1;
int x, y;
for(x = 0; x < diameter; x++){
for(y = 0; y < diameter; y++){
double distance = sqrt(pow((double)(x-radius+1),2) + pow((double)(y-radius+1),2));
if(distance < radius)
disk[x*diameter + y] = 1;
}
}
}
/**
* Dilates the provided video
* @param matrix The video to be dilated
* @param posX The x location of the pixel to be dilated
* @param posY The y location of the pixel to be dilated
* @param poxZ The z location of the pixel to be dilated
* @param dimX The x dimension of the frame
* @param dimY The y dimension of the frame
* @param dimZ The number of frames
* @param error The error radius
*/
void dilate_matrix(int * matrix, int posX, int posY, int posZ, int dimX, int dimY, int dimZ, int error)
{
int startX = posX - error;
while(startX < 0)
startX++;
int startY = posY - error;
while(startY < 0)
startY++;
int endX = posX + error;
while(endX > dimX)
endX--;
int endY = posY + error;
while(endY > dimY)
endY--;
int x,y;
for(x = startX; x < endX; x++){
for(y = startY; y < endY; y++){
double distance = sqrt( pow((double)(x-posX),2) + pow((double)(y-posY),2) );
if(distance < error)
matrix[x*dimY*dimZ + y*dimZ + posZ] = 1;
}
}
}
/**
* Dilates the target matrix using the radius as a guide
* @param matrix The reference matrix
* @param dimX The x dimension of the video
* @param dimY The y dimension of the video
* @param dimZ The z dimension of the video
* @param error The error radius to be dilated
* @param newMatrix The target matrix
*/
void imdilate_disk(int * matrix, int dimX, int dimY, int dimZ, int error, int * newMatrix)
{
int x, y, z;
for(z = 0; z < dimZ; z++){
for(x = 0; x < dimX; x++){
for(y = 0; y < dimY; y++){
if(matrix[x*dimY*dimZ + y*dimZ + z] == 1){
dilate_matrix(newMatrix, x, y, z, dimX, dimY, dimZ, error);
}
}
}
}
}
/**
* Fills a 2D array describing the offsets of the disk object
* @param se The disk object
* @param numOnes The number of ones in the disk
* @param neighbors The array that will contain the offsets
* @param radius The radius used for dilation
*/
void getneighbors(int * se, int numOnes, double * neighbors, int radius){
int x, y;
int neighY = 0;
int center = radius - 1;
int diameter = radius*2 -1;
for(x = 0; x < diameter; x++){
for(y = 0; y < diameter; y++){
if(se[x*diameter + y]){
neighbors[neighY*2] = (int)(y - center);
neighbors[neighY*2 + 1] = (int)(x - center);
neighY++;
}
}
}
}
/**
* The synthetic video sequence we will work with here is composed of a
* single moving object, circular in shape (fixed radius)
* The motion here is a linear motion
* the foreground intensity and the backgrounf intensity is known
* the image is corrupted with zero mean Gaussian noise
* @param I The video itself
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames of the video
* @param seed The seed array used for number generation
*/
void videoSequence(int * I, int IszX, int IszY, int Nfr, int * seed){
int k;
int max_size = IszX*IszY*Nfr;
/*get object centers*/
int x0 = (int)roundDouble(IszY/2.0);
int y0 = (int)roundDouble(IszX/2.0);
I[x0 *IszY *Nfr + y0 * Nfr + 0] = 1;
/*move point*/
int xk, yk, pos;
for(k = 1; k < Nfr; k++){
xk = abs(x0 + (k-1));
yk = abs(y0 - 2*(k-1));
pos = yk * IszY * Nfr + xk *Nfr + k;
if(pos >= max_size)
pos = 0;
I[pos] = 1;
}
/*dilate matrix*/
int * newMatrix = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
imdilate_disk(I, IszX, IszY, Nfr, 5, newMatrix);
int x, y;
for(x = 0; x < IszX; x++){
for(y = 0; y < IszY; y++){
for(k = 0; k < Nfr; k++){
I[x*IszY*Nfr + y*Nfr + k] = newMatrix[x*IszY*Nfr + y*Nfr + k];
}
}
}
free(newMatrix);
/*define background, add noise*/
setIf(0, 100, I, &IszX, &IszY, &Nfr);
setIf(1, 228, I, &IszX, &IszY, &Nfr);
/*add noise*/
addNoise(I, &IszX, &IszY, &Nfr, seed);
}
/**
* Determines the likelihood sum based on the formula: SUM( (IK[IND] - 100)^2 - (IK[IND] - 228)^2)/ 100
* @param I The 3D matrix
* @param ind The current ind array
* @param numOnes The length of ind array
* @return A double representing the sum
*/
double calcLikelihoodSum(int * I, int * ind, int numOnes){
double likelihoodSum = 0.0;
int y;
for(y = 0; y < numOnes; y++)
likelihoodSum += (pow((I[ind[y]] - 100),2) - pow((I[ind[y]]-228),2))/50.0;
return likelihoodSum;
}
/**
* Finds the first element in the CDF that is greater than or equal to the provided value and returns that index
* @note This function uses sequential search
* @param CDF The CDF
* @param lengthCDF The length of CDF
* @param value The value to be found
* @return The index of value in the CDF; if value is never found, returns the last index
*/
int findIndex(double * CDF, int lengthCDF, double value){
int index = -1;
int x;
for(x = 0; x < lengthCDF; x++){
if(CDF[x] >= value){
index = x;
break;
}
}
if(index == -1){
return lengthCDF-1;
}
return index;
}
/**
* Finds the first element in the CDF that is greater than or equal to the provided value and returns that index
* @note This function uses binary search before switching to sequential search
* @param CDF The CDF
* @param beginIndex The index to start searching from
* @param endIndex The index to stop searching
* @param value The value to find
* @return The index of value in the CDF; if value is never found, returns the last index
* @warning Use at your own risk; not fully tested
*/
int findIndexBin(double * CDF, int beginIndex, int endIndex, double value){
if(endIndex < beginIndex)
return -1;
int middleIndex = beginIndex + ((endIndex - beginIndex)/2);
/*check the value*/
if(CDF[middleIndex] >= value)
{
/*check that it's good*/
if(middleIndex == 0)
return middleIndex;
else if(CDF[middleIndex-1] < value)
return middleIndex;
else if(CDF[middleIndex-1] == value)
{
while(middleIndex > 0 && CDF[middleIndex-1] == value)
middleIndex--;
return middleIndex;
}
}
if(CDF[middleIndex] > value)
return findIndexBin(CDF, beginIndex, middleIndex+1, value);
return findIndexBin(CDF, middleIndex-1, endIndex, value);
}
/**
* The implementation of the particle filter using OpenMP for many frames
* @see http://openmp.org/wp/
* @note This function is designed to work with a video of several frames. In addition, it references a provided MATLAB function which takes the video, the objxy matrix and the x and y arrays as arguments and returns the likelihoods
* @param I The video to be run
* @param IszX The x dimension of the video
* @param IszY The y dimension of the video
* @param Nfr The number of frames
* @param seed The seed array used for random number generation
* @param Nparticles The number of particles to be used
*/
void particleFilter(int * I, int IszX, int IszY, int Nfr, int * seed, int Nparticles){
int max_size = IszX*IszY*Nfr;
long long start = get_time();
//original particle centroid
double xe = roundDouble(IszY/2.0);
double ye = roundDouble(IszX/2.0);
//expected object locations, compared to center
int radius = 5;
int diameter = radius*2 - 1;
int * disk = (int *)malloc(diameter*diameter*sizeof(int));
strelDisk(disk, radius);
int countOnes = 0;
int x, y;
for(x = 0; x < diameter; x++){
for(y = 0; y < diameter; y++){
if(disk[x*diameter + y] == 1)
countOnes++;
}
}
double * objxy = (double *)malloc(countOnes*2*sizeof(double));
getneighbors(disk, countOnes, objxy, radius);
long long get_neighbors = get_time();
printf("TIME TO GET NEIGHBORS TOOK: %f\n", elapsed_time(start, get_neighbors));
//initial weights are all equal (1/Nparticles)
double * weights = (double *)malloc(sizeof(double)*Nparticles);
for(x = 0; x < Nparticles; x++){
weights[x] = 1/((double)(Nparticles));
}
long long get_weights = get_time();
printf("TIME TO GET WEIGHTSTOOK: %f\n", elapsed_time(get_neighbors, get_weights));
//initial likelihood to 0.0
double * likelihood = (double *)malloc(sizeof(double)*Nparticles);
double * arrayX = (double *)malloc(sizeof(double)*Nparticles);
double * arrayY = (double *)malloc(sizeof(double)*Nparticles);
double * xj = (double *)malloc(sizeof(double)*Nparticles);
double * yj = (double *)malloc(sizeof(double)*Nparticles);
double * CDF = (double *)malloc(sizeof(double)*Nparticles);
double * u = (double *)malloc(sizeof(double)*Nparticles);
int * ind = (int*)malloc(sizeof(int)*countOnes*Nparticles);
for(x = 0; x < Nparticles; x++){
arrayX[x] = xe;
arrayY[x] = ye;
}
int k;
printf("TIME TO SET ARRAYS TOOK: %f\n", elapsed_time(get_weights, get_time()));
int indX, indY;
for(k = 1; k < Nfr; k++){
long long set_arrays = get_time();
//apply motion model
//draws sample from motion model (random walk). The only prior information
//is that the object moves 2x as fast as in the y direction
for(x = 0; x < Nparticles; x++){
arrayX[x] += 1 + 5*randn(seed, x);
arrayY[x] += -2 + 2*randn(seed, x);
}
long long error = get_time();
printf("TIME TO SET ERROR TOOK: %f\n", elapsed_time(set_arrays, error));
//particle filter likelihood
for(x = 0; x < Nparticles; x++){
//compute the likelihood: remember our assumption is that you know
// foreground and the background image intensity distribution.
// Notice that we consider here a likelihood ratio, instead of
// p(z|x). It is possible in this case. why? a hometask for you.
//calc ind
for(y = 0; y < countOnes; y++){
indX = roundDouble(arrayX[x]) + objxy[y*2 + 1];
indY = roundDouble(arrayY[x]) + objxy[y*2];
ind[x*countOnes + y] = fabs(indX*IszY*Nfr + indY*Nfr + k);
if(ind[x*countOnes + y] >= max_size)
ind[x*countOnes + y] = 0;
}
likelihood[x] = 0;
for(y = 0; y < countOnes; y++)
likelihood[x] += (pow((I[ind[x*countOnes + y]] - 100),2) - pow((I[ind[x*countOnes + y]]-228),2))/50.0;
likelihood[x] = likelihood[x]/((double) countOnes);
}
long long likelihood_time = get_time();
printf("TIME TO GET LIKELIHOODS TOOK: %f\n", elapsed_time(error, likelihood_time));
// update & normalize weights
// using equation (63) of Arulampalam Tutorial
for(x = 0; x < Nparticles; x++){
weights[x] = weights[x] * exp(likelihood[x]);
}
long long exponential = get_time();
printf("TIME TO GET EXP TOOK: %f\n", elapsed_time(likelihood_time, exponential));
double sumWeights = 0;
for(x = 0; x < Nparticles; x++){
sumWeights += weights[x];
}
long long sum_time = get_time();
printf("TIME TO SUM WEIGHTS TOOK: %f\n", elapsed_time(exponential, sum_time));
for(x = 0; x < Nparticles; x++){
weights[x] = weights[x]/sumWeights;
}
long long normalize = get_time();
printf("TIME TO NORMALIZE WEIGHTS TOOK: %f\n", elapsed_time(sum_time, normalize));
xe = 0;
ye = 0;
// estimate the object location by expected values
for(x = 0; x < Nparticles; x++){
xe += arrayX[x] * weights[x];
ye += arrayY[x] * weights[x];
}
long long move_time = get_time();
printf("TIME TO MOVE OBJECT TOOK: %f\n", elapsed_time(normalize, move_time));
printf("XE: %lf\n", xe);
printf("YE: %lf\n", ye);
double distance = sqrt( pow((double)(xe-(int)roundDouble(IszY/2.0)),2) + pow((double)(ye-(int)roundDouble(IszX/2.0)),2) );
printf("%lf\n", distance);
//display(hold off for now)
//pause(hold off for now)
//resampling
CDF[0] = weights[0];
for(x = 1; x < Nparticles; x++){
CDF[x] = weights[x] + CDF[x-1];
}
long long cum_sum = get_time();
printf("TIME TO CALC CUM SUM TOOK: %f\n", elapsed_time(move_time, cum_sum));
double u1 = (1/((double)(Nparticles)))*randu(seed, 0);
for(x = 0; x < Nparticles; x++){
u[x] = u1 + x/((double)(Nparticles));
}
long long u_time = get_time();
printf("TIME TO CALC U TOOK: %f\n", elapsed_time(cum_sum, u_time));
int j, i;
for(j = 0; j < Nparticles; j++){
i = findIndex(CDF, Nparticles, u[j]);
if(i == -1)
i = Nparticles-1;
xj[j] = arrayX[i];
yj[j] = arrayY[i];
}
long long xyj_time = get_time();
printf("TIME TO CALC NEW ARRAY X AND Y TOOK: %f\n", elapsed_time(u_time, xyj_time));
for(x = 0; x < Nparticles; x++){
//reassign arrayX and arrayY
arrayX[x] = xj[x];
arrayY[x] = yj[x];
weights[x] = 1/((double)(Nparticles));
}
long long reset = get_time();
printf("TIME TO RESET WEIGHTS TOOK: %f\n", elapsed_time(xyj_time, reset));
}
free(disk);
free(objxy);
free(weights);
free(likelihood);
free(xj);
free(yj);
free(arrayX);
free(arrayY);
free(CDF);
free(u);
free(ind);
}
int main(int argc, char * argv[]){
char* usage = "openmp.out -x <dimX> -y <dimY> -z <Nfr> -np <Nparticles>";
//check number of arguments
if(argc != 9)
{
printf("%s\n", usage);
return 0;
}
//check args deliminators
if( strcmp( argv[1], "-x" ) || strcmp( argv[3], "-y" ) || strcmp( argv[5], "-z" ) || strcmp( argv[7], "-np" ) ) {
printf( "%s\n",usage );
return 0;
}
int IszX, IszY, Nfr, Nparticles;
//converting a string to a integer
if( sscanf( argv[2], "%d", &IszX ) == EOF ) {
printf("ERROR: dimX input is incorrect");
return 0;
}
if( IszX <= 0 ) {
printf("dimX must be > 0\n");
return 0;
}
//converting a string to a integer
if( sscanf( argv[4], "%d", &IszY ) == EOF ) {
printf("ERROR: dimY input is incorrect");
return 0;
}
if( IszY <= 0 ) {
printf("dimY must be > 0\n");
return 0;
}
//converting a string to a integer
if( sscanf( argv[6], "%d", &Nfr ) == EOF ) {
printf("ERROR: Number of frames input is incorrect");
return 0;
}
if( Nfr <= 0 ) {
printf("number of frames must be > 0\n");
return 0;
}
//converting a string to a integer
if( sscanf( argv[8], "%d", &Nparticles ) == EOF ) {
printf("ERROR: Number of particles input is incorrect");
return 0;
}
if( Nparticles <= 0 ) {
printf("Number of particles must be > 0\n");
return 0;
}
//establish seed
int * seed = (int *)malloc(sizeof(int)*Nparticles);
int i;
for(i = 0; i < Nparticles; i++)
seed[i] = time(0)*i;
//malloc matrix
int * I = (int *)malloc(sizeof(int)*IszX*IszY*Nfr);
long long start = get_time();
//call video sequence
videoSequence(I, IszX, IszY, Nfr, seed);
long long endVideoSequence = get_time();
printf("VIDEO SEQUENCE TOOK %f\n", elapsed_time(start, endVideoSequence));
//call particle filter
particleFilter(I, IszX, IszY, Nfr, seed, Nparticles);
long long endParticleFilter = get_time();
printf("PARTICLE FILTER TOOK %f\n", elapsed_time(endVideoSequence, endParticleFilter));
printf("ENTIRE PROGRAM TOOK %f\n", elapsed_time(start, endParticleFilter));
free(seed);
free(I);
return 0;
}

View file

@ -1 +0,0 @@
./particle_filter -x 256 -y 256 -z 4 -np 100000

View file

@ -1,2 +0,0 @@
-include ../../utilities/options.mk
-include ../../utilities/c.mk

View file

@ -1,149 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 1000. */
#include "correlation.h"
/* Array initialization. */
static
void init_array (int m,
int n,
DATA_TYPE *float_n,
DATA_TYPE POLYBENCH_2D(data,M,N,m,n))
{
int i, j;
*float_n = 1.2;
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
data[i][j] = ((DATA_TYPE) i*j) / M;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static
void print_array(int m,
DATA_TYPE POLYBENCH_2D(symmat,M,M,m,m))
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < m; j++) {
fprintf (stderr, DATA_PRINTF_MODIFIER, symmat[i][j]);
if ((i * m + j) % 20 == 0) fprintf (stderr, "\n");
}
fprintf (stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static
void kernel_correlation(int m, int n,
DATA_TYPE float_n,
DATA_TYPE POLYBENCH_2D(data,M,N,m,n),
DATA_TYPE POLYBENCH_2D(symmat,M,M,m,m),
DATA_TYPE POLYBENCH_1D(mean,M,m),
DATA_TYPE POLYBENCH_1D(stddev,M,m))
{
int i, j, j1, j2;
DATA_TYPE eps = 0.1f;
#define sqrt_of_array_cell(x,j) sqrt(x[j])
/* Determine mean of column vectors of input data matrix */
for (j = 0; j < _PB_M; j++)
{
mean[j] = 0.0;
for (i = 0; i < _PB_N; i++)
mean[j] += data[i][j];
mean[j] /= float_n;
}
/* Determine standard deviations of column vectors of data matrix. */
for (j = 0; j < _PB_M; j++)
{
stddev[j] = 0.0;
for (i = 0; i < _PB_N; i++)
stddev[j] += (data[i][j] - mean[j]) * (data[i][j] - mean[j]);
stddev[j] /= float_n;
stddev[j] = sqrt_of_array_cell(stddev, j);
/* The following in an inelegant but usual way to handle
near-zero std. dev. values, which below would cause a zero-
divide. */
stddev[j] = stddev[j] <= eps ? 1.0 : stddev[j];
}
/* Center and reduce the column vectors. */
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_M; j++)
{
data[i][j] -= mean[j];
data[i][j] /= sqrt(float_n) * stddev[j];
}
/* Calculate the m * m correlation matrix. */
for (j1 = 0; j1 < _PB_M-1; j1++)
{
symmat[j1][j1] = 1.0;
for (j2 = j1+1; j2 < _PB_M; j2++)
{
symmat[j1][j2] = 0.0;
for (i = 0; i < _PB_N; i++)
symmat[j1][j2] += (data[i][j1] * data[i][j2]);
symmat[j2][j1] = symmat[j1][j2];
}
}
symmat[_PB_M-1][_PB_M-1] = 1.0;
}
int main(int argc, char** argv)
{
/* Retrieve problem size. */
int n = N;
int m = M;
/* Variable declaration/allocation. */
DATA_TYPE float_n;
POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,M,N,m,n);
POLYBENCH_2D_ARRAY_DECL(symmat,DATA_TYPE,M,M,m,m);
POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m);
POLYBENCH_1D_ARRAY_DECL(stddev,DATA_TYPE,M,m);
/* Initialize array(s). */
init_array (m, n, &float_n, POLYBENCH_ARRAY(data));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_correlation (m, n, float_n,
POLYBENCH_ARRAY(data),
POLYBENCH_ARRAY(symmat),
POLYBENCH_ARRAY(mean),
POLYBENCH_ARRAY(stddev));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(data);
POLYBENCH_FREE_ARRAY(symmat);
POLYBENCH_FREE_ARRAY(mean);
POLYBENCH_FREE_ARRAY(stddev);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef CORRELATION_H
# define CORRELATION_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(N) && !defined(M)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# define M 32
# endif
# ifdef SMALL_DATASET
# define N 500
# define M 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 1000
# define M 1000
# endif
# ifdef LARGE_DATASET
# define N 2000
# define M 2000
# endif
# ifdef EXTRALARGE_DATASET
# define N 4000
# define M 4000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# define _PB_M POLYBENCH_LOOP_BOUND(M,m)
# ifndef DATA_TYPE
# define DATA_TYPE float
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !CORRELATION_H */

View file

@ -1,2 +0,0 @@
-include ../../utilities/options.mk
-include ../../utilities/c.mk

View file

@ -1,122 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "covariance.h"
/* Array initialization. */
static
void init_array (int m, int n,
DATA_TYPE *float_n,
DATA_TYPE POLYBENCH_2D(data,M,N,m,n))
{
int i, j;
*float_n = 1.2;
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
data[i][j] = ((DATA_TYPE) i*j) / M;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static
void print_array(int m,
DATA_TYPE POLYBENCH_2D(symmat,M,M,m,m))
{
int i, j;
for (i = 0; i < m; i++)
for (j = 0; j < m; j++) {
fprintf (stderr, DATA_PRINTF_MODIFIER, symmat[i][j]);
if ((i * m + j) % 20 == 0) fprintf (stderr, "\n");
}
fprintf (stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static
void kernel_covariance(int m, int n,
DATA_TYPE float_n,
DATA_TYPE POLYBENCH_2D(data,M,N,m,n),
DATA_TYPE POLYBENCH_2D(symmat,M,M,m,m),
DATA_TYPE POLYBENCH_1D(mean,M,m))
{
int i, j, j1, j2;
/* Determine mean of column vectors of input data matrix */
for (j = 0; j < _PB_M; j++)
{
mean[j] = 0.0;
for (i = 0; i < _PB_N; i++)
mean[j] += data[i][j];
mean[j] /= float_n;
}
/* Center the column vectors. */
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_M; j++)
data[i][j] -= mean[j];
/* Calculate the m * m covariance matrix. */
for (j1 = 0; j1 < _PB_M; j1++)
for (j2 = j1; j2 < _PB_M; j2++)
{
symmat[j1][j2] = 0.0;
for (i = 0; i < _PB_N; i++)
symmat[j1][j2] += data[i][j1] * data[i][j2];
symmat[j2][j1] = symmat[j1][j2];
}
}
int main(int argc, char** argv)
{
/* Retrieve problem size. */
int n = N;
int m = M;
/* Variable declaration/allocation. */
DATA_TYPE float_n;
POLYBENCH_2D_ARRAY_DECL(data,DATA_TYPE,M,N,m,n);
POLYBENCH_2D_ARRAY_DECL(symmat,DATA_TYPE,M,M,m,m);
POLYBENCH_1D_ARRAY_DECL(mean,DATA_TYPE,M,m);
/* Initialize array(s). */
init_array (m, n, &float_n, POLYBENCH_ARRAY(data));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_covariance (m, n, float_n,
POLYBENCH_ARRAY(data),
POLYBENCH_ARRAY(symmat),
POLYBENCH_ARRAY(mean));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(m, POLYBENCH_ARRAY(symmat)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(data);
POLYBENCH_FREE_ARRAY(symmat);
POLYBENCH_FREE_ARRAY(mean);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef COVARIANCE_H
# define COVARIANCE_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(N) && !defined(M)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# define M 32
# endif
# ifdef SMALL_DATASET
# define N 500
# define M 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 1000
# define M 1000
# endif
# ifdef LARGE_DATASET
# define N 2000
# define M 2000
# endif
# ifdef EXTRALARGE_DATASET
# define N 4000
# define M 4000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# define _PB_M POLYBENCH_LOOP_BOUND(M,m)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !COVARIANCE_H */

View file

@ -1,141 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "2mm.h"
/* Array initialization. */
static void init_array(int ni, int nj, int nk, int nl,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nl),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj),
DATA_TYPE POLYBENCH_2D(C, NL, NJ, nl, nj),
DATA_TYPE POLYBENCH_2D(D, NI, NL, ni, nl))
{
int i, j;
*alpha = 32412;
*beta = 2123;
for (i = 0; i < ni; i++)
for (j = 0; j < nk; j++)
A[i][j] = ((DATA_TYPE)i * j) / ni;
for (i = 0; i < nk; i++)
for (j = 0; j < nj; j++)
B[i][j] = ((DATA_TYPE)i * (j + 1)) / nj;
for (i = 0; i < nl; i++)
for (j = 0; j < nj; j++)
C[i][j] = ((DATA_TYPE)i * (j + 3)) / nl;
for (i = 0; i < ni; i++)
for (j = 0; j < nl; j++)
D[i][j] = ((DATA_TYPE)i * (j + 2)) / nk;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni, int nl,
DATA_TYPE POLYBENCH_2D(D, NI, NL, ni, nl))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nl; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, D[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_2mm(int ni, int nj, int nk, int nl,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(tmp, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nk),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj),
DATA_TYPE POLYBENCH_2D(C, NL, NJ, nl, nj),
DATA_TYPE POLYBENCH_2D(D, NI, NL, ni, nl))
{
int i, j, k;
/* D := alpha*A*B*C + beta*D */
{
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NJ; j++)
{
tmp[i][j] = 0;
for (k = 0; k < _PB_NK; ++k)
tmp[i][j] += alpha * A[i][k] * B[k][j];
}
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NL; j++)
{
D[i][j] *= beta;
for (k = 0; k < _PB_NJ; ++k)
D[i][j] += tmp[i][k] * C[k][j];
}
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
int nk = NK;
int nl = NL;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(tmp, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NK, ni, nk);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NK, NJ, nk, nj);
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NL, NJ, nl, nj);
POLYBENCH_2D_ARRAY_DECL(D, DATA_TYPE, NI, NL, ni, nl);
/* Initialize array(s). */
init_array(ni, nj, nk, nl, &alpha, &beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(D));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_2mm(ni, nj, nk, nl,
alpha, beta,
POLYBENCH_ARRAY(tmp),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(D));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(D)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(tmp);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(D);
return 0;
}

View file

@ -1,59 +0,0 @@
#ifndef _2MM_H
# define _2MM_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ) && !defined(NK)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# define NK 32
# define NL 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# define NK 128
# define NL 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# define NK 1024
# define NL 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# define NK 2000
# define NL 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# define NK 4000
# define NL 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk)
# define _PB_NL POLYBENCH_LOOP_BOUND(NL,nl)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !_2MM */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1 +0,0 @@
-DNI=1024 -DNJ=1024 -DNK=1024 -DNL=1024

View file

@ -1,148 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "3mm.h"
/* Array initialization. */
static void init_array(int ni, int nj, int nk, int nl, int nm,
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nk),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj),
DATA_TYPE POLYBENCH_2D(C, NJ, NM, nj, nm),
DATA_TYPE POLYBENCH_2D(D, NM, NL, nm, nl))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nk; j++)
A[i][j] = ((DATA_TYPE)i * j) / ni;
for (i = 0; i < nk; i++)
for (j = 0; j < nj; j++)
B[i][j] = ((DATA_TYPE)i * (j + 1)) / nj;
for (i = 0; i < nj; i++)
for (j = 0; j < nm; j++)
C[i][j] = ((DATA_TYPE)i * (j + 3)) / nl;
for (i = 0; i < nm; i++)
for (j = 0; j < nl; j++)
D[i][j] = ((DATA_TYPE)i * (j + 2)) / nk;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni, int nl,
DATA_TYPE POLYBENCH_2D(G, NI, NL, ni, nl))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nl; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, G[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_3mm(int ni, int nj, int nk, int nl, int nm,
DATA_TYPE POLYBENCH_2D(E, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nk),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj),
DATA_TYPE POLYBENCH_2D(F, NJ, NL, nj, nl),
DATA_TYPE POLYBENCH_2D(C, NJ, NM, nj, nm),
DATA_TYPE POLYBENCH_2D(D, NM, NL, nm, nl),
DATA_TYPE POLYBENCH_2D(G, NI, NL, ni, nl))
{
int i, j, k;
/* E := A*B */
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NJ; j++)
{
E[i][j] = 0;
for (k = 0; k < _PB_NK; ++k)
E[i][j] += A[i][k] * B[k][j];
}
/* F := C*D */
for (i = 0; i < _PB_NJ; i++)
for (j = 0; j < _PB_NL; j++)
{
F[i][j] = 0;
for (k = 0; k < _PB_NM; ++k)
F[i][j] += C[i][k] * D[k][j];
}
/* G := E*F */
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NL; j++)
{
G[i][j] = 0;
for (k = 0; k < _PB_NJ; ++k)
G[i][j] += E[i][k] * F[k][j];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
int nk = NK;
int nl = NL;
int nm = NM;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(E, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NK, ni, nk);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NK, NJ, nk, nj);
POLYBENCH_2D_ARRAY_DECL(F, DATA_TYPE, NJ, NL, nj, nl);
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NJ, NM, nj, nm);
POLYBENCH_2D_ARRAY_DECL(D, DATA_TYPE, NM, NL, nm, nl);
POLYBENCH_2D_ARRAY_DECL(G, DATA_TYPE, NI, NL, ni, nl);
/* Initialize array(s). */
init_array(ni, nj, nk, nl, nm,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(D));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_3mm(ni, nj, nk, nl, nm,
POLYBENCH_ARRAY(E),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(F),
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(D),
POLYBENCH_ARRAY(G));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nl, POLYBENCH_ARRAY(G)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(E);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
POLYBENCH_FREE_ARRAY(F);
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(D);
POLYBENCH_FREE_ARRAY(G);
return 0;
}

View file

@ -1,65 +0,0 @@
#ifndef _3MM_H
# define _3MM_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ) && !defined(NK)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# define NK 32
# define NL 32
# define NM 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# define NK 128
# define NL 128
# define NM 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# define NK 1024
# define NL 1024
# define NM 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# define NK 2000
# define NL 2000
# define NM 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# define NK 4000
# define NL 4000
# define NM 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk)
# define _PB_NL POLYBENCH_LOOP_BOUND(NL,nl)
# define _PB_NM POLYBENCH_LOOP_BOUND(NM,nm)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !_3MM */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1 +0,0 @@
-DNI=1024 -DNJ=1024 -DNK=1024 -DNL=1024 -DNM=1024

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,125 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "bicg.h"
/* Array initialization. */
static void init_array(int nx, int ny,
DATA_TYPE POLYBENCH_2D(A, NX, NY, nx, ny),
DATA_TYPE POLYBENCH_1D(r, NX, nx),
DATA_TYPE POLYBENCH_1D(p, NY, ny))
{
int i, j;
for (i = 0; i < ny; i++)
p[i] = i * M_PI;
for (i = 0; i < nx; i++)
{
r[i] = i * M_PI;
for (j = 0; j < ny; j++)
A[i][j] = ((DATA_TYPE)i * (j + 1)) / nx;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int nx, int ny,
DATA_TYPE POLYBENCH_1D(s, NY, ny),
DATA_TYPE POLYBENCH_1D(q, NX, nx))
{
int i;
for (i = 0; i < ny; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, s[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
for (i = 0; i < nx; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, q[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_bicg(int nx, int ny,
DATA_TYPE POLYBENCH_2D(A, NX, NY, nx, ny),
DATA_TYPE POLYBENCH_1D(s, NY, ny),
DATA_TYPE POLYBENCH_1D(q, NX, nx),
DATA_TYPE POLYBENCH_1D(p, NY, ny),
DATA_TYPE POLYBENCH_1D(r, NX, nx))
{
int i, j;
for (i = 0; i < _PB_NY; i++)
s[i] = 0;
for (i = 0; i < _PB_NX; i++)
{
q[i] = 0;
for (j = 0; j < _PB_NY; j++)
{
s[j] = s[j] + r[i] * A[i][j];
q[i] = q[i] + A[i][j] * p[j];
}
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int nx = NX;
int ny = NY;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NX, NY, nx, ny);
POLYBENCH_1D_ARRAY_DECL(s, DATA_TYPE, NY, ny);
POLYBENCH_1D_ARRAY_DECL(q, DATA_TYPE, NX, nx);
POLYBENCH_1D_ARRAY_DECL(p, DATA_TYPE, NY, ny);
POLYBENCH_1D_ARRAY_DECL(r, DATA_TYPE, NX, nx);
/* Initialize array(s). */
init_array(nx, ny,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(r),
POLYBENCH_ARRAY(p));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_bicg(nx, ny,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(s),
POLYBENCH_ARRAY(q),
POLYBENCH_ARRAY(p),
POLYBENCH_ARRAY(r));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(nx, ny, POLYBENCH_ARRAY(s), POLYBENCH_ARRAY(q)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(s);
POLYBENCH_FREE_ARRAY(q);
POLYBENCH_FREE_ARRAY(p);
POLYBENCH_FREE_ARRAY(r);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef BICG_H
# define BICG_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NX) && !defined(NY)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NX 32
# define NY 32
# endif
# ifdef SMALL_DATASET
# define NX 500
# define NY 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NX 4000
# define NY 4000
# endif
# ifdef LARGE_DATASET
# define NX 8000
# define NY 8000
# endif
# ifdef EXTRALARGE_DATASET
# define NX 100000
# define NY 100000
# endif
# endif /* !N */
# define _PB_NX POLYBENCH_LOOP_BOUND(NX,nx)
# define _PB_NY POLYBENCH_LOOP_BOUND(NY,ny)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !BICG */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,101 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "cholesky.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE POLYBENCH_1D(p, N, n),
DATA_TYPE POLYBENCH_2D(A, N, N, n, n))
{
int i, j;
for (i = 0; i < n; i++)
{
p[i] = 1.0 / n;
for (j = 0; j < n; j++)
A[i][j] = 1.0 / n;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n))
{
int i, j;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, A[i][j]);
if ((i * N + j) % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_cholesky(int n,
DATA_TYPE POLYBENCH_1D(p, N, n),
DATA_TYPE POLYBENCH_2D(A, N, N, n, n))
{
int i, j, k;
DATA_TYPE x;
for (i = 0; i < _PB_N; ++i)
{
x = A[i][i];
for (j = 0; j <= i - 1; ++j)
x = x - A[i][j] * A[i][j];
p[i] = 1.0 / sqrt(x);
for (j = i + 1; j < _PB_N; ++j)
{
x = A[i][j];
for (k = 0; k <= i - 1; ++k)
x = x - A[j][k] * A[i][k];
A[j][i] = x * p[i];
}
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(p, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n, POLYBENCH_ARRAY(p), POLYBENCH_ARRAY(A));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_cholesky(n, POLYBENCH_ARRAY(p), POLYBENCH_ARRAY(A));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(A)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(p);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef CHOLESKY_H
# define CHOLESKY_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(N)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 1024
# endif
# ifdef LARGE_DATASET
# define N 2000
# endif
# ifdef EXTRALARGE_DATASET
# define N 4000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !CHOLESKY */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,110 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "doitgen.h"
/* Array initialization. */
static void init_array(int nr, int nq, int np,
DATA_TYPE POLYBENCH_3D(A, NR, NQ, NP, nr, nq, np),
DATA_TYPE POLYBENCH_2D(C4, NP, NP, np, np))
{
int i, j, k;
for (i = 0; i < nr; i++)
for (j = 0; j < nq; j++)
for (k = 0; k < np; k++)
A[i][j][k] = ((DATA_TYPE)i * j + k) / np;
for (i = 0; i < np; i++)
for (j = 0; j < np; j++)
C4[i][j] = ((DATA_TYPE)i * j) / np;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int nr, int nq, int np,
DATA_TYPE POLYBENCH_3D(A, NR, NQ, NP, nr, nq, np))
{
int i, j, k;
for (i = 0; i < nr; i++)
for (j = 0; j < nq; j++)
for (k = 0; k < np; k++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, A[i][j][k]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_doitgen(int nr, int nq, int np,
DATA_TYPE POLYBENCH_3D(A, NR, NQ, NP, nr, nq, np),
DATA_TYPE POLYBENCH_2D(C4, NP, NP, np, np),
DATA_TYPE POLYBENCH_3D(sum, NR, NQ, NP, nr, nq, np))
{
int r, q, p, s;
for (r = 0; r < _PB_NR; r++)
for (q = 0; q < _PB_NQ; q++)
{
for (p = 0; p < _PB_NP; p++)
{
sum[r][q][p] = 0;
for (s = 0; s < _PB_NP; s++)
sum[r][q][p] = sum[r][q][p] + A[r][q][s] * C4[s][p];
}
for (p = 0; p < _PB_NR; p++)
A[r][q][p] = sum[r][q][p];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int nr = NR;
int nq = NQ;
int np = NP;
/* Variable declaration/allocation. */
POLYBENCH_3D_ARRAY_DECL(A, DATA_TYPE, NR, NQ, NP, nr, nq, np);
POLYBENCH_3D_ARRAY_DECL(sum, DATA_TYPE, NR, NQ, NP, nr, nq, np);
POLYBENCH_2D_ARRAY_DECL(C4, DATA_TYPE, NP, NP, np, np);
/* Initialize array(s). */
init_array(nr, nq, np,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(C4));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_doitgen(nr, nq, np,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(C4),
POLYBENCH_ARRAY(sum));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(nr, nq, np, POLYBENCH_ARRAY(A)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(sum);
POLYBENCH_FREE_ARRAY(C4);
return 0;
}

View file

@ -1,53 +0,0 @@
#ifndef DOITGEN_H
# define DOITGEN_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NQ) && !defined(NR) && !defined(NP)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NQ 10
# define NR 10
# define NP 10
# endif
# ifdef SMALL_DATASET
# define NQ 32
# define NR 32
# define NP 32
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NQ 128
# define NR 128
# define NP 128
# endif
# ifdef LARGE_DATASET
# define NQ 256
# define NR 256
# define NP 256
# endif
# ifdef EXTRALARGE_DATASET
# define NQ 1000
# define NR 1000
# define NP 1000
# endif
# endif /* !N */
# define _PB_NQ POLYBENCH_LOOP_BOUND(NQ,nq)
# define _PB_NR POLYBENCH_LOOP_BOUND(NR,nr)
# define _PB_NP POLYBENCH_LOOP_BOUND(NP,np)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !DOITGEN */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,118 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "gemm.h"
/* Array initialization. */
static void init_array(int ni, int nj, int nk,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nk),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj))
{
int i, j;
*alpha = 32412;
*beta = 2123;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
C[i][j] = ((DATA_TYPE)i * j) / ni;
for (i = 0; i < ni; i++)
for (j = 0; j < nk; j++)
A[i][j] = ((DATA_TYPE)i * j) / ni;
for (i = 0; i < nk; i++)
for (j = 0; j < nj; j++)
B[i][j] = ((DATA_TYPE)i * j) / ni;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni, int nj,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, C[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_gemm(int ni, int nj, int nk,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NI, NK, ni, nk),
DATA_TYPE POLYBENCH_2D(B, NK, NJ, nk, nj))
{
int i, j, k;
/* C := alpha*A*B + beta*C */
#pragma omp for private(j, k)
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NJ; j++)
{
C[i][j] *= beta;
for (k = 0; k < _PB_NK; ++k)
C[i][j] += alpha * A[i][k] * B[k][j];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
int nk = NK;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NK, ni, nk);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NK, NJ, nk, nj);
/* Initialize array(s). */
init_array(ni, nj, nk, &alpha, &beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_gemm(ni, nj, nk,
alpha, beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nj, POLYBENCH_ARRAY(C)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
return 0;
}

View file

@ -1,53 +0,0 @@
#ifndef GEMM_H
# define GEMM_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ) && !defined(NK)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# define NK 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# define NK 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# define NK 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# define NK 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# define NK 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# define _PB_NK POLYBENCH_LOOP_BOUND(NK,nk)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !GEMM */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,157 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "gemver.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_1D(u1, N, n),
DATA_TYPE POLYBENCH_1D(v1, N, n),
DATA_TYPE POLYBENCH_1D(u2, N, n),
DATA_TYPE POLYBENCH_1D(v2, N, n),
DATA_TYPE POLYBENCH_1D(w, N, n),
DATA_TYPE POLYBENCH_1D(x, N, n),
DATA_TYPE POLYBENCH_1D(y, N, n),
DATA_TYPE POLYBENCH_1D(z, N, n))
{
int i, j;
*alpha = 43532;
*beta = 12313;
for (i = 0; i < n; i++)
{
u1[i] = i;
u2[i] = (i + 1) / n / 2.0;
v1[i] = (i + 1) / n / 4.0;
v2[i] = (i + 1) / n / 6.0;
y[i] = (i + 1) / n / 8.0;
z[i] = (i + 1) / n / 9.0;
x[i] = 0.0;
w[i] = 0.0;
for (j = 0; j < n; j++)
A[i][j] = ((DATA_TYPE)i * j) / n;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_1D(w, N, n))
{
int i;
for (i = 0; i < n; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, w[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_gemver(int n,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_1D(u1, N, n),
DATA_TYPE POLYBENCH_1D(v1, N, n),
DATA_TYPE POLYBENCH_1D(u2, N, n),
DATA_TYPE POLYBENCH_1D(v2, N, n),
DATA_TYPE POLYBENCH_1D(w, N, n),
DATA_TYPE POLYBENCH_1D(x, N, n),
DATA_TYPE POLYBENCH_1D(y, N, n),
DATA_TYPE POLYBENCH_1D(z, N, n))
{
int i, j;
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_N; j++)
A[i][j] = A[i][j] + u1[i] * v1[j] + u2[i] * v2[j];
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_N; j++)
x[i] = x[i] + beta * A[j][i] * y[j];
for (i = 0; i < _PB_N; i++)
x[i] = x[i] + z[i];
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_N; j++)
w[i] = w[i] + alpha * A[i][j] * x[j];
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(u1, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(v1, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(u2, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(v2, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(w, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(z, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n, &alpha, &beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(u1),
POLYBENCH_ARRAY(v1),
POLYBENCH_ARRAY(u2),
POLYBENCH_ARRAY(v2),
POLYBENCH_ARRAY(w),
POLYBENCH_ARRAY(x),
POLYBENCH_ARRAY(y),
POLYBENCH_ARRAY(z));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_gemver(n, alpha, beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(u1),
POLYBENCH_ARRAY(v1),
POLYBENCH_ARRAY(u2),
POLYBENCH_ARRAY(v2),
POLYBENCH_ARRAY(w),
POLYBENCH_ARRAY(x),
POLYBENCH_ARRAY(y),
POLYBENCH_ARRAY(z));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(w)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(u1);
POLYBENCH_FREE_ARRAY(v1);
POLYBENCH_FREE_ARRAY(u2);
POLYBENCH_FREE_ARRAY(v2);
POLYBENCH_FREE_ARRAY(w);
POLYBENCH_FREE_ARRAY(x);
POLYBENCH_FREE_ARRAY(y);
POLYBENCH_FREE_ARRAY(z);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef GEMVER_H
# define GEMVER_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# ifndef N
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 4000
# endif
# ifdef LARGE_DATASET
# define N 8000
# endif
# ifdef EXTRALARGE_DATASET
# define N 100000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !GEMVER */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,124 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "gesummv.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_2D(B, N, N, n, n),
DATA_TYPE POLYBENCH_1D(x, N, n))
{
int i, j;
*alpha = 43532;
*beta = 12313;
for (i = 0; i < n; i++)
{
x[i] = ((DATA_TYPE)i) / n;
for (j = 0; j < n; j++)
{
A[i][j] = ((DATA_TYPE)i * j) / n;
B[i][j] = ((DATA_TYPE)i * j) / n;
}
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_1D(y, N, n))
{
int i;
for (i = 0; i < n; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, y[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_gesummv(int n,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_2D(B, N, N, n, n),
DATA_TYPE POLYBENCH_1D(tmp, N, n),
DATA_TYPE POLYBENCH_1D(x, N, n),
DATA_TYPE POLYBENCH_1D(y, N, n))
{
int i, j;
for (i = 0; i < _PB_N; i++)
{
tmp[i] = 0;
y[i] = 0;
for (j = 0; j < _PB_N; j++)
{
tmp[i] = A[i][j] * x[j] + tmp[i];
y[i] = B[i][j] * x[j] + y[i];
}
y[i] = alpha * tmp[i] + beta * y[i];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(tmp, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(y, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n, &alpha, &beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(x));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_gesummv(n, alpha, beta,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B),
POLYBENCH_ARRAY(tmp),
POLYBENCH_ARRAY(x),
POLYBENCH_ARRAY(y));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(y)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
POLYBENCH_FREE_ARRAY(tmp);
POLYBENCH_FREE_ARRAY(x);
POLYBENCH_FREE_ARRAY(y);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef GESUMMV_H
# define GESUMMV_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# ifndef N
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 4000
# endif
# ifdef LARGE_DATASET
# define N 8000
# endif
# ifdef EXTRALARGE_DATASET
# define N 100000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !GESUMMV */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,118 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "mvt.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE POLYBENCH_1D(x1, N, n),
DATA_TYPE POLYBENCH_1D(x2, N, n),
DATA_TYPE POLYBENCH_1D(y_1, N, n),
DATA_TYPE POLYBENCH_1D(y_2, N, n),
DATA_TYPE POLYBENCH_2D(A, N, N, n, n))
{
int i, j;
for (i = 0; i < n; i++)
{
x1[i] = ((DATA_TYPE)i) / n;
x2[i] = ((DATA_TYPE)i + 1) / n;
y_1[i] = ((DATA_TYPE)i + 3) / n;
y_2[i] = ((DATA_TYPE)i + 4) / n;
for (j = 0; j < n; j++)
A[i][j] = ((DATA_TYPE)i * j) / N;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_1D(x1, N, n),
DATA_TYPE POLYBENCH_1D(x2, N, n))
{
int i;
for (i = 0; i < n; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, x1[i]);
fprintf(stderr, DATA_PRINTF_MODIFIER, x2[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_mvt(int n,
DATA_TYPE POLYBENCH_1D(x1, N, n),
DATA_TYPE POLYBENCH_1D(x2, N, n),
DATA_TYPE POLYBENCH_1D(y_1, N, n),
DATA_TYPE POLYBENCH_1D(y_2, N, n),
DATA_TYPE POLYBENCH_2D(A, N, N, n, n))
{
int i, j;
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_N; j++)
x1[i] = x1[i] + A[i][j] * y_1[j];
for (i = 0; i < _PB_N; i++)
for (j = 0; j < _PB_N; j++)
x2[i] = x2[i] + A[j][i] * y_2[j];
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(x1, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(x2, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(y_1, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(y_2, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n,
POLYBENCH_ARRAY(x1),
POLYBENCH_ARRAY(x2),
POLYBENCH_ARRAY(y_1),
POLYBENCH_ARRAY(y_2),
POLYBENCH_ARRAY(A));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_mvt(n,
POLYBENCH_ARRAY(x1),
POLYBENCH_ARRAY(x2),
POLYBENCH_ARRAY(y_1),
POLYBENCH_ARRAY(y_2),
POLYBENCH_ARRAY(A));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(x1), POLYBENCH_ARRAY(x2)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(x1);
POLYBENCH_FREE_ARRAY(x2);
POLYBENCH_FREE_ARRAY(y_1);
POLYBENCH_FREE_ARRAY(y_2);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef MVT_H
# define MVT_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# ifndef N
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 4000
# endif
# ifdef LARGE_DATASET
# define N 8000
# endif
# ifdef EXTRALARGE_DATASET
# define N 100000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !MVT */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,127 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "symm.h"
/* Array initialization. */
static void init_array(int ni, int nj,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NJ, NJ, nj, nj),
DATA_TYPE POLYBENCH_2D(B, NI, NJ, ni, nj))
{
int i, j;
*alpha = 32412;
*beta = 2123;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
C[i][j] = ((DATA_TYPE)i * j) / ni;
B[i][j] = ((DATA_TYPE)i * j) / ni;
}
for (i = 0; i < nj; i++)
for (j = 0; j < nj; j++)
A[i][j] = ((DATA_TYPE)i * j) / ni;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni, int nj,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, C[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_symm(int ni, int nj,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(C, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(A, NJ, NJ, nj, nj),
DATA_TYPE POLYBENCH_2D(B, NI, NJ, ni, nj))
{
int i, j, k;
DATA_TYPE acc;
#pragma scop
#pragma omp parallel
{
/* C := alpha*A*B + beta*C, A is symetric */
#pragma omp for private(j, acc, k)
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NJ; j++)
{
acc = 0;
for (k = 0; k < j - 1; k++)
{
C[k][j] += alpha * A[k][i] * B[i][j];
acc += B[k][j] * A[k][i];
}
C[i][j] = beta * C[i][j] + alpha * A[i][i] * B[i][j] + alpha * acc;
}
}
#pragma endscop
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NJ, NJ, nj, nj);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NI, NJ, ni, nj);
/* Initialize array(s). */
init_array(ni, nj, &alpha, &beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_symm(ni, nj,
alpha, beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nj, POLYBENCH_ARRAY(C)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef SYMM_H
# define SYMM_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !SYMM */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,120 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "syr2k.h"
/* Array initialization. */
static void init_array(int ni, int nj,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(B, NI, NJ, ni, nj))
{
int i, j;
*alpha = 32412;
*beta = 2123;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
A[i][j] = ((DATA_TYPE)i * j) / ni;
B[i][j] = ((DATA_TYPE)i * j) / ni;
}
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
C[i][j] = ((DATA_TYPE)i * j) / ni;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, C[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_syr2k(int ni, int nj,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(B, NI, NJ, ni, nj))
{
int i, j, k;
/* C := alpha*A*B' + alpha*B*A' + beta*C */
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NI; j++)
C[i][j] *= beta;
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NI; j++)
for (k = 0; k < _PB_NJ; k++)
{
C[i][j] += alpha * A[i][k] * B[j][k];
C[i][j] += alpha * B[i][k] * A[j][k];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NI, NI, ni, ni);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NI, NJ, ni, nj);
/* Initialize array(s). */
init_array(ni, nj, &alpha, &beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_syr2k(ni, nj,
alpha, beta,
POLYBENCH_ARRAY(C),
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(B));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, POLYBENCH_ARRAY(C)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef SYR2K_H
# define SYR2K_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !SYR2K */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,103 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "syrk.h"
/* Array initialization. */
static void init_array(int ni, int nj,
DATA_TYPE *alpha,
DATA_TYPE *beta,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj))
{
int i, j;
*alpha = 32412;
*beta = 2123;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
A[i][j] = ((DATA_TYPE)i * j) / ni;
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
C[i][j] = ((DATA_TYPE)i * j) / ni;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, C[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_syrk(int ni, int nj,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(C, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj))
{
int i, j, k;
/* C := alpha*A*A' + beta*C */
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NI; j++)
C[i][j] *= beta;
for (i = 0; i < _PB_NI; i++)
for (j = 0; j < _PB_NI; j++)
for (k = 0; k < _PB_NJ; k++)
C[i][j] += alpha * A[i][k] * A[j][k];
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
DATA_TYPE beta;
POLYBENCH_2D_ARRAY_DECL(C, DATA_TYPE, NI, NI, ni, ni);
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NJ, ni, nj);
/* Initialize array(s). */
init_array(ni, nj, &alpha, &beta, POLYBENCH_ARRAY(C), POLYBENCH_ARRAY(A));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_syrk(ni, nj, alpha, beta, POLYBENCH_ARRAY(C), POLYBENCH_ARRAY(A));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, POLYBENCH_ARRAY(C)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(C);
POLYBENCH_FREE_ARRAY(A);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef SYRK_H
# define SYRK_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# define NJ 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !SYRK */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,96 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "trisolv.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_1D(x, N, n),
DATA_TYPE POLYBENCH_1D(c, N, n))
{
int i, j;
for (i = 0; i < n; i++)
{
c[i] = x[i] = ((DATA_TYPE)i) / n;
for (j = 0; j < n; j++)
A[i][j] = ((DATA_TYPE)i * j) / n;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_1D(x, N, n))
{
int i;
for (i = 0; i < n; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, x[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_trisolv(int n,
DATA_TYPE POLYBENCH_2D(A, N, N, n, n),
DATA_TYPE POLYBENCH_1D(x, N, n),
DATA_TYPE POLYBENCH_1D(c, N, n))
{
int i, j;
for (i = 0; i < _PB_N; i++)
{
x[i] = c[i];
for (j = 0; j <= i - 1; j++)
x[i] = x[i] - A[i][j] * x[j];
x[i] = x[i] / A[i][i];
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(x, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(c, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(x), POLYBENCH_ARRAY(c));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_trisolv(n, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(x), POLYBENCH_ARRAY(c));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(x)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(x);
POLYBENCH_FREE_ARRAY(c);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef TRISOLV_H
# define TRISOLV_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# ifndef N
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 4000
# endif
# ifdef LARGE_DATASET
# define N 8000
# endif
# ifdef EXTRALARGE_DATASET
# define N 100000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !TRISOLV */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,95 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "trmm.h"
/* Array initialization. */
static void init_array(int ni,
DATA_TYPE *alpha,
DATA_TYPE POLYBENCH_2D(A, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(B, NI, NI, ni, ni))
{
int i, j;
*alpha = 32412;
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
{
A[i][j] = ((DATA_TYPE)i * j) / ni;
B[i][j] = ((DATA_TYPE)i * j) / ni;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni,
DATA_TYPE POLYBENCH_2D(B, NI, NI, ni, ni))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < ni; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, B[i][j]);
if ((i * ni + j) % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_trmm(int ni,
DATA_TYPE alpha,
DATA_TYPE POLYBENCH_2D(A, NI, NI, ni, ni),
DATA_TYPE POLYBENCH_2D(B, NI, NI, ni, ni))
{
int i, j, k;
/* B := alpha*A'*B, A triangular */
for (i = 1; i < _PB_NI; i++)
for (j = 0; j < _PB_NI; j++)
for (k = 0; k < i; k++)
B[i][j] += alpha * A[i][k] * B[j][k];
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
/* Variable declaration/allocation. */
DATA_TYPE alpha;
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NI, ni, ni);
POLYBENCH_2D_ARRAY_DECL(B, DATA_TYPE, NI, NI, ni, ni);
/* Initialize array(s). */
init_array(ni, &alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_trmm(ni, alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, POLYBENCH_ARRAY(B)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(B);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef TRMM_H
# define TRMM_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 1024
# endif
# ifdef LARGE_DATASET
# define NI 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !TRMM */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,133 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 4000. */
#include "durbin.h"
/* Array initialization. */
static void init_array(int n,
DATA_TYPE POLYBENCH_2D(y, N, N, n, n),
DATA_TYPE POLYBENCH_2D(sum, N, N, n, n),
DATA_TYPE POLYBENCH_1D(alpha, N, n),
DATA_TYPE POLYBENCH_1D(beta, N, n),
DATA_TYPE POLYBENCH_1D(r, N, n))
{
int i, j;
for (i = 0; i < n; i++)
{
alpha[i] = i;
beta[i] = (i + 1) / n / 2.0;
r[i] = (i + 1) / n / 4.0;
for (j = 0; j < n; j++)
{
y[i][j] = ((DATA_TYPE)i * j) / n;
sum[i][j] = ((DATA_TYPE)i * j) / n;
}
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int n,
DATA_TYPE POLYBENCH_1D(out, N, n))
{
int i;
for (i = 0; i < n; i++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, out[i]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_durbin(int n,
DATA_TYPE POLYBENCH_2D(y, N, N, n, n),
DATA_TYPE POLYBENCH_2D(sum, N, N, n, n),
DATA_TYPE POLYBENCH_1D(alpha, N, n),
DATA_TYPE POLYBENCH_1D(beta, N, n),
DATA_TYPE POLYBENCH_1D(r, N, n),
DATA_TYPE POLYBENCH_1D(out, N, n))
{
int i, k;
#pragma scop
y[0][0] = r[0];
beta[0] = 1;
alpha[0] = r[0];
for (k = 1; k < _PB_N; k++)
{
beta[k] = beta[k - 1] - alpha[k - 1] * alpha[k - 1] * beta[k - 1];
sum[0][k] = r[k];
for (i = 0; i <= k - 1; i++)
sum[i + 1][k] = sum[i][k] + r[k - i - 1] * y[i][k - 1];
alpha[k] = -sum[k][k] * beta[k];
for (i = 0; i <= k - 1; i++)
y[i][k] = y[i][k - 1] + alpha[k] * y[k - i - 1][k - 1];
y[k][k] = alpha[k];
}
for (i = 0; i < _PB_N; i++)
out[i] = y[i][_PB_N - 1];
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int n = N;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(y, DATA_TYPE, N, N, n, n);
POLYBENCH_2D_ARRAY_DECL(sum, DATA_TYPE, N, N, n, n);
POLYBENCH_1D_ARRAY_DECL(alpha, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(beta, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(r, DATA_TYPE, N, n);
POLYBENCH_1D_ARRAY_DECL(out, DATA_TYPE, N, n);
/* Initialize array(s). */
init_array(n,
POLYBENCH_ARRAY(y),
POLYBENCH_ARRAY(sum),
POLYBENCH_ARRAY(alpha),
POLYBENCH_ARRAY(beta),
POLYBENCH_ARRAY(r));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_durbin(n,
POLYBENCH_ARRAY(y),
POLYBENCH_ARRAY(sum),
POLYBENCH_ARRAY(alpha),
POLYBENCH_ARRAY(beta),
POLYBENCH_ARRAY(r),
POLYBENCH_ARRAY(out));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(out)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(y);
POLYBENCH_FREE_ARRAY(sum);
POLYBENCH_FREE_ARRAY(alpha);
POLYBENCH_FREE_ARRAY(beta);
POLYBENCH_FREE_ARRAY(r);
POLYBENCH_FREE_ARRAY(out);
return 0;
}

View file

@ -1,41 +0,0 @@
#ifndef DURBIN_H
# define DURBIN_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# ifndef N
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define N 32
# endif
# ifdef SMALL_DATASET
# define N 500
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define N 4000
# endif
# ifdef LARGE_DATASET
# define N 8000
# endif
# ifdef EXTRALARGE_DATASET
# define N 100000
# endif
# endif /* !N */
# define _PB_N POLYBENCH_LOOP_BOUND(N,n)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !DURBIN */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,106 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is int, default size is 50. */
#include "dynprog.h"
/* Array initialization. */
static void init_array(int length,
DATA_TYPE POLYBENCH_2D(c, LENGTH, LENGTH, length, length),
DATA_TYPE POLYBENCH_2D(W, LENGTH, LENGTH, length, length))
{
int i, j;
for (i = 0; i < length; i++)
for (j = 0; j < length; j++)
{
c[i][j] = i * j % 2;
W[i][j] = ((DATA_TYPE)i - j) / length;
}
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(DATA_TYPE out)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, out);
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_dynprog(int tsteps, int length,
DATA_TYPE POLYBENCH_2D(c, LENGTH, LENGTH, length, length),
DATA_TYPE POLYBENCH_2D(W, LENGTH, LENGTH, length, length),
DATA_TYPE POLYBENCH_3D(sum_c, LENGTH, LENGTH, LENGTH, length, length, length),
DATA_TYPE *out)
{
int iter, i, j, k;
DATA_TYPE out_l = 0;
for (iter = 0; iter < _PB_TSTEPS; iter++)
{
for (i = 0; i <= _PB_LENGTH - 1; i++)
for (j = 0; j <= _PB_LENGTH - 1; j++)
c[i][j] = 0;
for (i = 0; i <= _PB_LENGTH - 2; i++)
{
for (j = i + 1; j <= _PB_LENGTH - 1; j++)
{
sum_c[i][j][i] = 0;
for (k = i + 1; k <= j - 1; k++)
sum_c[i][j][k] = sum_c[i][j][k - 1] + c[i][k] + c[k][j];
c[i][j] = sum_c[i][j][j - 1] + W[i][j];
}
}
out_l += c[0][_PB_LENGTH - 1];
}
*out = out_l;
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int length = LENGTH;
int tsteps = TSTEPS;
/* Variable declaration/allocation. */
DATA_TYPE out;
POLYBENCH_3D_ARRAY_DECL(sum_c, DATA_TYPE, LENGTH, LENGTH, LENGTH, length, length, length);
POLYBENCH_2D_ARRAY_DECL(c, DATA_TYPE, LENGTH, LENGTH, length, length);
POLYBENCH_2D_ARRAY_DECL(W, DATA_TYPE, LENGTH, LENGTH, length, length);
/* Initialize array(s). */
init_array(length, POLYBENCH_ARRAY(c), POLYBENCH_ARRAY(W));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_dynprog(tsteps, length,
POLYBENCH_ARRAY(c),
POLYBENCH_ARRAY(W),
POLYBENCH_ARRAY(sum_c),
&out);
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(out));
/* Be clean. */
POLYBENCH_FREE_ARRAY(sum_c);
POLYBENCH_FREE_ARRAY(c);
POLYBENCH_FREE_ARRAY(W);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef DYNPROG_H
# define DYNPROG_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(TSTEPS) && !defined(LENGTH)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define TSTEPS 10
# define LENGTH 32
# endif
# ifdef SMALL_DATASET
# define TSTEPS 100
# define LENGTH 50
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define TSTEPS 10000
# define LENGTH 50
# endif
# ifdef LARGE_DATASET
# define TSTEPS 1000
# define LENGTH 500
# endif
# ifdef EXTRALARGE_DATASET
# define TSTEPS 10000
# define LENGTH 500
# endif
# endif /* !N */
# define _PB_TSTEPS POLYBENCH_LOOP_BOUND(TSTEPS,tsteps)
# define _PB_LENGTH POLYBENCH_LOOP_BOUND(LENGTH,length)
# ifndef DATA_TYPE
# define DATA_TYPE int
# define DATA_PRINTF_MODIFIER "%d "
# endif
#endif /* !DYNPROG */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

View file

@ -1,137 +0,0 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
/* Include polybench common header. */
#include <polybench.h>
/* Include benchmark-specific header. */
/* Default data type is double, default size is 512. */
#include "gramschmidt.h"
/* Array initialization. */
static void init_array(int ni, int nj,
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(R, NJ, NJ, nj, nj),
DATA_TYPE POLYBENCH_2D(Q, NI, NJ, ni, nj))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
A[i][j] = ((DATA_TYPE)i * j) / ni;
Q[i][j] = ((DATA_TYPE)i * (j + 1)) / nj;
}
for (i = 0; i < nj; i++)
for (j = 0; j < nj; j++)
R[i][j] = ((DATA_TYPE)i * (j + 2)) / nj;
}
/* DCE code. Must scan the entire live-out data.
Can be used also to check the correctness of the output. */
static void print_array(int ni, int nj,
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(R, NJ, NJ, nj, nj),
DATA_TYPE POLYBENCH_2D(Q, NI, NJ, ni, nj))
{
int i, j;
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, A[i][j]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
for (i = 0; i < nj; i++)
for (j = 0; j < nj; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, R[i][j]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
for (i = 0; i < ni; i++)
for (j = 0; j < nj; j++)
{
fprintf(stderr, DATA_PRINTF_MODIFIER, Q[i][j]);
if (i % 20 == 0)
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
/* Main computational kernel. The whole function will be timed,
including the call and return. */
static void kernel_gramschmidt(int ni, int nj,
DATA_TYPE POLYBENCH_2D(A, NI, NJ, ni, nj),
DATA_TYPE POLYBENCH_2D(R, NJ, NJ, nj, nj),
DATA_TYPE POLYBENCH_2D(Q, NI, NJ, ni, nj))
{
int i, j, k;
DATA_TYPE nrm;
for (k = 0; k < _PB_NJ; k++)
{
nrm = 0;
for (i = 0; i < _PB_NI; i++)
nrm += A[i][k] * A[i][k];
R[k][k] = sqrt(nrm);
for (i = 0; i < _PB_NI; i++)
Q[i][k] = A[i][k] / R[k][k];
for (j = k + 1; j < _PB_NJ; j++)
{
R[k][j] = 0;
for (i = 0; i < _PB_NI; i++)
R[k][j] += Q[i][k] * A[i][j];
for (i = 0; i < _PB_NI; i++)
A[i][j] = A[i][j] - Q[i][k] * R[k][j];
}
}
}
int main(int argc, char **argv)
{
/* Retrieve problem size. */
int ni = NI;
int nj = NJ;
/* Variable declaration/allocation. */
POLYBENCH_2D_ARRAY_DECL(A, DATA_TYPE, NI, NJ, ni, nj);
POLYBENCH_2D_ARRAY_DECL(R, DATA_TYPE, NJ, NJ, nj, nj);
POLYBENCH_2D_ARRAY_DECL(Q, DATA_TYPE, NI, NJ, ni, nj);
/* Initialize array(s). */
init_array(ni, nj,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(R),
POLYBENCH_ARRAY(Q));
/* Start timer. */
polybench_start_instruments;
/* Run kernel. */
kernel_gramschmidt(ni, nj,
POLYBENCH_ARRAY(A),
POLYBENCH_ARRAY(R),
POLYBENCH_ARRAY(Q));
/* Stop and print timer. */
polybench_stop_instruments;
polybench_print_instruments;
/* Prevent dead-code elimination. All live-out data must be printed
by the function call in argument. */
polybench_prevent_dce(print_array(ni, nj, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(R), POLYBENCH_ARRAY(Q)));
/* Be clean. */
POLYBENCH_FREE_ARRAY(A);
POLYBENCH_FREE_ARRAY(R);
POLYBENCH_FREE_ARRAY(Q);
return 0;
}

View file

@ -1,47 +0,0 @@
#ifndef GRAMSCHMIDT_H
# define GRAMSCHMIDT_H
/* Default to STANDARD_DATASET. */
# if !defined(MINI_DATASET) && !defined(SMALL_DATASET) && !defined(LARGE_DATASET) && !defined(EXTRALARGE_DATASET)
# define STANDARD_DATASET
# endif
/* Do not define anything if the user manually defines the size. */
# if !defined(NI) && !defined(NJ)
/* Define the possible dataset sizes. */
# ifdef MINI_DATASET
# define NI 32
# define NJ 32
# endif
# ifdef SMALL_DATASET
# define NI 128
# define NJ 128
# endif
# ifdef STANDARD_DATASET /* Default if unspecified. */
# define NI 512
# define NJ 512
# endif
# ifdef LARGE_DATASET
# define NI 2000
# define NJ 2000
# endif
# ifdef EXTRALARGE_DATASET
# define NI 4000
# define NJ 4000
# endif
# endif /* !N */
# define _PB_NI POLYBENCH_LOOP_BOUND(NI,ni)
# define _PB_NJ POLYBENCH_LOOP_BOUND(NJ,nj)
# ifndef DATA_TYPE
# define DATA_TYPE double
# define DATA_PRINTF_MODIFIER "%0.2lf "
# endif
#endif /* !GRAMSCHMIDT */

View file

@ -1,3 +0,0 @@
-include ../../../utilities/options.mk
-include ../../../utilities/c2.mk

Some files were not shown because too many files have changed in this diff Show more