Skip to content

Commit e50675c

Browse files
committed
Modified console output (now without clearing).
1 parent bb09ff2 commit e50675c

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

TutorialApp/AcceleratorExample.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public class AcceleratorExample : IDisposable
2626
/// disposed.</remarks>
2727
public AcceleratorExample()
2828
{
29-
Console.Clear();
29+
Console.WriteLine("*******************");
30+
Console.WriteLine("* Example started *");
31+
Console.WriteLine("*******************");
3032
Console.WriteLine("Initializing ILGPU context...");
3133
_context = Context.CreateDefault();
3234
Console.WriteLine("Context object obtained");
@@ -38,7 +40,7 @@ public AcceleratorExample()
3840
}
3941

4042
/// <summary>
41-
/// Nothing special. Performs a grid-stride loop operation on a 2D source array, applying a neighborhood-based computation and
43+
/// Does nothing special. Performs a grid-stride loop operation on a 2D source array, applying a neighborhood-based computation and
4244
/// storing the results in a 2D destination array.
4345
/// </summary>
4446
/// <param name="srcArray">The 2D source array of bytes. Each element represents the input data for the computation.</param>
@@ -185,11 +187,11 @@ long PerformGPUWrappedAcceleratorPatternTest()
185187

186188
Console.WriteLine("GPUWrappedAccelerator pattern test started...");
187189
long gpuWrappedAcceleratorPatternTime = PerformGPUWrappedAcceleratorPatternTest();
188-
Console.WriteLine($" Execution took {gpuWrappedAcceleratorPatternTime} ms.");
190+
Console.WriteLine($" Load kernel calls took {gpuWrappedAcceleratorPatternTime} ms.");
189191

190192
Console.WriteLine("Classical pattern test started...");
191193
long classicalPatternTime = PerformClassicalPatternTest();
192-
Console.WriteLine($" Execution took {classicalPatternTime} ms.");
194+
Console.WriteLine($" Load kernel calls took {classicalPatternTime} ms.");
193195

194196
double ratio = Math.Round(classicalPatternTime >= gpuWrappedAcceleratorPatternTime ?
195197
(double)classicalPatternTime / (double)gpuWrappedAcceleratorPatternTime
@@ -200,10 +202,6 @@ long PerformGPUWrappedAcceleratorPatternTest()
200202
string result = classicalPatternTime >= gpuWrappedAcceleratorPatternTime ? "faster" : "slower";
201203
Console.WriteLine($"Using the GPUWrappedAccelerator pattern to load kernel is about {ratio} times {result} than when using Classical pattern.");
202204

203-
Console.WriteLine();
204-
Console.WriteLine();
205-
Console.WriteLine("Press any key to exit...");
206-
Console.ReadKey();
207205
return;
208206
}
209207

@@ -222,7 +220,6 @@ private void Dispose(bool disposing)
222220
_isDisposed = true;
223221
if (disposing)
224222
{
225-
Console.WriteLine("Disposing ILGPU context...");
226223
_context.Dispose();
227224
}
228225
}

TutorialApp/AllocatorExample.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public class AllocatorExample
3636
/// GPUs on host machine (for information only).</remarks>
3737
public AllocatorExample()
3838
{
39-
Console.Clear();
39+
Console.WriteLine("*******************");
40+
Console.WriteLine("* Example started *");
41+
Console.WriteLine("*******************");
4042
Random rand = new();
4143
int height = 600;
4244
int width = 800;
@@ -261,10 +263,6 @@ public void Run()
261263
// Execute the parallel sequence
262264
_ = ExecuteParallelSequence();
263265

264-
Console.WriteLine();
265-
Console.WriteLine();
266-
Console.WriteLine("Press any key to exit...");
267-
Console.ReadKey();
268266
return;
269267
}
270268

TutorialApp/AllocatorNDStreamExample.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public class AllocatorNDStreamExample
3737
/// GPUs on host machine (for information only).</remarks>
3838
public AllocatorNDStreamExample()
3939
{
40-
Console.Clear();
40+
Console.WriteLine("*******************");
41+
Console.WriteLine("* Example started *");
42+
Console.WriteLine("*******************");
4143
Random rand = new();
4244
int height = 600;
4345
int width = 800;
@@ -268,10 +270,6 @@ public void Run()
268270
// Execute the parallel sequence
269271
_ = ExecuteParallelSequence();
270272

271-
Console.WriteLine();
272-
Console.WriteLine();
273-
Console.WriteLine("Press any key to exit...");
274-
Console.ReadKey();
275273
return;
276274
}
277275

TutorialApp/Program.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,19 @@
77
bool exit = false;
88
while (!exit)
99
{
10-
Console.WriteLine("Menu");
10+
Console.WriteLine();
11+
Console.WriteLine();
12+
Console.WriteLine();
13+
Console.WriteLine("Main menu");
14+
Console.WriteLine("---------");
1115
Console.WriteLine($"1. {nameof(GPUWrappedAccelerator)} used as a standalone component");
1216
Console.WriteLine($"2. {nameof(GPUAllocator)} singleton scenario");
1317
Console.WriteLine($"3. {nameof(GPUStreamPool)} usage of non-default GPU streams");
1418
Console.WriteLine("4. Exit");
15-
Console.WriteLine("Press your choice...");
19+
Console.WriteLine("Select your choice (press key 1, 2, 3 or 4)...");
1620
ConsoleKeyInfo keyInfo = Console.ReadKey();
21+
Console.WriteLine();
22+
Console.WriteLine();
1723
switch (keyInfo.KeyChar)
1824
{
1925
case '1':
@@ -39,7 +45,14 @@
3945
exit = true;
4046
break;
4147
default:
48+
Console.WriteLine("Unsupported choice.");
4249
break;
4350
}
44-
Console.Clear();
51+
Console.WriteLine();
52+
Console.WriteLine();
53+
if (!exit)
54+
{
55+
Console.WriteLine("Press any key to return to main menu...");
56+
Console.ReadKey();
57+
}
4558
}

0 commit comments

Comments
 (0)