Пример #1
0
        public static eCudafyType?GetCudafyType(this ICustomAttributeProvider med, out bool isDummy, out bool ignore, out eCudafyDummyBehaviour behaviour, out eCudafyInlineMode inlineMode)
        {
            isDummy    = false;
            behaviour  = eCudafyDummyBehaviour.Default;
            inlineMode = eCudafyInlineMode.Auto;
            ignore     = false;
            if (med is TypeDefinition)
            {
                med = med as TypeDefinition;
            }

            var customInline = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYINLINEATTRIBUTE).FirstOrDefault();

            if (customInline != null)
            {
                if (customInline.ConstructorArguments.Count() > 0)
                {
                    inlineMode = (eCudafyInlineMode)customInline.ConstructorArguments.First().Value;
                }
            }

            var customAttr = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYATTRIBUTE).FirstOrDefault();

            if (customAttr == null)
            {
                customAttr = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYDUMMYATTRIBUTE).FirstOrDefault();
                isDummy    = customAttr != null;
            }
            if (customAttr == null)
            {
                customAttr = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYIGNOREATTRIBUTE).FirstOrDefault();
                ignore     = true;
            }
            else
            {
                eCudafyType et = eCudafyType.Auto;
                if (customAttr.ConstructorArguments.Count() > 0)
                {
                    et = (eCudafyType)customAttr.ConstructorArguments.First().Value;
                }
                if (customAttr.ConstructorArguments.Count() > 1)
                {
                    behaviour = (eCudafyDummyBehaviour)customAttr.ConstructorArguments.ElementAt(1).Value;
                }
                return(et);
            }
            return(null);
        }
Пример #2
0
        //public static CudafyDummyAttribute GetCudafyDummyAttribute(this ICustomAttributeProvider med)
        //{
        //    customAttr = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYDUMMYATTRIBUTE).FirstOrDefault();
        //}

        public static eCudafyType?GetCudafyType(this ICustomAttributeProvider med)
        {
            var customAttr = med.CustomAttributes.Where(ca => ca.AttributeType.Name == csCUDAFYATTRIBUTE).FirstOrDefault();

            if (customAttr != null)
            {
                eCudafyType et = eCudafyType.Auto;
                if (customAttr.ConstructorArguments.Count() > 0)
                {
                    et = (eCudafyType)customAttr.ConstructorArguments.First().Value;
                }
                return(et);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CudafyDummyAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="behaviour">If set to Suppress then do not include CUDA C file of the same name.</param>
 public CudafyDummyAttribute(eCudafyType type, eCudafyDummyBehaviour behaviour = eCudafyDummyBehaviour.Default)
 {
     CudafyType = type;
     SupportsEmulation = true;
     Behaviour = behaviour;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CudafyAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public CudafyAttribute(eCudafyType type)
 {
     CudafyType = type;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CudafyDummyAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="behaviour">If set to Suppress then do not include CUDA C file of the same name.</param>
 public CudafyDummyAttribute(eCudafyType type, eCudafyDummyBehaviour behaviour = eCudafyDummyBehaviour.Default)
 {
     CudafyType        = type;
     SupportsEmulation = true;
     Behaviour         = behaviour;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CudafyAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public CudafyAttribute(eCudafyType type)
 {
     CudafyType = type;
 }
Пример #7
0
 private static eKernelMethodType GetKernelMethodType(eCudafyType? attr, MethodInfo mi)
 {
     eKernelMethodType kmt;
     if (attr == eCudafyType.Auto)
         kmt = mi.ReturnType.Name == "Void" ? eKernelMethodType.Global : eKernelMethodType.Device;
     else if (attr == eCudafyType.Device)
         kmt = eKernelMethodType.Device;
     else if (attr == eCudafyType.Global && mi.ReturnType.Name != "Void")
         throw new CudafyException(CudafyException.csX_NOT_SUPPORTED, "Return values on global methods");
     else if (attr == eCudafyType.Global)
         kmt = eKernelMethodType.Global;
     else if (attr == eCudafyType.Struct)
         throw new CudafyException(CudafyException.csX_NOT_SUPPORTED, "Cudafy struct attribute on methods");
     else
         throw new CudafyFatalException(attr.ToString());
     return kmt;
 }