Skip to content

Commit be4eca9

Browse files
Merge pull request #37 from GralDispersionModel/V2409B6
V2404 Service Release
2 parents 655d1b6 + 693317f commit be4eca9

15 files changed

+1777
-202
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ bld/
2424

2525
# Visual Studio 2015 cache/options directory
2626
.vs/
27+
.vscode/
2728
# Uncomment if you have tasks that create the project's static files in wwwroot
2829
#wwwroot/
2930

src/GRAL.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net8.0</TargetFramework>
6-
<VersionPrefix>23.11.6</VersionPrefix>
6+
<VersionPrefix>24.04.1</VersionPrefix>
77
<Authors>Dietmar Oettl;Markus Kuntner</Authors>
88
<NeutralLanguage>en-US</NeutralLanguage>
99
<AssemblyTitle>GRAL</AssemblyTitle>
10-
<ServerGarbageCollection>true</ServerGarbageCollection>
10+
<ServerGarbageCollection>false</ServerGarbageCollection>
1111
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
1212
<Optimize>true</Optimize>
13-
<TieredCompilation>false</TieredCompilation>
13+
<TieredCompilation>true</TieredCompilation>
1414
<TieredCompilationQuickJit>false</TieredCompilationQuickJit>
1515
<DOTNET_TC_QuickJitForLoops>false</DOTNET_TC_QuickJitForLoops>
1616
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
17-
<TieredPGO>false</TieredPGO>
17+
<TieredPGO>true</TieredPGO>
1818
<DOTNET_EnableDiagnostics>false</DOTNET_EnableDiagnostics>
1919
<DOTNET_ENABLE_PROFILING>false</DOTNET_ENABLE_PROFILING>
2020
<RetainVMGarbageCollection>false</RetainVMGarbageCollection>

src/PrognosticFlowfield.cs

+134-106
Large diffs are not rendered by default.

src/Program.cs

+14-12
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void Main(string[] args)
6666
Console.WriteLine("");
6767
Console.WriteLine("+------------------------------------------------------+");
6868
Console.WriteLine("| |");
69-
string Info = "+ > > G R A L VERSION: 23.11 < < +";
69+
string Info = "+ > > G R A L VERSION: 24.04 < < +";
7070
Console.WriteLine(Info);
7171
if (RunOnUnix)
7272
{
@@ -90,7 +90,6 @@ static void Main(string[] args)
9090
// write zipped files?
9191
ResultFileZipped = false;
9292

93-
int SIMD = CheckSIMD();
9493
LogLevel = CheckCommandLineArguments(args);
9594

9695
//Delete file Problemreport_GRAL.txt
@@ -166,18 +165,21 @@ static void Main(string[] args)
166165

167166
//Reading building data
168167
//case 1: complex terrain
169-
if (Topo == Consts.TerrainAvailable)
170168
{
171-
InitGralTopography(SIMD);
172-
ReaderClass.ReadBuildingsTerrain(Program.CUTK); //define buildings in GRAL
173-
}
174-
//flat terrain application
175-
else
176-
{
177-
InitGralFlat();
178-
ReaderClass.ReadBuildingsFlat(Program.CUTK); //define buildings in GRAL
169+
int SIMD = CheckSIMD();
170+
if (Topo == Consts.TerrainAvailable)
171+
{
172+
InitGralTopography(SIMD);
173+
ReaderClass.ReadBuildingsTerrain(Program.CUTK); //define buildings in GRAL
174+
}
175+
//flat terrain application
176+
else
177+
{
178+
InitGralFlat();
179+
ReaderClass.ReadBuildingsFlat(Program.CUTK); //define buildings in GRAL
180+
}
179181
}
180-
182+
181183
// array declarations for prognostic and diagnostic flow field
182184
if ((FlowFieldLevel > Consts.FlowFieldNoBuildings) || (Topo == Consts.TerrainAvailable))
183185
{

src/ProgramDeclarations.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,11 @@ partial class Program
12561256
///</summary>
12571257
public static VegetationDepoVel VegetationDepoVelFactors = new VegetationDepoVel(1.5F, 3);
12581258

1259+
///<summary>
1260+
/// Use Vector512 class?
1261+
///</summary>
1262+
public static bool UseVector512Class = false;
1263+
12591264
///<summary>
12601265
/// Deposition velocity factor within vegetation areas
12611266
///</summary>

src/ProgramFunctions.cs

+17-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.IO;
1515
using System.Numerics;
1616
using System.Runtime.CompilerServices;
17+
using System.Runtime.Intrinsics;
1718
using System.Threading;
1819
using System.Threading.Tasks;
1920
namespace GRAL_2001
@@ -309,7 +310,16 @@ private static void CalculateBoudaryLayerHeight()
309310
private static int CheckSIMD()
310311
{
311312
int SIMD = Vector<float>.Count;
312-
Console.WriteLine("SIMD - support: " + SIMD.ToString() + " float values IsHardwareAccelerated: " + Vector.IsHardwareAccelerated.ToString());
313+
if (Program.UseVector512Class && Vector512.IsHardwareAccelerated)
314+
{
315+
SIMD = Vector512<float>.Count;
316+
Console.WriteLine("SIMD - support: " + SIMD.ToString() + " float values Using Vector512 extension");
317+
}
318+
else
319+
{
320+
SIMD = Vector<float>.Count;
321+
Console.WriteLine("SIMD - support: " + SIMD.ToString() + " float values IsHardwareAccelerated: " + Vector.IsHardwareAccelerated.ToString());
322+
}
313323
if (Vector.IsHardwareAccelerated == false)
314324
{
315325
string err = "Your system does not support vectors. This results in a very slow flow field calculation. \n Try to use the latest .NetCore framework \n Press a key to continue.";
@@ -451,7 +461,7 @@ private static void CreateLargeArrays()
451461
/// <summary>
452462
/// Init GRAL settings for a calculation in complex terrain
453463
/// </summary>
454-
/// <param name="SIMD">Nukber of float values within a vector</param>
464+
/// <param name="SIMD">Number of float values within a vector</param>
455465
private static void InitGralTopography(int SIMD)
456466
{
457467
//get the minimum and maximum elevation of the GRAMM orography
@@ -1084,9 +1094,9 @@ public void VolumeConcCorrection(float[][][][] Conc, float DeltaH)
10841094
double x0 = i * Program.GralDx;
10851095
double xmax = x0 + Program.GralDx;
10861096

1087-
Span<double> VolumeReduction = stackalloc double[Program.NS];
1088-
Span<float> HMin = stackalloc float[Program.NS];
1089-
Span<float> HMax = stackalloc float[Program.NS];
1097+
Span<double> VolumeReduction = new double[Program.NS];
1098+
Span<float> HMin = new float[Program.NS];
1099+
Span<float> HMax = new float[Program.NS];
10901100

10911101
for (int k = 0; k < HMin.Length; k++)
10921102
{
@@ -1184,8 +1194,8 @@ public void VolumeConcCorrection2(float[][][][] Conc, float DeltaH)
11841194
// loop over all concentration cells
11851195
Parallel.For(0, Program.NXL, Program.pOptions, i =>
11861196
{
1187-
Span<float> HMin = stackalloc float[Program.NS];
1188-
Span<float> HMax = stackalloc float[Program.NS];
1197+
Span<float> HMin = new float[Program.NS];
1198+
Span<float> HMax = new float[Program.NS];
11891199

11901200
for (int k = 0; k < HMin.Length; k++)
11911201
{

src/ReadBuildings.cs

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ private bool ReadBuildingsGrid(float[][] BuildingHeights)
285285

286286
if (block > 0)
287287
{
288+
CalculateSubDomainsForPrognosticWindSimulation();
288289
return true;
289290
}
290291
}

src/ReadInDat.cs

+21-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
using System;
1414
using System.IO;
15+
using System.Runtime.Intrinsics;
1516

1617
namespace GRAL_2001
1718
{
@@ -185,7 +186,7 @@ public void ReadInDat()
185186
if (text.Length > 1 && text[1].Equals("1"))
186187
{
187188
Program.WriteASCiiResults = true;
188-
Console.WriteLine("Write ASCii Results");
189+
Console.WriteLine("Writing ASCii results activated");
189190
}
190191
}
191192
}
@@ -247,6 +248,25 @@ public void ReadInDat()
247248
{ }
248249
}
249250

251+
// Use Vector512 class - Opt Out feature
252+
if (sr.EndOfStream == false)
253+
{
254+
try
255+
{
256+
_line++;
257+
text = sr.ReadLine().Split(new char[] { ' ', ',', '\r', '\n', ';', '!' }, StringSplitOptions.RemoveEmptyEntries);
258+
if (text.Length > 0 && int.TryParse(text[0], System.Globalization.NumberStyles.Any, ic, out int r))
259+
{
260+
if (r == 1 && Vector512.IsHardwareAccelerated)
261+
{
262+
Program.UseVector512Class = true;
263+
}
264+
}
265+
}
266+
catch
267+
{ }
268+
}
269+
250270
}
251271
}
252272
}

src/Transient_Concentration.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace GRAL_2001
1616
{
17-
class TransientConcentration
17+
internal class TransientConcentration
1818
{
1919

2020
/// <summary>
@@ -29,7 +29,7 @@ class TransientConcentration
2929
/// <param name="xsi">Particle x position</param>
3030
/// <param name="eta">Particle y position</param>
3131
/// <param name="SG_nteil">internal source group number of this particle</param>
32-
public void Conz5dZeitschleife(int reflexion_flag, float zcoord_nteil, float AHint, double masse, double Area_cart, float idt, double xsi, double eta, int SG_nteil)
32+
public static void Conz5dZeitschleife(int reflexion_flag, float zcoord_nteil, float AHint, double masse, double Area_cart, float idt, double xsi, double eta, int SG_nteil)
3333
{
3434
if (reflexion_flag == 0)
3535
{
@@ -38,7 +38,7 @@ public void Conz5dZeitschleife(int reflexion_flag, float zcoord_nteil, float AHi
3838
int IndexJ3d = (int)(eta / Program.DYK) + 1;
3939

4040
float[] conz5d_L = Program.Conz5d[IndexI3d][IndexJ3d][IndexK3d];
41-
lock (conz5d_L)
41+
lock (conz5d_L.SyncRoot)
4242
{
4343
conz5d_L[SG_nteil] += (float)(masse * Program.GridVolume * Program.TAUS / (Area_cart * Program.DZK_Trans[IndexK3d]));
4444
}
@@ -57,7 +57,7 @@ public void Conz5dZeitschleife(int reflexion_flag, float zcoord_nteil, float AHi
5757
/// <param name="xsi">Particle x position</param>
5858
/// <param name="eta">Particle y position</param>
5959
/// <param name="SG_nteil">internal source group number of this particle</param>
60-
public void Conz5dZeitschleifeTransient(int reflexion_flag, float zcoord_nteil, float AHint, double mass_real, double Area_cart, float idt, double xsi, double eta, int SG_nteil)
60+
public static void Conz5dZeitschleifeTransient(int reflexion_flag, float zcoord_nteil, float AHint, double mass_real, double Area_cart, float idt, double xsi, double eta, int SG_nteil)
6161
{
6262
if (reflexion_flag == 0)
6363
{
@@ -66,7 +66,7 @@ public void Conz5dZeitschleifeTransient(int reflexion_flag, float zcoord_nteil,
6666
int IndexJ3d = (int)(eta / Program.DYK) + 1;
6767

6868
float[] conz5d_L = Program.Conz5d[IndexI3d][IndexJ3d][IndexK3d];
69-
lock (conz5d_L)
69+
lock (conz5d_L.SyncRoot)
7070
{
7171
conz5d_L[SG_nteil] += (float)(mass_real * Program.TAUS / (Area_cart * Program.DZK_Trans[IndexK3d]));
7272
}

0 commit comments

Comments
 (0)