using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenCL;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
int[] Primes = Enumerable.Range(2, 1000000).ToArray();
EasyCL cl = new EasyCL();
cl.Accelerator = OpenCL.AcceleratorDevice.GPU; //You can also set the accelerator after loading the kernel
cl.LoadKernel(IsPrime); //Load kernel string here, (Compiles in the background)
cl.Invoke("GetIfPrime", Primes.Length, Primes); //Call Function By Name With Parameters
//Primes now contains all Prime Numbers
}
static string IsPrime
{
get
{
return @"
kernel void GetIfPrime(global int* message)
{
int index = get_global_id(0);
int upperl=(int)sqrt((float)message[index]);
for(int i=2;i<=upperl;i++)
{
if(message[index]%i==0)
{
//printf("" %d / %d\n"",index,i );
message[index]=0;
return;
}
}
//printf("" % d"",index);
}";
}
}
}
}
key1[1 1 1 0]
key2 [1 0 0 0]
key3 [1 0 0 0]
PS C:\Users\Sergey> cd e:
PS E:\> cd test
PS E:\test> dotnet new console
The template "Console App" was created successfully.
Processing post-creation actions...
Restoring E:\test\test.csproj:
Determining projects to restore...
Restored E:\test\test.csproj (in 123 ms).
Restore succeeded.
PS E:\test> dotnet run
The number of processors on this computer is 44.
PS E:\test>
while(true)
int idForTheCalc = int.MaxValue
// Ищу задачу на день и если нашел, тогда idForTheCalc получает id
// Если так и остался id по умолчанию, значит спим
if (idForTheCalc == int.MaxValue)
{
System.Threading.Thread.Sleep(2000);
continue;
}
//Если нашел, то делаю что нибудь или опять искать и спать, если задач нет
}
Все исключения обязаны наследоваться от базового.
Перехватить нельзя всего несколько очень специфичных исключений типа OOM
using (MySqlConnection UpgradeConnection = new MySqlConnection(SQLConnect))
{
MySqlCommand updateCommand = UpgradeConnection.CreateCommand();
updateCommand.CommandText = String.Join("", SQL_QUERIES.ToArray());
updateCommand.CommandTimeout = 180;
UpgradeConnection.Open();
updateCommand.ExecuteNonQuery();
}
Thread pPointThread = new Thread(() => pPointsCalculate(InitName, "Week", NextRow));
activeThreads.Add(new threadData
{
id = pPointThread.ManagedThreadId,
InitName = initGrid.Rows[NextRow.Index].Cells[0].Value.ToString(),
thread = pPointThread,
type = "pPointsWeekly"
});
pPointThread.Start();
Два: в стектрейсе пишется ещё тип исключения. Скорее всего тут какой-нибудь ArgumentException
'Timeout can be only be set to 'System.Threading.Timeout.Infinite' or a value > 0.
Parameter name: value'
try
{
updateCommand.ExecuteNonQuery();
}
catch (MySqlException Ext)
{
checkpPointsLog.Invoke((MethodInvoker)delegate
{
UpdateLog(Ext.Message);
});
}