Hitmap 1.3
|
#include <stdio.h>
#include <stdlib.h>
#include <hitmap.h>
#include <hit_com.h>
#include <unistd.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | Vector |
struct | Matrix |
Macros | |
#define | printfRootInternal(...) { if( hit_Rank == 0 ) { printf(__VA_ARGS__); fflush(stdout); }} |
#define | printfRoot(...) printfRootInternal(__VA_ARGS__) |
#define | D (3) |
#define | K (1) |
#define | L (0.001) |
#define | P_FIXED 10 |
#define | ITER1 10 |
#define | ITER2 100 |
#define | clearV(vv) clearVInternal((vv).v) |
#define | clearVInternal(v) ((v)[0] = (v)[1] = (v)[2] = 0.0 ) |
#define | cpyV(r, a) cpyVInternal((r).v,(a).v) |
#define | cpyVInternal(r, a) {(r)[0] = (a)[0]; (r)[1] = (a)[1]; (r)[2] = (a)[2]; } |
#define | addV(r, a, b) addVInternal((r).v,(a).v,(b).v) |
#define | addVInternal(r, a, b) {(r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; } |
#define | subV(r, a, b) subVInternal((r).v,(a).v,(b).v) |
#define | subVInternal(r, a, b) {(r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; } |
#define | norm(vv) normInternal((vv).v) |
#define | normInternal(v) (sqrt( pow((v)[0],2) + pow((v)[1],2) + pow((v)[2],2) )) |
#define | multSV(r, s, vv) multSVInternal((r).v,s,(vv).v) |
#define | multSVInternal(r, s, v) {(r)[0] = (s) * (v)[0]; (r)[1] = (s) * (v)[1]; (r)[2] = (s) * (v)[2]; } |
#define | clearM(mm) clearMInternal((mm).m) |
#define | clearMInternal(m) |
#define | det(mm) detInternal((mm).m) |
#define | detInternal(m) |
#define | init_matrix(mm, a, b, c, d, e, f, g, h, i) init_matrixInternal((mm).m,a,b,c,d,e,f,g,h,i) |
#define | init_matrixInternal(m, a, b, c, d, e, f, g, h, i) |
#define | multSM(r, s, mm) multSMInternal((r).m,s,(mm).m) |
#define | multSMInternal(r, s, m) |
#define | multSI(r, s) multSIInternal((r).m,s) |
#define | multSIInternal(r, s) |
#define | addM(r, a, b) addMInternal((r).m,(a).m,(b).m) |
#define | addMInternal(r, a, b) |
#define | multVVt(r, a, b) multVVtInternal((r).m,(a).v,(b).v) |
#define | multVVtInternal(r, a, b) |
#define | multMV(r, mm, vv) multMVInternal((r).v,(mm).m,(vv).v) |
#define | multMVInternal(r, m, v) |
#define | inv(r, mm) invInternal((r).m,(mm).m) |
#define | invInternal(r, m) |
#define | multMM(r, a, b) multMMInternal((r).m,(a).m,(b).m) |
#define | multMMInternal(r, a, b) |
#define | ITER_SJ 10 |
Functions | |
hit_tileNewType (Vector) | |
hit_tileNewType (Matrix) | |
hit_tileNewType (int) | |
hit_tileNewType (double) | |
void | calculate_GH (int vertex) |
void | solve_system_iter (int vertex) |
Vector | solve_jacobi (Matrix A, Vector b) |
Vector | solve (Matrix A, Vector b) |
void | init_structures () |
void | free_structures () |
void | print_help (char *name) |
char * | replace_str (char *str, const char *orig, const char *rep) |
void | random_coordinates () |
void | init_graph (int argc, char **argv) |
double | gradient_norm () |
int | main (int argc, char **argv) |
Vector | g (int i, int j) |
Matrix | W (int i, int j) |
Variables | |
int | iter1 = ITER1 |
int | iter2 = ITER2 |
HitTile_Vector | gradient |
HitTile_Matrix | hessian |
HitTile_Vector | e |
HitTile_Vector | new_e |
HitShape | global_shape |
HitShape | shape |
HitShape | ext_shape |
HitTile_Vector | graph |
HitTile_Vector | global_graph |
HitTile_int | fixed |
HitTile_int | global_fixed |
HitLayout | lay = HIT_LAYOUT_NULL_STATIC |
Calculate the stable position of a spring system. Parallel hitmap version of the benchmark.
Definition in file spring_csr.c.
Add two matrix, r = a + b.
Definition at line 291 of file spring_csr.c.
#define addMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 292 of file spring_csr.c.
Add two vectors, r = a + b.
Definition at line 206 of file spring_csr.c.
#define addVInternal | ( | r, | |
a, | |||
b | |||
) | {(r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; } |
Definition at line 207 of file spring_csr.c.
#define clearM | ( | mm | ) | clearMInternal((mm).m) |
Clear a matrix.
Definition at line 235 of file spring_csr.c.
#define clearMInternal | ( | m | ) |
#define clearV | ( | vv | ) | clearVInternal((vv).v) |
Clear a vector.
Definition at line 192 of file spring_csr.c.
Definition at line 193 of file spring_csr.c.
#define cpyV | ( | r, | |
a | |||
) | cpyVInternal((r).v,(a).v) |
Copy a vector.
Definition at line 199 of file spring_csr.c.
Definition at line 200 of file spring_csr.c.
#define D (3) |
Number of dimensions.
Definition at line 59 of file spring_csr.c.
#define det | ( | mm | ) | detInternal((mm).m) |
Calculate the determinant.
a b c d e f g h i
det = aei + bfg + cdh - afh - bdi - ceg
Definition at line 251 of file spring_csr.c.
#define detInternal | ( | m | ) |
Initialization of a matrix.
Definition at line 263 of file spring_csr.c.
Definition at line 264 of file spring_csr.c.
Inverses a matrix.
Definition at line 321 of file spring_csr.c.
Definition at line 322 of file spring_csr.c.
#define ITER1 10 |
Default number of iterations for the Newton-Raphson method.
Definition at line 70 of file spring_csr.c.
#define ITER2 100 |
Default number of iterations for the Jacobi method.
Definition at line 72 of file spring_csr.c.
#define ITER_SJ 10 |
#define K (1) |
Spring constant.
Definition at line 62 of file spring_csr.c.
#define L (0.001) |
Spring length.
Definition at line 64 of file spring_csr.c.
Multiplies two matrices.
Definition at line 337 of file spring_csr.c.
#define multMMInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 338 of file spring_csr.c.
Multiplies a matrix with a vector.
Definition at line 311 of file spring_csr.c.
Definition at line 312 of file spring_csr.c.
Multiplication scalar x identity matrix.
Definition at line 281 of file spring_csr.c.
Multiplication scalar x matrix.
Definition at line 272 of file spring_csr.c.
Definition at line 273 of file spring_csr.c.
Multiplication scalar x vector.
Definition at line 228 of file spring_csr.c.
#define multSVInternal | ( | r, | |
s, | |||
v | |||
) | {(r)[0] = (s) * (v)[0]; (r)[1] = (s) * (v)[1]; (r)[2] = (s) * (v)[2]; } |
Definition at line 229 of file spring_csr.c.
Multiply a vector with a transposed vector. the result is a matrix.
Definition at line 301 of file spring_csr.c.
#define multVVtInternal | ( | r, | |
a, | |||
b | |||
) |
Definition at line 302 of file spring_csr.c.
#define norm | ( | vv | ) | normInternal((vv).v) |
Calculate the norm of a vector
Definition at line 221 of file spring_csr.c.
Definition at line 222 of file spring_csr.c.
#define P_FIXED 10 |
Percentage of fixed points
Definition at line 67 of file spring_csr.c.
#define printfRoot | ( | ... | ) | printfRootInternal(__VA_ARGS__) |
Definition at line 56 of file spring_csr.c.
#define printfRootInternal | ( | ... | ) | { if( hit_Rank == 0 ) { printf(__VA_ARGS__); fflush(stdout); }} |
Definition at line 55 of file spring_csr.c.
Subtract two vectors, r = a - b.
Definition at line 214 of file spring_csr.c.
#define subVInternal | ( | r, | |
a, | |||
b | |||
) | {(r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; } |
Definition at line 215 of file spring_csr.c.
void calculate_GH | ( | int | vertex | ) |
Function to calculate the gradient and hessian for a given node.
vertex | The vertex index. |
Function to calculate the gradient and hessian for a given node. Gradient: gs_i = Sum_j gij
vertex | The vertex index. |
void free_structures | ( | ) |
Release the memory
Definition at line 442 of file spring_csr.c.
Vector g | ( | int | i, |
int | j | ||
) |
Auxiliar function to get the gradient.
Definition at line 842 of file spring_csr.c.
double gradient_norm | ( | ) |
Calculate the norm of the whole gradient vector.
Definition at line 664 of file spring_csr.c.
hit_tileNewType | ( | Vector | ) |
hit_tileNewType | ( | Matrix | ) |
hit_tileNewType | ( | int | ) |
hit_tileNewType | ( | double | ) |
void init_graph | ( | int | argc, |
char ** | argv | ||
) |
Init the graph
Definition at line 538 of file spring_csr.c.
void init_structures | ( | ) |
Allocate memory of all the variables
Definition at line 427 of file spring_csr.c.
int main | ( | int | argc, |
char ** | argv | ||
) |
Main function
Definition at line 719 of file spring_csr.c.
void print_help | ( | char * | name | ) |
void random_coordinates | ( | ) |
Generate random coordinates for the spring nodes. It also set the fixed nodes
Definition at line 501 of file spring_csr.c.
char* replace_str | ( | char * | str, |
const char * | orig, | ||
const char * | rep | ||
) |
Solve a linear system. It calculates the inverse matrix. If the matrix is singular, it use the jacobi method to get an approximation. Ax=b.
A | The coefficients matrix. |
b | The constant terms vector. |
Definition at line 405 of file spring_csr.c.
Solve a linear system using the jacobi method. Ax=b.
A | The coefficients matrix. |
b | The constant terms vector. |
Definition at line 357 of file spring_csr.c.
void solve_system_iter | ( | int | vertex | ) |
Function that solves a iteration of the jacobi method for a given node.
vertex | The vertex index. |
Function that solves a iteration of the jacobi method for a given node. e_i = H_ii^(-1) * (Gi - SUM_{i not j} ( Hij e_j ) )
vertex | The vertex index. |
Matrix W | ( | int | i, |
int | j | ||
) |
Auxiliary function to get the hessian.
Definition at line 879 of file spring_csr.c.
HitTile_Vector e |
Vector with the position increase.
Definition at line 114 of file spring_csr.c.
HitShape ext_shape |
Hit shape defining the extended local spring structure.
Definition at line 126 of file spring_csr.c.
HitTile_int fixed |
Tile with the fixed/free status
Definition at line 135 of file spring_csr.c.
HitTile_int global_fixed |
Tile with all the fixed/free status
Definition at line 138 of file spring_csr.c.
HitTile_Vector global_graph |
Tile with all the node values.
Definition at line 132 of file spring_csr.c.
HitShape global_shape |
Hit shape defining the spring structure.
Definition at line 120 of file spring_csr.c.
HitTile_Vector gradient |
Gradient array part for each node.
Definition at line 108 of file spring_csr.c.
HitTile_Vector graph |
Tile with the local node values.
Definition at line 129 of file spring_csr.c.
HitTile_Matrix hessian |
Hessian matrix part for each edge.
Definition at line 111 of file spring_csr.c.
int iter1 = ITER1 |
Number of iterations for the Newton-Raphson method.
Definition at line 75 of file spring_csr.c.
int iter2 = ITER2 |
Number of iterations for the Jacobi method.
Definition at line 77 of file spring_csr.c.
Layout
Definition at line 142 of file spring_csr.c.
HitTile_Vector new_e |
Vector with the new position increase.
Definition at line 117 of file spring_csr.c.
HitShape shape |
Hit shape defining the local spring structure.
Definition at line 123 of file spring_csr.c.