Skip to content

Commit

Permalink
Merge pull request #29 from gnudatalanguage/master
Browse files Browse the repository at this point in the history
align
  • Loading branch information
GillesDuvert authored Oct 25, 2018
2 parents f6b1d6e + 8d1fcb3 commit ce67e88
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 42 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ endif(READLINE_FOUND)
# -DEDITLINEDIR=DIR
if(EDITLINE)
set(CMAKE_PREFIX_PATH ${EDITLINEDIR})
find_package(Editline QUIET)
find_package(Editline CONFIG)
if(NOT EDITLINE_FOUND)
find_package(Editline QUIET)
endif(NOT EDITLINE_FOUND)
set(HAVE_LIBEDITLINE ${EDITLINE_FOUND})
if(EDITLINE_FOUND)
if(NOT WIN32)
Expand Down
49 changes: 49 additions & 0 deletions src/pro/utilities/read_ascii_basic.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
;
; Under GNU GPL V3+
; Alain C., October 2018
;
; Frequently, we just want to copy in a STRING Array all the lines
; of an ACSII file ...
;
function READ_ASCII_BASIC, filename, $
test=test, verbose=verbose, help=help
;
if (KEYWORD_SET(help) or (N_PARAMS() NE 1)) then begin
print, 'function READ_ASCII_BASIC, filename, $'
print, ' test=test, verbose=verbose, help=help'
return, ''
endif
;
ON_ERROR, 2
;
if N_ELEMENTS(filename) GT 1 then MESSAGE, 'Only one file at once !'
if ~FILE_TEST(filename) then MESSAGE, 'Missing file >>'+filename+'<<'
if FILE_TEST(filename, /zero) then $
MESSAGE, 'File >>'+filename+'<< does exist but has zero-length'
;
txt=''
restxt=''
;
GET_LUN, lun
OPENR, lun, filename
;
while ~EOF(lun) do begin
READF, lun, txt
;;print, txt
restxt=[restxt,txt]
endwhile
;
CLOSE, lun
FREE_LUN, lun
;
if N_ELEMENTS(restxt) GT 1 then restxt=restxt[1:*]
if KEYWORD_SET(verbose) then begin
print, 'File : ', filename, ' read with ', N_ELEMENTS(restxt), ' lines.'
endif
;
if KEYWORD_SET(test) then STOP
;
return, restxt
;
end
;
99 changes: 84 additions & 15 deletions testsuite/benchmark/basic_benchmarks.pro
Original file line number Diff line number Diff line change
@@ -1,22 +1,91 @@

