public GridIntrinsicAttribute( GridIntrinsicKind intrinsicKind, DeviceConstantDimension3D dimension) { IntrinsicKind = intrinsicKind; Dimension = dimension; }
/// <summary cref="CompilerDeviceFunctions.MakeGrid(InvocationContext, GridIntrinsicKind)"/> protected override Value?MakeGrid(InvocationContext context, GridIntrinsicKind kind) { if (context.GetArgs().Length != 0 || context.GetMethodGenericArguments().Length != 0) { throw context.CompilationContext.GetNotSupportedException( ErrorMessages.NotSupportedGridIntrinsic, kind); } Lazy <LLVMValueRef>[] indices; switch (kind) { case GridIntrinsicKind.GetGridDimension: indices = GetGridDimensions; break; case GridIntrinsicKind.GetGroupDimension: indices = GetBlockDimensions; break; default: throw context.CompilationContext.GetNotSupportedException( ErrorMessages.NotSupportedGridIntrinsic, kind); } Debug.Assert(indices != null, "Invalid grid indices"); var builder = context.Builder; var indexValue = GetUndef(context.Unit.GetType(typeof(Index3))); for (int i = 0; i < 3; ++i) { var resolvedValue = BuildCall(builder, indices[i].Value); indexValue = BuildInsertValue(builder, indexValue, resolvedValue, i, string.Empty); } return(new Value(typeof(Index3), indexValue)); }
/// <summary> /// Handles general grid operations. /// </summary> /// <param name="context">The current invocation context.</param> /// <param name="kind">The kind of the grid intrinsic.</param> /// <returns>The resulting value.</returns> protected abstract Value?MakeGrid(InvocationContext context, GridIntrinsicKind kind);
public GridIntrinsicAttribute(GridIntrinsicKind intrinsicKind) { IntrinsicKind = intrinsicKind; }