public MyFourierBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
            : base(owner, inputSize, tempBlock)
        {
            m_stream = new CudaStream();

            m_fft = new CudaFFTPlan1D(inputSize, cufftType.R2C, 1);
            m_fft.SetStream(m_stream.Stream);
            m_ifft = new CudaFFTPlan1D(inputSize, cufftType.C2R, 1);
            m_ifft.SetStream(m_stream.Stream);

            m_mulkernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "MulComplexElementWise");
            m_mulkernel.SetupExecution(inputSize + 1);

            m_involutionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "InvolveVector");
            m_involutionKernel.SetupExecution(inputSize - 1);

            m_inversionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\InvertValuesKernel", "InvertLengthComplexKernel");
            m_inversionKernel.SetupExecution(inputSize);

            m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(owner, owner.GPU, ProductMode.f_DotProduct_f);

            m_normalKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\TransformKernels", "PolynomialFunctionKernel");
            m_normalKernel.SetupExecution(inputSize);

            m_firstFFTOffset = 0;
            m_secondFFTOffset = (inputSize + 1) * 2;
            m_tempOffset = (inputSize + 1) * 4;

            Denominator = inputSize;
        }
Example #2
0
        public VectorOps(MyWorkingNode caller, VectorOperation operations, MyMemoryBlock<float> tempBlock)
        {
            m_caller = caller;
            m_operations = operations;
            m_temp = tempBlock;

            MatOperation mat_ops = MatOperation.None;

            if (m_operations.HasFlag(VectorOperation.Rotate))
            {
                Debug.Assert(tempBlock.Count >= 4, "Temporary memory block has to be large at least 4 items when using Rotate operation");
                mat_ops |= MatOperation.Multiplication;
            }

            if (m_operations.HasFlag(VectorOperation.Angle))
                mat_ops |= MatOperation.DotProd;

            if (m_operations.HasFlag(VectorOperation.DirectedAngle))
            {
                mat_ops |= MatOperation.Multiplication | MatOperation.DotProd;
                m_operations |= VectorOperation.Angle | VectorOperation.Rotate;
            }

            m_matOperation = new MyMatrixAutoOps(caller, mat_ops);
        }
 public MyPermutationBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
     : base(owner, inputSize, tempBlock)
 {
     m_PermKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineVectorsKernel");
     m_PermKernel.SetupExecution(inputSize);
     m_binaryPermKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
     m_binaryPermKernel.SetupExecution(inputSize);
 }
        public MyMatrixKernelOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock<float> A, MyMemoryBlock<float> B = null)
        {
            OpersKerlsDictionary = new Dictionary<MatOperation, MyCudaKernel>();
            this.callee = callee;

            if ((operations & MatOperation.Log) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Log, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "LogKernel_naive"));
            }
            if ((operations & MatOperation.Exp) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Exp, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "ExpKernel_naive"));
            }
            if ((operations & MatOperation.Round) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Round, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "RoundKernel_naive"));
            }
            if ((operations & MatOperation.Floor) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Floor, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "FloorKernel_naive"));
            }
            if ((operations & MatOperation.Ceil) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Ceil, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "CeilKernel_naive"));
            }
            if ((operations & MatOperation.Abs) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Abs, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "AbsKernel_naive"));
            }
            if ((operations & MatOperation.GetCol) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetCol, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getCol_FloatId_naive"));
            }
            if ((operations & MatOperation.GetRow) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetRow, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getRow_FloatId_naive"));
            }
            if ((operations & MatOperation.MultiplElemntWise) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.MultiplElemntWise, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_MultiplElementWise_naive"));
            }
            if ((operations & MatOperation.Addition) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Addition, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Addition_naive"));
            }
            if ((operations & MatOperation.Substraction) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Substraction, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Substraction_naive"));
            }
            if (operations > 0 && OpersKerlsDictionary.Count == 0)
            {
                MyLog.Writer.WriteLine(MyLogLevel.ERROR, "Trying to init kernel MatrixOps for undefined MatOperation");
            }
        }
 public MyMatrixAutoOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock<float> A = null)
 {
     if ((MyMatrixKernelOps.AvailableOperations() & operations) > 0)
     {
         MatKerlOps = new MyMatrixKernelOps(callee, operations);
     }
     if ((MyMatrixCublasOps.AvailableOperations() & operations) > 0)
     {
         MatCublOps = new MyMatrixCublasOps(callee);
     }
     if ((MyMatrixCPUOps.AvailableOperations() & operations) > 0)
     {
         MatCPUOps = new MyMatrixCPUOps(callee);
     }
 }
