Commit 42f39ea7 authored by BORNON Théophile's avatar BORNON Théophile

possibility to add a max thread arguement

parent 1825f502
...@@ -30,7 +30,6 @@ namespace S04_Projet ...@@ -30,7 +30,6 @@ namespace S04_Projet
private short[,] filter; private short[,] filter;
private double factor; private double factor;
private int size; private int size;
//private double stepSize;
private Operation ToDo; private Operation ToDo;
#endregion #endregion
...@@ -62,7 +61,7 @@ namespace S04_Projet ...@@ -62,7 +61,7 @@ namespace S04_Projet
nbPixel = opt.width * opt.height; nbPixel = opt.width * opt.height;
size = filter.GetLength(0); size = filter.GetLength(0);
if (Program.MULTITHREADING) if (Program.MULTITHREADING)
nbProcessors = Math.Min(Environment.ProcessorCount, 8); nbProcessors = Program.MAX_THREADS;
else else
nbProcessors = 1; nbProcessors = 1;
} }
...@@ -137,7 +136,6 @@ namespace S04_Projet ...@@ -137,7 +136,6 @@ namespace S04_Projet
NewGMatrix = new byte[nbPixel]; NewGMatrix = new byte[nbPixel];
NewBMatrix = new byte[nbPixel]; NewBMatrix = new byte[nbPixel];
//stepSize = (Math.E - 1) / nbProcessors;
Thread[] threads = new Thread[nbProcessors]; Thread[] threads = new Thread[nbProcessors];
Console.WriteLine("Creating {0} thread(s)", nbProcessors); Console.WriteLine("Creating {0} thread(s)", nbProcessors);
...@@ -145,7 +143,6 @@ namespace S04_Projet ...@@ -145,7 +143,6 @@ namespace S04_Projet
for (int i = 0; i < nbProcessors; i++) for (int i = 0; i < nbProcessors; i++)
{ {
threads[i] = new Thread(new ParameterizedThreadStart(ApplyFilterTask)); threads[i] = new Thread(new ParameterizedThreadStart(ApplyFilterTask));
//double param = 1 + i * stepSize;
threads[i].Start(i); threads[i].Start(i);
} }
......
...@@ -8,6 +8,7 @@ namespace S04_Projet ...@@ -8,6 +8,7 @@ namespace S04_Projet
{ {
//public static bool MULTITHREADING_LOAD = false; //public static bool MULTITHREADING_LOAD = false;
public static bool MULTITHREADING = false; public static bool MULTITHREADING = false;
public static int MAX_THREADS = Environment.ProcessorCount;
public static bool DEBUG = false; public static bool DEBUG = false;
private static string[] menuItems = new string[] { "Charger une image", "Créer une image" }; private static string[] menuItems = new string[] { "Charger une image", "Créer une image" };
...@@ -111,7 +112,12 @@ namespace S04_Projet ...@@ -111,7 +112,12 @@ namespace S04_Projet
break; break;
} }
img = img.Filter(Filter.Filtres[choix], Filter.Facteurs[choix]); img = img.Filter(Filter.Filtres[choix], Filter.Facteurs[choix]);
}; }
else if (args[i] == "--threads" || args[i] == "-t")
{
MAX_THREADS = int.Parse(args[i + 1]);
increment = 2;
}
if (DEBUG) if (DEBUG)
{ {
......
@echo off
FOR /L %%i IN (1,1,30) DO (
ECHO i : %%i
FOR /L %%j IN (1,1,20) DO (
ECHO j : %%j
ImageProcessing.exe -d -MT -t %%i -i img\flocon.bmp -f flou
)
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment