23#include "hardware.inc"
26#if CPP_mach == CPP_w95 || CPP_mach == CPP_win64_spmd || CPP_mach == CPP_p4win64_spmd || CPP_mach == CPP_wnt || CPP_mach == CPP_wmr || CPP_mach == CPP_p4win64 || CPP_mach == CPP_p4win32
35#if CPP_mach==CPP_linux || CPP_mach == CPP_linux64_spmd || CPP_mach == CPP_p4linux964_spmd || CPP_mach == CPP_il_spmd || CPP_mach == CPP_il || CPP_mach == CPP_linux_spmd || CPP_mach == CPP_linux || CPP_mach == CPP_linux964 || CPP_mach == CPP_p4linux964 || CPP_mach == CPP_p4linux932
42#include <sys/sysinfo.h>
44#include <sys/utsname.h>
47void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
59#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
60 char * compstr=
"family :";
62 char * compstr=
"model name";
64 char * compMHZ=
"cpu MHz";
65 int cpMHZ=strlen(compMHZ);
66 int cmplen=strlen(compstr);
73 stream=fopen(
"/proc/cpuinfo",
"r");
79 lenmach=strlen(unam.machine);
81 while (fgets(ligne,255,stream) && unknown){
82 if (strncmp(compstr,ligne,cmplen)==0){
96 while (ligne[debut]==
' ' );
98 for (i=debut; i<size-1;i++) {
100 cputype[j] = ligne[i];
108 for (i=0; i<lenmach;i++) {
109 cputype[j] = unam.machine[i];
117 sprintf(cputype,
"Unknown");
119 *lencputype = strlen(cputype);
126 while (fgets(ligne,255,stream) && unknown){
127 if (strncmp(compMHZ,ligne,cpMHZ)==0){
133#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
139 size = strlen(ligne);
140 for (i=debut; i<size-1;i++) {
145#if CPP_mach==CPP_il || CPP_mach==CPP_il_spmd
149 *frequence = atoi(freq);
158 gethostname(hostname, 256);
159 *lenhost = strlen(hostname);
163 *memory = info.totalram*info.mem_unit/(1024*1024);
164 *
swap = info.freeswap*info.mem_unit/(1024*1024);
169#elif CPP_mach == CPP_wmr || CPP_mach==CPP_wnt || CPP_mach==CPP_p4win64_spmd || CPP_mach==CPP_win64_spmd || CPP_mach==CPP_p4win64 || CPP_mach==CPP_p4win32
180#include <sys\types.h>
182#if CPP_mach == CPP_p4win64_spmd || CPP_mach==CPP_p4win64 || CPP_mach==CPP_p4win32 || CPP_mach==CPP_wnt && CPP_rel==10
184#define pclose _pclose
188void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
190 FILE * stream = NULL;
196 WORD version = MAKEWORD(1,1);
199 char RegKey_Entry[]=
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
200 char query1[] =
"ProcessorNameString";
208 MEMORYSTATUSEX statex;
212 nRet = WSAStartup(version, &wsaData);
213 len=gethostname(hostname,256);
214 len=WSAGetLastError();
215 *lenhost = strlen(hostname);
219 if ( RegOpenKeyEx ( HKEY_LOCAL_MACHINE,RegKey_Entry,0, KEY_QUERY_VALUE, &
handle ) != ERROR_SUCCESS )
goto FAIL1;
220 if ( RegQueryValueEx (
handle,query1, NULL, NULL,(LPBYTE) hname1,(LPDWORD) &mxlen1 ) != ERROR_SUCCESS )
goto FAIL1;
223 GetSystemInfo(&info);
224 if (info.dwProcessorType < 8664) {
227 else { hname2=
"x86_64"; }
229 sprintf(cputype,
"%s (%s)",hname1,hname2);
233 sprintf(cputype,
"UNKOWN");
237 *lencputype = strlen(cputype);
241 if ( RegOpenKeyEx ( HKEY_LOCAL_MACHINE,
242 "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
243 0, KEY_QUERY_VALUE, &
handle ) != ERROR_SUCCESS )
245 if ( RegQueryValueEx (
handle,
"~MHz", NULL, NULL,
246 (LPBYTE )(&mhz) ,(LPDWORD) &l ) != ERROR_SUCCESS )
249 *frequence = (int)(mhz/50.0 +0.5)*50;
255 statex.dwLength =
sizeof (statex);
257 GlobalMemoryStatus (&statex);
258 *memory = statex.dwAvailPhys/(1024*1024);
260 *
swap=statex.dwTotalPageFile/(1024*1024);
262 statex.dwLength =
sizeof (statex);
263 GlobalMemoryStatusEx (&statex);
265 *memory = statex.ullAvailPhys/(1024*1024);
266 *
swap=statex.ullTotalPageFile/(1024*1024);
273#elif CPP_mach ==CPP_hp11 || CPP_mach == CPP_hp11_spmd
280#include <sys/pstat.h>
281#include <sys/param.h>
285void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
296 struct pst_processor psp;
297 struct pst_dynamic psd;
298 struct pst_static pst;
300 unsigned long int clock_speed, scclktick;
302 FILE * stream = NULL;
304 stream = popen (
"hostname",
"r");
305 fgets(ligne,256, stream);
308 fgets(ligne,256, stream);
309 size = strlen(ligne);
310 for ( i=0 ; i< size-1; i++) {
311 hostname[i] = ligne[i] ;
313 hostname[size-1] =
'\0';
314 *lenhost = strlen(hostname);
318 stream = popen (
"model",
"r");
319 fgets(ligne,256, stream);
320 size = strlen(ligne);
321 for ( i=0 ; i< size-1; i++) {
322 cputype[i] = ligne[i] ;
325 cputype[size-1] =
'\0';
329#if CPP_mach==CPP_hp11_spmd && CPP_rel != 600|| CPP_mach==CPP_hp11 && CPP_rel != 600
334 }
while (ligne[debut] !=
'/');
338 cpt[j] = ligne[debut];
340 }
while (ligne[debut] !=
'/');
343 sprintf(cmdline,
" grep -i %s /usr/sam/lib/mo/sched.models | awk '{print $3}'",cpt);
344 stream = popen (cmdline,
"r");
345 fgets(ligne,256, stream);
348 cputype[size-1] =
' ';
354 for (i=0;i<sz-1;i++) {
355 cputype[size]=ligne[i];
361 *lencputype = strlen(cputype);
365 pstat_getprocessor(&psp,
sizeof(psp), 1, 0);
366 scclktick=sysconf(_SC_CLK_TCK);
367 clock_speed = psp.psp_iticksperclktick * scclktick;
368 clock_speed = (clock_speed/1000000);
369 *frequence = clock_speed;
372 pstat_getstatic(&pst,
sizeof(pst), (
size_t)1, 0);
373 *memory=pst.physical_memory*pst.page_size/(1024*1024);
376 pstat_getdynamic(&psd,
sizeof(psd), (
size_t)1, 0);
377 *
swap = ((psd.psd_vm*pst.page_size - pst.physical_memory*pst.page_size)>0)?(psd.psd_vm*pst.page_size - pst.physical_memory*pst.page_size)/(1024*1024):0;
384#elif CPP_mach == CPP_pwr4_spmd || CPP_mach ==CPP_pwr4
393void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
396 char ligne[256],swaps[256];
403 FILE * stream = NULL;
405 stream = popen (
"hostname",
"r");
406 fgets(ligne,256, stream);
409 fgets(ligne,256, stream);
410 size = strlen(ligne);
411 for ( i=0 ; i< size-1; i++) {
412 hostname[i] = ligne[i] ;
414 hostname[size-1] =
'\0';
417 *lenhost = strlen(hostname);
419 stream = popen (
"lscfg | grep proc | awk '{print $2}'",
"r");
421 fgets(ligne,256, stream);
422 size = strlen(ligne);
423 for (i=0;i<size-1;i++) cpt[i]=ligne[i];
427 sprintf(cmdline,
"lsattr -El %s | grep frequency | awk '{print $2}'",cpt);
429 stream = popen (cmdline,
"r");
430 fgets(ligne,256, stream);
433 *frequence = atoi(ligne) / 1000000;
437 sprintf(cmdline,
"lsattr -El %s | grep type",cpt);
439 stream = popen (cmdline,
"r");
440 fgets(ligne,256, stream);
446 }
while (ligne[debut]!=
' ');
450 }
while (ligne[debut]==
' ');
454 cputype[i] = ligne[debut] ;
457 }
while (ligne[debut]!=
' ');
461 *lencputype=strlen(cputype);
465 sprintf(cmdline,
"lsattr -El mem0 | awk '{print $2}' ");
466 stream = popen (cmdline,
"r");
467 fgets(ligne,256, stream);
470 *memory = atoi(ligne);
473 sprintf(cmdline,
"lsps -s | awk '{print $1}' ");
474 stream = popen (cmdline,
"r");
475 fgets(ligne,256, stream);
476 fgets(ligne,256, stream);
479 for (i=0;i<strlen(ligne);i++){
480 if (ligne[i]>=
'0' && ligne[i]<=
'9'){
481 swaps[lswaps]=ligne[i];
491#elif CPP_mach==CPP_sun25 || CPP_mach==CPP_sol10x64_spmd
496#include <sys/types.h>
497#include <sys/processor.h>
498#include <sys/systeminfo.h>
500#if CPP_rel == 1000 || CPP_mach==CPP_sol10x64_spmd
506void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
508 processor_info_t infop;
509 char ligne[256],swaps[256];
515 FILE * stream = NULL;
516#if CPP_rel == 1000 || CPP_mach==CPP_sol10x64_spmd
522 stream = popen (
"hostname",
"r");
523 fgets(ligne,256, stream);
526 fgets(ligne,256, stream);
527 size = strlen(ligne);
528 for ( i=0 ; i< size-1; i++) {
529 hostname[i] = ligne[i] ;
531 hostname[size-1] =
'\0';
532 *lenhost = strlen(hostname);
536 processor_info(
proc_id, &infop);
537#if CPP_rel == 1000 || CPP_mach==CPP_sol10x64_spmd
539 ksp = kstat_lookup(kc,
"cpu_info", -1, NULL);
540 kstat_read(kc, ksp, NULL);
541 knp = kstat_data_lookup(ksp,
"brand");
542 sprintf(cputype,
"%s",knp->value);
544 strcpy(cputype,infop.pi_processor_type);
546 *lencputype = strlen(cputype);
548 *frequence = infop.pi_clock;
553*memory = (int)sysconf(_SC_PHYS_PAGES)/1024 * sysconf(_SC_PAGESIZE)/1024;
556 stream = popen(
"swap -s",
"r");
557 fgets(ligne,256, stream);
563 for (i=0;i<strlen(ligne);i++)
565 if (ligne[i]>=
'0' && ligne[i]<=
'9')
567 swaps[lswap]=ligne[i];
583 *
swap = atoi(swaps)/1024;
587#elif CPP_mach==CPP_macosx64
591#include <sys/types.h>
592#include <sys/sysctl.h>
597void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
599 FILE * stream = NULL;
602 char swapstring[256],s1[256],s2[256],s3[256],s4[256];
610 gethostname(hostname,lenh);
611 *lenhost = strlen(hostname);
617 sysctlbyname(
"machdep.cpu.brand_string", cputype, &lenh, NULL, 0);
618 *lencputype = strlen(cputype);
624 sysctlbyname(
"hw.cpufrequency",&freq,&ilen, NULL, 0);
626 *frequence = (int)frq;
632 sysctlbyname(
"hw.physmem",&mem,&ilen, NULL, 0);
633 mem = mem / 1048576 ;
639 stream = popen (
"df -k /",
"r");
640 fgets(swapstring,256, stream);
641 fgets(swapstring,256, stream);
643 sscanf(swapstring,
"%s %s %s %s",s1,s2,s3,s4);
644 *
swap = atoi(s4)/1024;
656void cpuinfo_c(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
658 sprintf(hostname,
"UNKNOWN");
659 *lenhost = strlen(hostname);
660 sprintf(cputype,
"UNKNOWN");
661 *lencputype = strlen(cputype);
673void cpuinfo(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
675 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory,
swap );
678void cpuinfo_(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
680 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory,
swap );
683void cpuinfo__(
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
685 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory,
swap );
688void _FCALL CPUINFO (
char *hostname,
int *lenhost,
char *cputype,
int *lencputype,
int *frequence,
int *memory,
int *
swap )
690 cpuinfo_c(hostname,lenhost, cputype,lencputype, frequence,memory,
swap );
void cpuinfo_(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void _FCALL CPUINFO(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo__(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo_c(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
void cpuinfo(char *hostname, int *lenhost, char *cputype, int *lencputype, int *frequence, int *memory, int *swap)
*fortran !University of Stuttgart All rights reserved Inc All rights reserved ! $COPYRIGHT$ !Additional copyrights may follow ! $HEADER$ !WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING !Do ***not ***copy this file to the directory where your Fortran !fortran application is compiled unless it is absolutely necessary !Most !modern Fortran compilers now support the I command line flag