-
Notifications
You must be signed in to change notification settings - Fork 7
/
compile_info.h
104 lines (84 loc) · 2.28 KB
/
compile_info.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef BINARY_INFO_H
#define BINARY_INFO_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define MAX_INFO_STRING_LENGTH 1024
int get_compiler_info( char *info_str ) {
/* For compiler predfined macros used for identification see
* http://predef.sourceforge.net/precomp.html
*/
/* Cray compiler */
#if defined(_CRAYC)
sprintf( info_str, "Cray %d.%d", _RELEASE, _RELEASE_MINOR );
#endif
/* GNU compiler */
#if defined(__GNUC__)
# if defined(__GNUC_PATCHLEVEL__)
sprintf( info_str, "GNU %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ );
# else
sprintf( info_str, "GNU %d.%d", __GNUC__, __GNUC_MINOR__ );
# endif
/* Intel compiler */
#elif defined(__INTEL_COMPILER)
int version = (int) __INTEL_COMPILER / 100;
int revision = ((int)__INTEL_COMPILER % 100) / 10;
int patch = (int) __INTEL_COMPILER % 10;
sprintf( info_str, "Intel %d.%d.%d", version, revision, patch );
/* PGI compiler */
#elif defined(__PGI)
sprintf( info_str, "PGI" );
/* Sun compiler */
#elif defined(__SUNPRO_C)
int version = (__SUNPRO_C >> 12) & 0xf;
int revision_digit1 = (__SUNPRO_C >> 8) & 0xf;
int revision_digit2 = (__SUNPRO_C >> 4) & 0xf;
int patch = (__SUNPRO_C >> 0 ) & 0xf;
sprintf( info_str, "Sun %d.%d%d.%d", version, revision_digit1, revision_digit2, patch );
/* unknown */
#else
sprintf( info_str, "unknown" );
#endif
return 0;
}
#if defined(MPI_VERSION)
int get_mpi_info(char *info_str) {
#if defined(MVAPICH2)
sprintf( info_str, "MVAPICH2");
#elif defined(OPEN_MPI)
sprintf( info_str, "Open MPI");
#elif defined(I_MPI_VERSION)
sprintf( info_str, "Intel MPI");
#elif defined(CRAY_MPI)
sprintf( info_str, "Cray MPI");
#elif defined(MPICH)
sprintf( info_str, "MPICH");
#else
sprintf( info_str, "unknown");
#endif
return 0;
}
#endif
int get_compile_time( char *info_str ) {
sprintf( info_str, "%s %s", __DATE__, __TIME__ );
return 0;
}
int get_timestamp ( char *info_str ) {
time_t t;
struct tm *ts;
t = time(NULL);
ts = localtime(&t);
sprintf( info_str, "D%d-%d-%d T%d:%d:%d",
ts->tm_mday, ts->tm_mon + 1, ts->tm_year + 1900,
ts->tm_hour, ts->tm_min, ts->tm_sec );
return 0;
}
int get_host( char *info_str ) {
char hostname[1024];
hostname[1023] = '\0';
gethostname(hostname, 1023 );
sprintf( info_str, "%s", hostname );
return 0;
}
#endif