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); } } }
/// <summary> /// Gets a statement for the entire block, and a pointer to its body. /// </summary> /// <param name="innerBlock">On return, a pointer to the body of the block.</param> /// <returns></returns> internal override IStatement GetStatement(out IList <IStatement> innerBlock) { if (ConditionVariable.IsObserved) { innerBlock = null; return(null); } IForStatement ifs = Builder.ForStmt(range.GetIndexDeclaration(), range.GetSizeExpression()); ifs.Body.Statements.Add(base.GetStatement(out innerBlock)); return(ifs); }
/// <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); } } }