| 1 | #ifndef helpers_h | 
|---|
| 2 | #define helpers_h | 
|---|
| 3 | /** \file helpers.h | 
|---|
| 4 | * Header file for \ref helpers.c | 
|---|
| 5 | * | 
|---|
| 6 | * Contains declarations of the functions implemented in \ref helpers.c and one | 
|---|
| 7 | * inline function which gets current time via an MPI call: GetTime(). | 
|---|
| 8 | * | 
|---|
| 9 | Project: ParallelCarParrinello | 
|---|
| 10 | Jan Hamaekers | 
|---|
| 11 | 2000 | 
|---|
| 12 |  | 
|---|
| 13 | File: helpers.h | 
|---|
| 14 | $Id: helpers.h,v 1.9 2007/02/09 09:13:48 foo Exp $ | 
|---|
| 15 | */ | 
|---|
| 16 |  | 
|---|
| 17 | #include<stddef.h> /* fuer size_t */ | 
|---|
| 18 |  | 
|---|
| 19 | // taken out of TREMOLO | 
|---|
| 20 | /*@-namechecks@*/ | 
|---|
| 21 | #ifndef __GNUC__ | 
|---|
| 22 | # undef __attribute__ | 
|---|
| 23 | # define __attribute__(x) | 
|---|
| 24 | #endif | 
|---|
| 25 | /*@=namechecks@*/ | 
|---|
| 26 |  | 
|---|
| 27 |  | 
|---|
| 28 | /* Behandelt aufgetretene Fehler. error ist der Fehlertyp(enum Errors) | 
|---|
| 29 | void *SpecialData ist ein untypisierter Zeiger auf Spezielle Daten zur Fehlerbehandlung. | 
|---|
| 30 | Man koennte auch noch einen Zeiger auf eine Funktion uebergeben */ | 
|---|
| 31 | extern void /*@exits@*/ debug(struct Problem *P, const char *output); | 
|---|
| 32 | //__attribute__ ((__return__)); | 
|---|
| 33 | #define debug(problemstruct, data) debug_in((problemstruct), (data), __FILE__, __LINE__) | 
|---|
| 34 |  | 
|---|
| 35 | extern void /*@exits@*/ debug_in(struct Problem *P, const char *output, | 
|---|
| 36 | const char *file, const int line); | 
|---|
| 37 | //__attribute__ ((__return__)); | 
|---|
| 38 |  | 
|---|
| 39 | /* Eigene malloc, die bei einem Fehler an Error output uebergibt */ | 
|---|
| 40 | void* Malloc(size_t size, const char* output); | 
|---|
| 41 |  | 
|---|
| 42 | char* MallocString(size_t size, const char* output); | 
|---|
| 43 |  | 
|---|
| 44 | /* Eigene malloc, die bei einem Fehler erzeugten (ein int rein) output  an Error uebergibt */ | 
|---|
| 45 | void* Malloci(size_t size, const char* output, int i); | 
|---|
| 46 |  | 
|---|
| 47 | /* Eigene malloc, die bei einem Fehler erzeugten (zwei int rein) output  an Error uebergibt */ | 
|---|
| 48 | void* Mallocii(size_t size, const char* output, int i, int j); | 
|---|
| 49 |  | 
|---|
| 50 | /* Dasselbe wie oben mit realloc */ | 
|---|
| 51 | void* Realloc(void* pointer, size_t size, const char* output); | 
|---|
| 52 | void* Realloci(void* pointer, size_t size, const char* output, int i); | 
|---|
| 53 | void* Reallocii(void* pointer, size_t size, const char* output, int i, int j); | 
|---|
| 54 | void Free (void *ptr, const char* output); | 
|---|
| 55 |  | 
|---|
| 56 | void GetRGB(int i, unsigned int max, double* rgb); | 
|---|
| 57 |  | 
|---|
| 58 | /** Get current time. | 
|---|
| 59 | * Uses MPI_Wtime() to get current system time, synchronously for all processes. | 
|---|
| 60 | * \return current time | 
|---|
| 61 | */ | 
|---|
| 62 | static inline /*@unused@*/ double GetTime(void) | 
|---|
| 63 | { | 
|---|
| 64 | double t; | 
|---|
| 65 | t = MPI_Wtime(); | 
|---|
| 66 | return t; | 
|---|
| 67 | }; | 
|---|
| 68 |  | 
|---|
| 69 | void InitSpeedMeasure(struct Problem *P); | 
|---|
| 70 | void SpeedMeasure(struct Problem *P, enum TimeTypes TT, enum TimeDoTypes TOT); | 
|---|
| 71 | void CompleteSpeedMeasure(struct Problem *P); | 
|---|
| 72 | void StartParallel (struct Problem *P, char **argv); | 
|---|
| 73 | void WaitForOtherProcs(struct Problem *P, int out); | 
|---|
| 74 | /*void SetArrayToDouble0(double *a, int n);*/ | 
|---|
| 75 | void RemoveEverything(struct Problem *P); | 
|---|
| 76 | #endif | 
|---|