Example #6
0
        public MyDistanceOps(MyWorkingNode caller, DistanceOperation operations, MyMemoryBlock<float> tempBlock = null)
        {
            m_caller = caller;
            m_operations = operations;
            m_temp = tempBlock;

            if (operations.HasFlag(DistanceOperation.DotProd))
            {
                m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.CosDist))
            {
                m_cosKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_Cosine_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared))
            {
                // EuclidDist computes EuclidDistSquared first, so keep them together:
                m_operations |= DistanceOperation.EuclidDist | DistanceOperation.EuclidDistSquared;
                m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.HammingDist))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction<float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }
            if (operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction<float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared) ||
                operations.HasFlag(DistanceOperation.HammingDist) || operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_combineVecsKernel = MyKernelFactory.Instance.Kernel(m_caller.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
            }
        }
Example #7
0
 public MyXORBinder(MyWorkingNode owner, int inputSize)
     : base(owner, inputSize, null)
 {
     m_XORKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
     m_XORKernel.SetupExecution(inputSize);
 }
 public MySymbolBinderBase(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
 {
     m_inputSize = inputSize;
     m_tempBlock = tempBlock;
     m_owner = owner;
 }
Example #9
0
 public void RemoveNode(MyWorkingNode node)
 {
     m_removedNodes.Add(node);
 }
        private MyExecutionBlock CreateNodeExecutionPlan(MyWorkingNode node, bool initPhase)
        {
            List<IMyExecutable> defaultPlanContent = new List<IMyExecutable>();

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyIncomingSignalTask(node));
            }

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);

                if (task != null && initPhase && task.OneShot || !initPhase && !task.OneShot)
                {
                    defaultPlanContent.Add(task);
                }
            }

            if (node is MyNodeGroup)
            {
                IEnumerable<MyNode> children = (node as MyNodeGroup).Children.OrderBy(x => x.TopologicalOrder);

                foreach (MyNode childNode in children)
                {
                    if (childNode is MyWorkingNode)
                    {
                        defaultPlanContent.Add(CreateNodeExecutionPlan(childNode as MyWorkingNode, initPhase));
                    }
                }
            }

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyOutgoingSignalTask(node));
            }

            MyExecutionBlock defaultPlan = new MyExecutionBlock(defaultPlanContent.ToArray());
            defaultPlan.Name = node.Name;

            MyExecutionBlock resultPlan = defaultPlan;

            if (node is IMyCustomExecutionPlanner)
            {
                if (initPhase)
                {
                    resultPlan = (node as IMyCustomExecutionPlanner).CreateCustomInitPhasePlan(defaultPlan);
                }
                else
                {
                    resultPlan = (node as IMyCustomExecutionPlanner).CreateCustomExecutionPlan(defaultPlan);
                }
                resultPlan.Name = defaultPlan.Name;
            }

            if (node is MyNodeGroup)
            {
                resultPlan.Name += " (group)";
            }

            return resultPlan;
        }
        public MyExecutionBlock CreateNodeExecutionPlan(MyWorkingNode node, bool initPhase)
        {
            List<IMyExecutable> defaultPlanContent = new List<IMyExecutable>();

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyIncomingSignalTask(node));
            }

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);

                if (task != null && !task.DesignTime && (initPhase && task.OneShot || !initPhase && !task.OneShot))
                {
                    defaultPlanContent.Add(task);
                }
            }

            MyNodeGroup nodeGroup = node as MyNodeGroup;
            if (nodeGroup != null)
            {
                IEnumerable<MyNode> children = nodeGroup.Children.OrderBy(x => x.TopologicalOrder);

                foreach (MyNode childNode in children)
                {
                    MyWorkingNode childWorkingNode = childNode as MyWorkingNode;
                    if (childWorkingNode != null)
                    {
                        defaultPlanContent.Add(CreateNodeExecutionPlan(childWorkingNode, initPhase));
                    }
                }
            }

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyOutgoingSignalTask(node));
            }

            MyExecutionBlock defaultPlan = new MyExecutionBlock(defaultPlanContent.ToArray());
            defaultPlan.Name = node.Name;

            MyExecutionBlock resultPlan = defaultPlan;

            IMyCustomExecutionPlanner executionPlannerNode = node as IMyCustomExecutionPlanner;
            if (executionPlannerNode != null)
            {
                if (initPhase)
                {
                    resultPlan = executionPlannerNode.CreateCustomInitPhasePlan(defaultPlan);
                }
                else
                {
                    resultPlan = executionPlannerNode.CreateCustomExecutionPlan(defaultPlan);
                }
                resultPlan.Name = defaultPlan.Name;
            }

            if (resultPlan.Name == null)
                resultPlan.Name = node.GetType().Name;

            if (node is MyNodeGroup)
            {
                resultPlan.Name += " (group)";
            }

            // TODO(HonzaS): Rethink this. It's only used in profiling results.
            node.ExecutionBlock = resultPlan;

            return resultPlan;
        }
        public override void Restore(MyProject project)
        {
            string[] idSplit = PropertyId.Split(new[] { SerializationIdSeparator }, StringSplitOptions.RemoveEmptyEntries);

            MyNode node = FindNode(project, idSplit[0]);
            WorkingNode = node as MyWorkingNode;
            if (Node == null)
                throw new SerializationException(string.Format("Node id {0} was found but doesn't contain tasks", node.Id));

            string taskGroupName = idSplit[1];
            TaskGroup taskGroup;
            if (!WorkingNode.TaskGroups.TryGetValue(taskGroupName, out taskGroup))
                throw new SerializationException(string.Format("Task group {0} not found", taskGroupName));

            TaskGroup = taskGroup;
        }