pro printb, str, flt, tab_name, tab_val
;
; Under GNU GPL V3+
; Alain C., summer 2018
;
; Basic benchmarks, easy to extend ...
; In the future, maybe the pure numerical part (COS, SIN, SQRT, EXP,
; ...) can be separeted for
; more high level functionnalities (WHERE, SORT, FINITE, ...)
;
; Please not that from now, RANDOMU in GDL is related to the GSL
;
; ---------------------------------
;
; Modifications history :
;
; - 2018-10-15 : AC.
; * forcing !cpu.TPOOL_NTHREADS to be equal to
; physical (detected !) core number !cpu.HW_NCPU
; * ading more informations on the machine used in the output XDR
; (to be used by "PLOT_BASIC_BENCHMARKS"
;
; ---------------------------------
;
; just a convenience code for smart print ...
pro PRINTB, str, flt, tab_name, tab_val
vide=' '
print, format='(A20, f7.2)', str+vide, flt
;
tmp=STRMID(STRMID(str,9),STRLEN(str), STRLEN(str)-9-2, /REV)
tab_name=[tab_name, tmp]
tab_val=[tab_val, flt]
end

pro basic_benchmarks, nbps=nbps, double=double, test=test, prefix=prefix
pro PRINT_CPUINFO, message
txt1=': nb detected CORES : '+STRING(!cpu.HW_NCPU, format='(i4)')
txt2=', nb cores/threads in use : '+STRING(!cpu.TPOOL_NTHREADS, format='(i4)')
print, message, txt1, txt2
end
;
; ---------------------------------
;
pro BASIC_BENCHMARKS, nbps=nbps, double=double, type=type, $
force_max_cpu=force_max_cpu, set_cpu_nb=set_cpu_nb, $
prefix=prefix, $
help=help, verbose=verbose, test=test
;
if KEYWORD_SET(help) then begin
print, 'pro basic_benchmarks, nbps=nbps, double=double, type=type, $'
print, ' prefix=prefix, force_max_cpu=force_max_cpu, $'
print, ' help=help, verbose=verbose, test=test'
return
endif
;
; Checking status for CPU: sometimes, in GDL, due to load balancing in
; Eigen3 as studied by Nodar, not all threads are activated by default
; Bench on a machine with other load is not a good idea !!!
PRINT_CPUINFO, 'Initial'
;
if ~KEYWORD_SET(force_max_cpu) then begin
if (!cpu.TPOOL_NTHREADS LT !cpu.HW_NCPU) then $
MESSAGE, /continue, 'Please consider /force_max_cpu'
endif else begin
CPU, TPOOL_NTHREADS=!cpu.HW_NCPU
PRINT_CPUINFO, 'Updated'
endelse
;
if KEYWORD_SET(set_cpu_nb) then begin
CPU, TPOOL_NTHREADS=set_cpu_nb
PRINT_CPUINFO, 'Set'
endif
;
if ~KEYWORD_SET(nbps) then nbps=1e8
tab_name=['']
tab_val=[0.]
;
; ------------ need to chnage the type if needed ---
;
a=TIC()
input=RANDOMU(1, nbps, double=double)
printb, 'Time for RANDOMU : ', TOC(a), tab_name, tab_val
b=TOC(a)
;
; do we want to convert the type ?
if KEYWORD_SET(type) then input=FIX(input, type=type)
used_type=TYPENAME(input)
print, 'Working on type : ', used_type
;
; ------------ starting other computation ! ----
;
printb, 'Time for RANDOMU : ', b, tab_name, tab_val
;
a=TIC() & res=COS(input)
printb, 'Time for COS : ', TOC(a), tab_name, tab_val
Expand All @@ -36,12 +105,10 @@ printb, 'Time for SQRT : ', TOC(a), tab_name, tab_val
a=TIC() & res=EXP(input)
printb, 'Time for EXP : ', TOC(a), tab_name, tab_val
;
val=input GT 0.5
a=TIC() & res=WHERE(val)
a=TIC() & res=WHERE(input GT 0.5)
printb, 'Time for WHERE : ', TOC(a), tab_name, tab_val
;
sub=input[0:nbps/30]
a=TIC() & res=SORT(sub)
a=TIC() & res=SORT(input[0:nbps/30])
printb, 'Time for SORT (1/30) : ', TOC(a), tab_name, tab_val
;
a=TIC() & res=FINITE(input)
Expand All @@ -53,16 +120,18 @@ printb, 'Time for FIX : ', TOC(a), tab_name, tab_val
; save file ...
;
if ~KEYWORD_SET(prefix) then prefix=''
filename=BENCHMARK_GENERATE_FILENAME('basic_bench'+prefix)
cpuinfo=BENCHMARK_GENERATE_CPUINFO()
DEFSYSV, '!GDL', exist=exist
if exist then version=!gdl.release else version=!version.release
filename=BENCHMARK_GENERATE_FILENAME('basic'+prefix)
;
info_cpu=BENCHMARK_INFO_CPU()
info_os=BENCHMARK_INFO_OS()
info_soft=BENCHMARK_INFO_SOFT()
;
op_name=tab_name[1:*]
op_val=tab_val[1:*]
;
SAVE, file=filename, nbps, op_name, op_val, cpuinfo, version
print, 'writing file : ', filename
SAVE, file=filename, nbps, used_type, op_name, op_val, $
info_cpu, info_os, info_soft
print, 'Writing file : ', filename
;
if KEYWORD_SET(test) then stop
;
Expand Down
3 changes: 1 addition & 2 deletions testsuite/benchmark/benchmark_generate_cpuinfo.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
; -- bogomips <<-- does not exist on OSX
; -- cpu MHz
;


function BENCHMARK_GENERATE_CPUINFO, test=test, verbose=verbose, help=help
;
if KEYWORD_SET(help) then begin
Expand Down Expand Up @@ -48,6 +46,7 @@ endif
cpu_info={MHz : resu_Mhz, $
Bogo : resu_bogo, $
model : model_name, $
used_cores : !cpu.TPOOL_NTHREADS, $
nb_cores : !cpu.HW_NCPU} ; not fully clear ...
;
if KEYWORD_SET(verbose) then HELP,/struct, cpu_info
Expand Down
2 changes: 0 additions & 2 deletions testsuite/benchmark/benchmark_generate_filename.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ endif else begin
endelse
SPAWN, commande_date, result, status
;
name=result
;
machine=GET_LOGIN_INFO()
;
name=machine.machine_name+'_'+result
Expand Down
60 changes: 60 additions & 0 deletions testsuite/benchmark/benchmark_info_cpu.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;
; AC, July 2017, GPL V3+
;
; Collecting informations on the CPU
; -- processor name
; -- cores number <<-- tricks on OSX due to OpenMP
; -- bogomips <<-- does not exist on OSX
; -- cpu MHz
;
; Help welcome (MSwin ... BSD ...)
;
function BENCHMARK_INFO_CPU, test=test, verbose=verbose, help=help
;
if KEYWORD_SET(help) then begin
print, 'function BENCHMARK_INFO_CPU, test=test, verbose=verbose, help=help'
return, -1
endif
;
os_name=STRLOWCASE(!version.os)
;
if (os_name EQ 'linux') then begin
;;
SPAWN, 'more /proc/cpuinfo | grep MHz', resu_Mhz
resu_mhz=STRMID(resu_Mhz[0], STRPOS(resu_Mhz[0],':')+2)
resu_mhz=FLOAT(resu_mhz)
;;
SPAWN, 'more /proc/cpuinfo | grep bogo', resu_bogo
resu_bogo=STRMID(resu_bogo[0], STRPOS(resu_bogo[0],':')+2)
resu_bogo=FLOAT(resu_bogo)
;;
SPAWN, 'more /proc/cpuinfo | grep "model name"', model_name
model_name=STRMID(model_name[0], STRPOS(model_name[0],':')+2)
;;
endif
;
if (os_name EQ 'darwin') then begin
;;
SPAWN, 'sysctl -n hw.cpufrequency', resu_Hz
resu_Mhz=resu_Hz/1.e6
;;
;; no known equivalent of BogoMIPS on OSX :(
resu_bogo=-1
;;
SPAWN, 'sysctl -n machdep.cpu.brand_string', model_name
;;
endif
;
info_cpu={MHz : resu_Mhz, $
Bogo : resu_bogo, $
model : model_name, $
used_cores : !cpu.tpool_nthreads, $
nb_cores : !cpu.hw_ncpu} ; not fully clear ...
;
if KEYWORD_SET(verbose) then HELP,/struct, info_cpu
if KEYWORD_SET(test) then STOP
;
return, info_cpu
;
end
;
75 changes: 75 additions & 0 deletions testsuite/benchmark/benchmark_info_os.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
;
; AC, Octobre 201_, GPL V3+
;
; Collecting informations on the Machine
; -- hostname
; -- detailed info on the OS
;
; Help welcome (MSwin ... BSD ...)
;
; ----------------------------------------
;
function BENCHMARK_INFO_OS, test=test, verbose=verbose, help=help
;
if KEYWORD_SET(help) then begin
print, 'function BENCHMARK_INFO_OS, test=test, verbose=verbose, help=help'
return, -1
endif
;
info_os={hostname :'', $
generic_osname : 'TBD', $
family_osname : 'TBD', $
accurate_osname : 'TBD'}
;
machine=GET_LOGIN_INFO()
info_os.hostname=machine.machine_name
;
os_name=STRLOWCASE(!version.os)
;
if (os_name EQ 'linux') then begin
;;
info_os.generic_osname='Linux'
;;
txt='' & restxt=''
filename='/etc/os-release'
if FILE_TEST(filename) then begin
txt=READ_ASCII_BASIC(filename)
endif else begin
MESSAGE, /continue, 'missing file : '+filename
MESSAGE, /continue, 'no Linux OS specific info collected'
endelse
;;
ok=WHERE(STRPOS(txt,'NAME=') EQ 0, nbp_ok)
if (nbp_ok GE 1) then begin
tmp=txt[ok]
tmp=strmid(tmp, STRLEN('NAME='))
info_os.family_osname=STRJOIN(STRSPLIT(tmp,'"', /EXTRACT),'')
endif else info_os.family_osname=os_name+' (unknown)'
;;
ok=WHERE(STRPOS(txt,'VERSION=') GE 0, nbp_ok)
if (nbp_ok GE 1) then begin
tmp=txt[ok]
tmp=strmid(tmp, STRLEN('VERSION='))
info_os.accurate_osname=STRJOIN(STRSPLIT(tmp,'"', /EXTRACT),'')
endif else info_os.accurate_osname=os_name+' (unknown)'
;;
endif
;
if (os_name EQ 'darwin') then begin
;;
info_os.generic_osname='OSX'
;;
SPAWN, 'sw_vers', txt
tmp=txt[1]
tmp=strmid(tmp, STRLEN('ProductVersion:'))
info_os.accurate_osname=tmp
;;
endif
;
if KEYWORD_SET(verbose) then HELP,/struct, info_os
if KEYWORD_SET(test) then STOP
;
return, info_os
;
end
;
28 changes: 28 additions & 0 deletions testsuite/benchmark/benchmark_info_soft.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
;
; AC, October 21, 2018, GPL V3+
;
; Collecting informations on the interpreter version (GDL or IDL or FL)
; -- soft
; -- version
;
function BENCHMARK_INFO_SOFT, test=test, verbose=verbose, help=help
;
if KEYWORD_SET(help) then begin
print, 'function BENCHMARK_INFO_SOFT, test=test, verbose=verbose, help=help'
return, -1
endif
;
info_soft={name : '', release : ''}
info_soft.name=GDL_IDL_FL()
;
if info_soft.name EQ 'GDL' then version=!gdl.release
if info_soft.name EQ 'IDL' then version=!version.release
if info_soft.name EQ 'FL' then version='Unknown'
;
if KEYWORD_SET(verbose) then HELP,/struct, info_soft
if KEYWORD_SET(test) then STOP
;
return, info_soft
;
end
;
Loading

0 comments on commit ce67e88

Please sign in to comment.