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 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(); }
public virtual void Dispose() { Db?.Dispose(); }
public void Dispose() { KernelDatabase.Dispose(); }
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); }