Example #13
0
        public void CreateAndShowObserverView(MyWorkingNode node, Type observerType)
        {
            try
            {
                MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType);
                observer.GenericTarget = node;

                ObserverForm newView = new ObserverForm(this, observer, node);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);

                ProjectStateChanged("Node observer added");
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
Example #14
0
 public void AddNode(MyWorkingNode node)
 {
     m_addedNodes.Add(node);
 }
 /// <summary>
 /// Return task of given type from given node
 /// </summary>
 /// <param name="node">Node</param>
 /// <param name="type">Type of task</param>
 /// <returns>Task</returns>
 protected MyTask GetTaskByType(MyWorkingNode node, Type type)
 {
     foreach (PropertyInfo taskPropInfo in node.GetInfo().TaskOrder)
     {
         MyTask task = node.GetTaskByPropertyName(taskPropInfo.Name);
         if (task.GetType().ToString() == type.ToString())
             return task;
     }
     return null;
 }
Example #16
0
        private void RefreshNode(MyWorkingNode node)
        {
            node.Updated();

            propertyGrid.Refresh();
            m_mainForm.InvalidateGraphLayouts();
        }
Example #17
0
 public MyStackingOps(MyWorkingNode caller, MyStackingOperation operations, bool forceInputChecking = false)
 {
     m_caller = caller;
     m_operations = operations;
     m_forceInputChecking = forceInputChecking;
 }
Example #18
0
 public MyMatrixCPUOps(MyWorkingNode callee=null, MatOperation operation = 0, MyMemoryBlock<float> A = null, MyMemoryBlock<float> tmp = null)
 {
 }
Example #19
0
        public static void CheckControlSize(MyValidator validator, MyAbstractMemoryBlock controls, MyWorkingNode sender)
        {
            validator.AssertError(controls != null, sender, "Controls are not connected");

            if (controls != null)
            {
                int neededControls = NrOfControls;
                int providedControls = controls.Count;
                validator.AssertError(providedControls >= neededControls, sender, String.Format("Wrong number of actions. With current control mode ({0}) you have to provide at least {1} controls. Provide the correct number of controls or change the control mode.", Mode, neededControls));
                validator.AssertWarning(providedControls != neededControls, sender, String.Format("With current control mode ({0}) you should provide {1} controls but you provided {2} controls. Make sure that this is what you want and you have correct control mode chosen.", Mode, neededControls, providedControls));
            }
        }
 //private CudaBlas cublas = null;
 public MyMatrixCublasOps(MyWorkingNode callee, MatOperation operation = 0, MyMemoryBlock<float> A = null, MyMemoryBlock<float> tmp = null)
 {
     //  cublas = new CudaBlas();
     this.callee = callee;
 }
        private List<IMyExecutable> GetTasks(MyWorkingNode node)
        {
            List<IMyExecutable> tasks = new List<IMyExecutable>();

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);
                tasks.Add(task);
            }

            MyNodeGroup nodeGroup = node as MyNodeGroup;
            if (nodeGroup != null)
            {
                foreach (MyNode childNode in nodeGroup.Children)
                {
                    MyWorkingNode childWorkingNode = childNode as MyWorkingNode;
                    if (childWorkingNode != null)
                    {
                        tasks.AddRange(GetTasks(childWorkingNode));
                    }
                }
            }

            return tasks;
        }