public FLDataContainer() { Instance = CLAPI.GetInstance(); InstructionSet = FLInstructionSet.CreateWithBuiltInTypes(Instance, "assets/kernel"); BufferCreator = BufferCreator.CreateWithBuiltInTypes(); Parser = new FLParser(InstructionSet, BufferCreator, WorkItemRunnerSettings.Default); }
public void CompileTest() { CLAPI instance = CLAPI.GetInstance(); KernelDatabase db = new KernelDatabase(instance, "resources/kernel", DataVectorTypes.Uchar1); Assert.True(db.KernelNames.Count != 0); Assert.Pass("Kernels Loaded: " + db.KernelNames.Count); db.Dispose(); instance.Dispose(); }
public FlMultiThreadScriptRunner( Action onFinishQueueCallback, DataVectorTypes dataVectorTypes = DataVectorTypes.Uchar1, string kernelFolder = "resources/kernel") : base( CLAPI .GetInstance(), dataVectorTypes, kernelFolder ) { OnFinishQueue = onFinishQueueCallback; }
private static FLDataContainer InitializeCLKernels(string kernelPath) { { CLAPI instance = CLAPI.GetInstance(); Logger.Log(LogType.Log, "Discovering Files in Path: " + kernelPath, 1); string[] files = IOManager.DirectoryExists(kernelPath) ? IOManager.GetFiles(kernelPath, "*.cl") : new string[0]; if (files.Length == 0) { Logger.Log(LogType.Error, "Error: No Files found at path: " + kernelPath, 1); } KernelDatabase dataBase = new KernelDatabase(DataVectorTypes.Uchar1); List <CLProgramBuildResult> results = new List <CLProgramBuildResult>(); bool throwEx = false; int kernelCount = 0; int fileCount = 0; foreach (string file in files) { Logger.Log( LogType.Log, $"[{fileCount}/{files.Length}]Loading: {file} ({kernelCount})", 2 ); try { CLProgram prog = dataBase.AddProgram(instance, file, false, out CLProgramBuildResult res); kernelCount += prog.ContainedKernels.Count; throwEx |= !res; results.Add(res); } catch (Exception e) { Logger.Log(LogType.Error, "ERROR: " + e.Message, 2); } fileCount++; } Logger.Log(LogType.Log, "Kernels Loaded: " + kernelCount, 1); FLInstructionSet iset = FLInstructionSet.CreateWithBuiltInTypes(dataBase); BufferCreator creator = BufferCreator.CreateWithBuiltInTypes(); FLParser parser = new FLParser(iset, creator, new WorkItemRunnerSettings(true, 2)); return(new FLDataContainer(instance, iset, creator, parser)); } }
public void SignatureParsing() { CLAPI instance = CLAPI.GetInstance(); KernelDatabase db = new KernelDatabase(DataVectorTypes.Uchar1); CLProgram program = db.AddProgram(instance, TEST_KERNEL, "./", true, out CLProgramBuildResult result); CLKernel kernel = program.ContainedKernels["set_value"]; Assert.True(CheckParameter(kernel.Parameter["arr"], "arr", true, 0, DataVectorTypes.Uchar1, MemoryScope.Global)); Assert.True(CheckParameter(kernel.Parameter["value"], "value", false, 1, DataVectorTypes.Uchar1, MemoryScope.None)); db.Dispose(); instance.Dispose(); }
//private GameWindow window; public FlMultiThreadScriptRunner(Action onFinishQueueCallback, DataTypes dataTypes = DataTypes.Uchar1, string kernelFolder = "assets/kernel/") : base( CLAPI.GetInstance(), dataTypes, kernelFolder) { }
private void Initialize() { CLAPI instance = CLAPI.GetInstance(); string path = FLScriptEditor.Settings.KernelPath; StartupSequence.loaderForm.SetStatus("Discovering Files in Path: " + path); string[] files = IOManager.DirectoryExists(path) ? IOManager.GetFiles(path, "*.cl") : new string[0]; if (files.Length == 0) { DialogResult res = StyledMessageBox.Show( "Error", "No Files found at path: " + path, MessageBoxButtons.AbortRetryIgnore, SystemIcons.Error ); if (res == DialogResult.Retry) { Initialize(); return; } if (res == DialogResult.Abort) { StartupSequence.loaderForm.DialogResult = DialogResult.Abort; StartupSequence.loaderForm.Close(); return; } if (res == DialogResult.Ignore) { StartupSequence.loaderForm.DialogResult = DialogResult.OK; } } KernelDatabase dataBase = new KernelDatabase(DataVectorTypes.Uchar1); List <CLProgramBuildResult> results = new List <CLProgramBuildResult>(); bool throwEx = false; int kernelCount = 0; int fileCount = 0; if (FLScriptEditor.Settings.ExperimentalKernelLoading) { try { string source = TextProcessorAPI.PreprocessSource(files, new Dictionary <string, bool>()); CLProgram prog = dataBase.AddProgram(instance, source, "./", false, out CLProgramBuildResult res); throwEx |= !res; if (res) { kernelCount += prog.ContainedKernels.Count; } results.Add(res); StartupSequence.loaderForm.SetStatus($"File Loaded(Kernels Loaded): ({kernelCount})"); } catch (Exception e) { throw new SoftException(e); } } else { foreach (string file in files) { StartupSequence.loaderForm.SetStatus( $"[{fileCount}/{files.Length}]Loading: {file} ({kernelCount})" ); try { CLProgram prog = dataBase.AddProgram(instance, file, false, out CLProgramBuildResult res); kernelCount += prog.ContainedKernels.Count; throwEx |= !res; results.Add(res); } catch (Exception e) { StartupSequence.loaderForm.Log("ERROR: " + e.Message, Color.Red); throw e; //Let the Exception Viewer Catch that } fileCount++; } } StartupSequence.loaderForm.SetStatus("Loading Finished"); StartupSequence.loaderForm.Log("Loading Finished", Color.White); StartupSequence.loaderForm.Log("Kernels Loaded: " + kernelCount, Color.White); if (throwEx) { DialogResult res = StyledMessageBox.Show( "OpenCL Build Errors", "There are errors in one or more OpenCL kernels. Do you want to open the OpenCL Build Excepion Viewer?", MessageBoxButtons.YesNoCancel, SystemIcons.Warning ); if (res == DialogResult.Cancel) { StartupSequence.loaderForm.DialogResult = DialogResult.Abort; StartupSequence.loaderForm.Close(); } else if (res == DialogResult.Yes) { BuildExceptionViewer bvr = new BuildExceptionViewer(new CLBuildException(results)); if (bvr.ShowDialog() == DialogResult.Retry) { dataBase.Dispose(); Initialize(); } } } FLInstructionSet iset = FLInstructionSet.CreateWithBuiltInTypes(dataBase); BufferCreator creator = BufferCreator.CreateWithBuiltInTypes(); FLParser parser = new FLParser(iset, creator, new WorkItemRunnerSettings(true, 2)); StartupSequence.FlContainer = new FLDataContainer(instance, iset, creator, parser); }