Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spmd test for uvh assembly. Looking good.
- Loading branch information
Showing
6 changed files
with
1,072 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,93 @@ | ||
load PlotFile | ||
|
||
%% | ||
clc | ||
load TestSaveuvhAssembly | ||
|
||
tic | ||
[K,R,T,F]=KRTF(s,S,B,h,u,v,AGlen,n,C,m,coordinates,connectivity,Boundary,nip,alpha,rho,rhow,g,CtrlVar); | ||
|
||
for Iint=1:MUA.nip | ||
|
||
|
||
[Tx1,Fx1,Ty1,Fy1,Th1,Fh1,Kxu1,Kxv1,Kyu1,Kyv1,Kxh1,Kyh1,Khu1,Khv1,Khh1]=... | ||
uvhAssemblyIntPointImplicitSUPG(Iint,ndim,MUA,... | ||
bnod,hnod,unod,vnod,AGlennod,nnod,Cnod,mnod,h0nod,u0nod,v0nod,as0nod,ab0nod,as1nod,ab1nod,dadhnod,Bnod,Snod,rhonod,... | ||
uonod,vonod,Conod,monod,uanod,vanod,Canod,manod,... | ||
CtrlVar,rhow,g,Ronly,ca,sa,dt,... | ||
Tx0,Fx0,Ty0,Fy0,Th0,Fh0,Kxu0,Kxv0,Kyu0,Kyv0,Kxh0,Kyh0,Khu0,Khv0,Khh0); | ||
|
||
Tx=Tx+Tx1; Fx=Fx+Fx1; | ||
Ty=Ty+Ty1; Fy=Fy+Fy1; | ||
Th=Th+Th1; Fh=Fh+Fh1; | ||
|
||
Kxu=Kxu+Kxu1; Kxv=Kxv+Kxv1; | ||
Kyu=Kyu+Kyu1; Kyv=Kyv+Kyv1; | ||
Kxh=Kxh+Kxh1; Kyh=Kyh+Kyh1; | ||
Khu=Khu+Khu1; Khv=Khv+Khv1; Khh=Khh+Khh1; | ||
|
||
end | ||
toc | ||
|
||
|
||
Nnodes=max(connectivity(:)); [Nele,nod]=size(connectivity); | ||
tic | ||
|
||
parfor Iint=1:MUA.nip | ||
|
||
|
||
[Tx1,Fx1,Ty1,Fy1,Th1,Fh1,Kxu1,Kxv1,Kyu1,Kyv1,Kxh1,Kyh1,Khu1,Khv1,Khh1]=... | ||
uvhAssemblyIntPointImplicitSUPG(Iint,ndim,MUA,... | ||
bnod,hnod,unod,vnod,AGlennod,nnod,Cnod,mnod,h0nod,u0nod,v0nod,as0nod,ab0nod,as1nod,ab1nod,dadhnod,Bnod,Snod,rhonod,... | ||
uonod,vonod,Conod,monod,uanod,vanod,Canod,manod,... | ||
CtrlVar,rhow,g,Ronly,ca,sa,dt,... | ||
Tx0,Fx0,Ty0,Fy0,Th0,Fh0,Kxu0,Kxv0,Kyu0,Kyv0,Kxh0,Kyh0,Khu0,Khv0,Khh0); | ||
|
||
Tx=Tx+Tx1; Fx=Fx+Fx1; | ||
Ty=Ty+Ty1; Fy=Fy+Fy1; | ||
Th=Th+Th1; Fh=Fh+Fh1; | ||
|
||
Kxu=Kxu+Kxu1; Kxv=Kxv+Kxv1; | ||
Kyu=Kyu+Kyu1; Kyv=Kyv+Kyv1; | ||
Kxh=Kxh+Kxh1; Kyh=Kyh+Kyh1; | ||
Khu=Khu+Khu1; Khv=Khv+Khv1; Khh=Khh+Khh1; | ||
|
||
end | ||
toc | ||
|
||
|
||
FEmesh.Coordinates=coordinates; | ||
FEmesh.Connectivity=connectivity; | ||
FEmesh.Boundary=Boundary; | ||
FEmesh.Nnodes=Nnodes; | ||
FEmesh.Nele=Nele; | ||
FEmesh.Nod=nod; | ||
FEmesh.Nip=nip; | ||
%% | ||
N=10000; | ||
A=rand(N,N); | ||
B=rand(N,N); | ||
|
||
%% | ||
clc | ||
tic | ||
parfor Iint=1:nip; | ||
[Ktest{Iint},R,T,F]=KRTFparInt(Iint,s,S,B,h,u,v,AGlen,n,C,m,FEmesh,alpha,rho,rhow,g,CtrlVar); | ||
end | ||
AA=distributed(A); | ||
BB=distributed(B); | ||
toc | ||
|
||
tic | ||
C=TestAddM(A,B); | ||
t=toc; | ||
trace(C) | ||
|
||
tic | ||
|
||
CC=TestAddM(AA,BB); | ||
|
||
tspmd=toc; | ||
trace(CC) | ||
|
||
fprintf('t=%f \t tspmd=%f \n',t,tspmd) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
delete(gcp('nocreate')) | ||
poolobj=parpool('local',6); | ||
|
||
%% | ||
poolobj = gcp('nocreate'); | ||
|
||
|
||
%clc | ||
fprintf('\n\n\n\n') | ||
%load uvhAssembly.mat | ||
load TestSaveuvhAssembly | ||
|
||
|
||
|
||
CtrlVar.Parallel.uvhAssembly.parfor=0; | ||
tic | ||
[UserVar,RunInfo,R,K,Tint,Fext]=uvhAssembly(UserVar,RunInfo,CtrlVar,MUA,F0,F1,ZeroFields); | ||
toc | ||
fprintf(' sum(R)=%g \t trace(K)=%g \n',full(sum(R)),full(trace(K))) | ||
|
||
% The spmd option has potential | ||
|
||
CtrlVar.NumWorkers=poolobj.NumWorkers; | ||
fprintf(' Number of workers=%i \n ',CtrlVar.NumWorkers) | ||
tic | ||
[UserVar,RunInfo,R,K,Tint,Fext]=uvhAssemblySPMD(UserVar,RunInfo,CtrlVar,MUA,F0,F1,ZeroFields); | ||
toc | ||
fprintf(' sum(R)=%g \t trace(K)=%g \n',full(sum(R)),full(trace(K))) | ||
|
||
%% The parfor option is not good and apparantly always slower | ||
|
||
|
||
nW=poolobj.NumWorkers; | ||
N=ceil(MUA.Nele/nW) ; | ||
|
||
i1=1 ; i2=N; | ||
|
||
for I=1:nW | ||
|
||
Partition{I}=[i1:i2] ; | ||
i1=i2+1 ; | ||
i2=min([i2+N,MUA.Nele]); | ||
end | ||
|
||
% using parfor | ||
neq=3*MUA.Nnodes; | ||
R=sparseUA(neq,1); | ||
K=sparseUA(neq,neq); | ||
|
||
tic | ||
parfor iWorker=1:numel(Partition) | ||
|
||
M{iWorker}=MUA; | ||
M{iWorker}.connectivity=MUA.connectivity(Partition{iWorker},:); | ||
M{iWorker}.Nele=numel(Partition{iWorker}); | ||
M{iWorker}.Deriv=MUA.Deriv(Partition{iWorker},:,:,:); | ||
M{iWorker}.DetJ=MUA.DetJ(Partition{iWorker},:); | ||
[~,~,r,k,Tint,Fext]=uvhAssembly(UserVar,RunInfo,CtrlVar,M{iWorker},F0,F1,ZeroFields); | ||
R=R+r ; | ||
K=K+k; | ||
|
||
end | ||
toc | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.