Exemple #1
0
        public FLSetup(string testName, string kernelPath, string performance = "performance", Type[] checkPipeline = null,
                       bool useMultiThreading = false, int workSizeMultiplier = 2) : base(testName, performance)
        {
            KernelDatabase = new KernelDatabase(CLAPI.MainThread, kernelPath, DataVectorTypes.Uchar1);
            InstructionSet = FLInstructionSet.CreateWithBuiltInTypes(KernelDatabase);
            BufferCreator  = BufferCreator.CreateWithBuiltInTypes();
            CheckBuilder   = null;
            if (checkPipeline == null)
            {
                CheckBuilder = FLProgramCheckBuilder.CreateDefaultCheckBuilder(InstructionSet, BufferCreator);
            }
            else
            {
                CheckBuilder = new FLProgramCheckBuilder(InstructionSet, BufferCreator);
                foreach (Type useCheck in checkPipeline)
                {
                    CheckBuilder.AddProgramCheck((FLProgramCheck)Activator.CreateInstance(useCheck));
                }
            }


            Parser = new FLParser(InstructionSet, BufferCreator,
                                  new WorkItemRunnerSettings(useMultiThreading, workSizeMultiplier));

            CheckBuilder.Attach(Parser, true);

            Directory.CreateDirectory(RunResultPath);
            Directory.CreateDirectory(DataOutputDirectory);
        }
Exemple #2
0
        public void OpenFL_DefineFile_Wrong_Test()
        {
            TestSetup.SetupTestingSession();
            string file = "resources/filter/defines/test_wrong_define_invalid_file.fl";

            Assert.Catch <Byt3Exception>(() =>
            {
                BufferCreator bc      = new BufferCreator();
                FLInstructionSet iset = new FLInstructionSet();
                FLProgramCheckBuilder checkBuilder = new FLProgramCheckBuilder(iset, bc);
                checkBuilder.AddProgramCheck(new FilePathValidator());

                FLParser parser = new FLParser(iset, bc);
                checkBuilder.Attach(parser, true);

                Assembly asm = Assembly.GetAssembly(typeof(ASerializableBufferCreator));
                parser.BufferCreator.AddBufferCreatorsInAssembly(asm);

                SerializableFLProgram pr = parser.Process(new FLParserInput(file));
            });
        }
Exemple #3
0
        private void Run()
        {
            FLConsole.Settings.SetVerbosity();
            BufferCreator creator = new BufferCreator();

            FLConsole.Settings.BufferCreatorTypes.ForEach(x =>
                                                          creator.AddBufferCreator((ASerializableBufferCreator)Activator.CreateInstance(x)));
            KernelDatabase db = new KernelDatabase(CLAPI.MainThread, FLConsole.Settings.KernelFolder,
                                                   DataVectorTypes.Uchar1);
            FLInstructionSet      iset = FLInstructionSet.CreateWithBuiltInTypes(db);
            FLProgramCheckBuilder programCheckBuilder = new FLProgramCheckBuilder(iset, creator);

            FLConsole.Settings.ProgramCheckTypes.ForEach(x =>
                                                         programCheckBuilder.AddProgramCheck((FLProgramCheck)Activator.CreateInstance(x)));


            FLScriptRunner runner =
                new FLScriptRunner(CLAPI.MainThread, db, creator, iset, programCheckBuilder,
                                   new WorkItemRunnerSettings(FLConsole.Settings.MultiThread,
                                                              FLConsole.Settings.WorkSizeMultiplier));

            string[] inputFiles  = SetInputFilesCommand.InputFiles;
            string[] outputFiles = SetOutputFilesCommand.OutputFiles;


            for (int i = 0; i < inputFiles.Length; i++)
            {
                string inp  = inputFiles[i];
                string outp = outputFiles.Length > i
                    ? outputFiles[i]
                    : $"./{Path.GetFileNameWithoutExtension(inp)}.out.png";

                Bitmap bmp = new Bitmap(FLConsole.Settings.Resolution.X,
                                        FLConsole.Settings.Resolution.Y);

                runner.Enqueue(new FlScriptExecutionContext(inp, bmp, result => OnFinishCallback(result, outp)));
            }

            runner.Process();
        }