Skip to content

Commit

Permalink
SPMD uv
Browse files Browse the repository at this point in the history
  • Loading branch information
GHilmarG committed Jan 5, 2024
1 parent 1f85481 commit 36d0576
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions TestParallelAssemblyOptions.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@


% n=200 ; A = sprandsym(n,.1,0.1); x=ones(n,1) ;


% delete(gcp('nocreate')); parpool('Processes',8)

% delete(gcp('nocreate')); parpool('Threads',8)
Expand Down
1 change: 1 addition & 0 deletions Ua2D_DefaultParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
%% Types of run
%


CtrlVar.UaRunType="" ; % "-uvh-" , "-uv-h-" , "-uv-" , "-h-" ;


Expand Down
8 changes: 5 additions & 3 deletions uvMatrixAssembly.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@

[Ruv,Kuv,Tint,Fext,MUAworkers]=uvMatrixAssemblySSTREAM_SPMD(CtrlVar,MUA,F,MUAworkers);

else
else % this is the otherwise default sequencial assembly

[Ruv,Kuv,Tint,Fext]=uvMatrixAssemblySSTREAM(CtrlVar,MUA,F) ;

end

if CtrlVar.Parallel.isTest

% MUAworkers=[];


% There might be an argument for doing this a few times, but if one does a number of NR iterations, which generally is the
% case, then that should not be needed.
tSeq=tic ; [Ruv,Kuv,Tint,Fext]=uvMatrixAssemblySSTREAM(CtrlVar,MUA,F); tSeq=toc(tSeq) ;
% tSeq2=tic ; [Ruv,Kuv,Tint,Fext]=uvMatrixAssemblySSTREAM(CtrlVar,MUA,F); tSeq2=toc(tSeq2) ; [tSeq tSeq2]


if CtrlVar.Parallel.uvAssembly.spmd.isOn
MUAworkers=[];
Expand Down
17 changes: 12 additions & 5 deletions uvMatrixAssemblySSTREAM_SPMD.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

nW=CtrlVar.Parallel.uvAssembly.spmd.nWorkers;

Partition=cell(nW,1);





%% create element lists for each partition
% Use round to make sure that there are exactly nW partitions
% and ensure that all elements are included.
tPartition=tic;
Partition=cell(nW,1);
N=round(MUA.Nele/nW) ; i1=1 ; i2=N;
for iWorker=1:(nW-1)
Partition{iWorker}=i1:i2 ;
Expand All @@ -26,11 +29,12 @@

i2=MUA.Nele;
Partition{nW}=i1:i2 ;
tPartition=toc(tPartition);
%


% outside of spmd M is composite
% inside of spmd M is struct
% inside of spmd M is struct on each worker

MUA.dM=[] ;

Expand Down Expand Up @@ -75,17 +79,20 @@
rrsum = spmdPlus(rr,1);
kksum = spmdPlus(kk,1);
end
% rrsum and kksum are composites
% Ruv and Kuv are double sparse
Ruv=rrsum{1}; Kuv=kksum{1};

tSum=toc(tSum) ;


Ruv=rrsum{1};
Kuv=kksum{1};


Tint=[] ; Fext=[];


if CtrlVar.Parallel.isTest
fprintf("uvMatrixAssemblySSTREAM_SPMD: Building arrays on workers %f sec. \t SPMD Assembly %f sec. \t Summing up results from workers %f sec. \n",tBuild,tAssembly,tSum)
fprintf("uvMatrixAssemblySSTREAM_SPMD: Creating partition arrays %f sec. \t Building arrays on workers %f sec. \t SPMD Assembly %f sec. \t Summing up results from workers %f sec. \n",tPartition,tBuild,tAssembly,tSum)
end


Expand Down

0 comments on commit 36d0576

Please sign in to comment.