示例#1
0
        private void SearchRangeAttributes(Range range)
        {
            IVariableDeclaration ivd = range.GetIndexDeclaration();

            foreach (ICompilerAttribute attr in range.GetAttributes <ICompilerAttribute>())
            {
                if (attr is ParallelSchedule ps)
                {
                    toSearch.Push(ps.scheduleExpression);
                    var attr2 = new ParallelScheduleExpression(ps.scheduleExpression.GetExpression());
                    Attributes.Set(ivd, attr2);
                }
                else if (attr is DistributedSchedule ds)
                {
                    toSearch.Push(ds.commExpression);
                    if (ds.scheduleExpression != null)
                    {
                        toSearch.Push(ds.scheduleExpression);
                    }
                    if (ds.schedulePerThreadExpression != null)
                    {
                        toSearch.Push(ds.schedulePerThreadExpression);
                    }
                    var attr2 = new DistributedScheduleExpression(ds.commExpression.GetExpression(), ds.scheduleExpression?.GetExpression(), ds.schedulePerThreadExpression?.GetExpression());
                    Attributes.Set(ivd, attr2);
                }
                else
                {
                    Attributes.Set(ivd, attr);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Search all variables referred to by a Range.
        /// </summary>
        /// <param name="range"></param>
        private void SearchRange(Range range)
        {
            if (searched.Contains(range))
            {
                return;
            }
            string name = ((IModelExpression)range).Name;

            foreach (IModelExpression expr in searched)
            {
                if (name.Equals(expr.Name))
                {
                    throw new InferCompilerException("Model contains multiple items with the name '" + name + "'.  Names must be unique.");
                }
            }
            searched.Add(range);
            toSearch.Push(range.Size);
            IVariableDeclaration ivd = range.GetIndexDeclaration();

            foreach (ICompilerAttribute attr in range.GetAttributes <ICompilerAttribute>())
            {
                if (attr is ParallelSchedule)
                {
                    var ps = (ParallelSchedule)attr;
                    toSearch.Push(ps.scheduleExpression);
                    var attr2 = new ParallelScheduleExpression(ps.scheduleExpression.GetExpression());
                    Attributes.Set(ivd, attr2);
                }
                else if (attr is DistributedSchedule)
                {
                    var ds = (DistributedSchedule)attr;
                    toSearch.Push(ds.commExpression);
                    if (ds.scheduleExpression != null)
                    {
                        toSearch.Push(ds.scheduleExpression);
                    }
                    if (ds.schedulePerThreadExpression != null)
                    {
                        toSearch.Push(ds.schedulePerThreadExpression);
                    }
                    var attr2 = new DistributedScheduleExpression(ds.commExpression.GetExpression(), ds.scheduleExpression?.GetExpression(), ds.schedulePerThreadExpression?.GetExpression());
                    Attributes.Set(ivd, attr2);
                }
                else
                {
                    Attributes.Set(ivd, attr);
                }
            }
        }