Skip to content

Commit

Permalink
Re #944 port newly modified changes from rel 3.6.3 to horace 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Feb 13, 2023
1 parent d7e7d48 commit 5efc902
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 64 deletions.
40 changes: 16 additions & 24 deletions herbert_core/admin/@opt_config_manager/private/find_comp_type_.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [pc_type,nproc,mem_size] = find_comp_type_(obj)
function [pc_type,nproc,phys_mem] = find_comp_type_(obj)
% find pc type as function of the pc properties, like memory size number of
% processors, etc.
%
Expand All @@ -10,17 +10,19 @@

types = obj.known_pc_types_;
Gb = 1024*1024*1024;
nproc = 1;

[phys_mem,free_mem] = horace_memory();
if isempty(phys_mem) % assume something small
phys_mem = 16*Gb;
free_mem = 16*Gb;
end
nproc = idivide(int64(phys_mem),int64(obj.mem_size_per_worker_*Gb),'floor');
if ispc
[~,sys] = memory();
mem_size = sys.PhysicalMemory.Total;
if mem_size < 32*Gb
if phys_mem < 32*Gb
pc_type = types{1}; %windows small
else
if sys.PhysicalMemory.Available >= 0.5*sys.PhysicalMemory.Total
nproc = idivide(int64(mem_size),int64(obj.mem_size_per_worker_*Gb),'floor');
if nproc >1
if free_mem >= 0.5*phys_mem
if nproc >2
pc_type = types{2}; %windows large
else
pc_type = types{1}; %windows small
Expand All @@ -33,14 +35,6 @@
pc_type = types{8}; % 'jenkins_win'
end
elseif isunix

[nok,mem_string] = system('free | grep Mem');
if nok
mem_size = 16*Gb;
else
mem_size = parse_mem_string(mem_string);
end

if ismac %MAC
pc_type = types{3};
return;
Expand All @@ -50,14 +44,16 @@
pc_type = types{3};
return;
end

rez=strfind(mess,'NUMA node');
% if lscpu returns more then one numa node strigs, first string defines
% the number of numa nodes and all subsequent strings describe each
% node. So, if there are more then 2 string, its more then one numa
% node and we consider this computer to be an hpc system.
if numel(rez)>2; hpc_computer = true;
else; hpc_computer = false;
if numel(rez)>2 || nproc>4
hpc_computer = true;
else
hpc_computer = false;
end
[is_virtual,type] = is_idaaas();
if is_virtual
Expand All @@ -69,7 +65,7 @@
else
n_profile = 4; % normal unix machine
end

if hpc_computer
n_profile=n_profile+1;
end
Expand All @@ -81,7 +77,3 @@
end
end


function mem_size = parse_mem_string(mem_string)
cont = regexp(mem_string,'\s+','split');
mem_size = sscanf(cont{2},'%d');
28 changes: 28 additions & 0 deletions herbert_core/utilities/misc/horace_memory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function [phys_memory,free_memory]=horace_memory()
%HORACE_MEMORY Simple system-indepentent utility used by Horace to identify
% its type for proper auto-configuration
%
% Returns:
% phys_memory -- physical memory installed on the computer
% free_memory -- free memory available for utilites.
% Returns these parameters empty if the memory
% identification does not work.

if ispc
[~,sys] = memory();
phys_memory = sys.PhysicalMemory.Total;
free_memory = sys.PhysicalMemory.Available;
elseif isunix
[nok,mem_string] = system('free | grep Mem');
if nok
phys_memory = [];
free_memory = [];
else
[phys_memory,free_memory] = parse_mem_string(mem_string);
end
end

function [phys_memory,free_memory] = parse_mem_string(mem_string)
cont = regexp(mem_string,'\s+','split');
phys_memory = 1024*sscanf(cont{2},'%d');
free_memory = 1024*sscanf(cont{4},'%d');
40 changes: 0 additions & 40 deletions horace_core/horace_memory.m

This file was deleted.

0 comments on commit 5efc902

Please sign in to comment.