Ejemplo n.º 1
0
        /// <summary>
        /// Creates a runtime compiler instance.
        /// </summary>
        /// <param name="src">CUDA program source.</param>
        /// <param name="name">CUDA program name.<para/>
        /// name can be NULL; "default_program" is used when name is NULL.</param>
        /// <param name="includeNames">Sources of the headers.</param>
        /// <param name="headers">Name of each header by which they can be included in the CUDA program source.</param>
        public CudaRuntimeCompiler(string src, string name, string[] headers, string[] includeNames)
        {
            int headerCount = 0;
            IntPtr[] headersPtr = null;
            IntPtr[] includeNamesPtr = null;

            try
            {
                if (headers != null && includeNames != null)
                {
                    if (headers.Length != includeNames.Length)
                        throw new ArgumentException("headers and includeNames must have same length.");

                    if (headers == null)
                        throw new ArgumentNullException("headers can't be NULL if includeNames is not NULL");

                    if (includeNames == null)
                        throw new ArgumentNullException("includeNames can't be NULL if headers is not NULL");

                    headerCount = headers.Length;

                    headersPtr = new IntPtr[headerCount];
                    includeNamesPtr = new IntPtr[headerCount];

                    for (int i = 0; i < headerCount; i++)
                    {
                        headersPtr[i] = Marshal.StringToHGlobalAnsi(headers[i]);
                        includeNamesPtr[i] = Marshal.StringToHGlobalAnsi(includeNames[i]);
                    }
                }

                _program = new nvrtcProgram();
                res = NVRTCNativeMethods.nvrtcCreateProgram(ref _program, src, name, headerCount, headersPtr, includeNamesPtr);
                Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvrtcCreateProgram", res));
            }
            finally
            {
                if (headersPtr != null)
                    for (int i = 0; i < headersPtr.Length; i++)
                    {
                        Marshal.FreeHGlobal(headersPtr[i]);
                    }

                if (includeNamesPtr != null)
                    for (int i = 0; i < includeNamesPtr.Length; i++)
                    {
                        Marshal.FreeHGlobal(includeNamesPtr[i]);
                    }
            }

            if (res != nvrtcResult.Success)
                throw new NVRTCException(res);
        }
Ejemplo n.º 2
0
 public static extern nvrtcResult nvrtcCompileProgram(nvrtcProgram prog, int numOptions, IntPtr[] options);
Ejemplo n.º 3
0
 public static extern nvrtcResult nvrtcDestroyProgram(ref nvrtcProgram prog);
Ejemplo n.º 4
0
 public static extern nvrtcResult nvrtcCreateProgram(ref nvrtcProgram prog,
                                                     [MarshalAs(UnmanagedType.LPStr)] string src,
                                                     [MarshalAs(UnmanagedType.LPStr)] string name,
                                                     int numHeaders,
                                                     IntPtr[] headers,
                                                     IntPtr[] includeNames);
Ejemplo n.º 5
0
        public static extern nvrtcResult nvrtcGetLoweredName(nvrtcProgram prog,
										[MarshalAs(UnmanagedType.LPStr)] string name_expression, ref IntPtr lowered_name);
Ejemplo n.º 6
0
 public static extern nvrtcResult nvrtcAddNameExpression(nvrtcProgram prog, [MarshalAs(UnmanagedType.LPStr)] string name_expression);
Ejemplo n.º 7
0
 public static extern nvrtcResult nvrtcGetProgramLogSize(nvrtcProgram prog, ref SizeT logSizeRet);
Ejemplo n.º 8
0
 public static extern nvrtcResult nvrtcGetCUBINSize(nvrtcProgram prog, ref SizeT cubinSizeRet);
Ejemplo n.º 9
0
		public static extern nvrtcResult nvrtcGetPTX(nvrtcProgram prog, byte[] ptx);
Ejemplo n.º 10
0
		public static extern nvrtcResult nvrtcGetPTXSize(nvrtcProgram prog, ref SizeT ptxSizeRet);
Ejemplo n.º 11
0
		public static extern nvrtcResult nvrtcCompileProgram(nvrtcProgram prog, int numOptions, IntPtr[] options);
Ejemplo n.º 12
0
 public static extern nvrtcResult nvrtcGetNVVM(nvrtcProgram prog, byte[] nvvm);
Ejemplo n.º 13
0
 public static extern nvrtcResult nvrtcGetNVVMSize(nvrtcProgram prog, ref SizeT nvvmSizeRet);
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a runtime compiler instance.
        /// </summary>
        /// <param name="src">CUDA program source.</param>
        /// <param name="name">CUDA program name.<para/>
        /// name can be NULL; "default_program" is used when name is NULL.</param>
        /// <param name="includeNames">Sources of the headers.</param>
        /// <param name="headers">Name of each header by which they can be included in the CUDA program source.</param>
        public CudaRuntimeCompiler(string src, string name, string[] headers, string[] includeNames)
        {
            int headerCount = 0;

            IntPtr[] headersPtr      = null;
            IntPtr[] includeNamesPtr = null;

            try
            {
                if (headers != null && includeNames != null)
                {
                    if (headers.Length != includeNames.Length)
                    {
                        throw new ArgumentException("headers and includeNames must have same length.");
                    }

                    if (headers == null)
                    {
                        throw new ArgumentNullException("headers can't be NULL if includeNames is not NULL");
                    }

                    if (includeNames == null)
                    {
                        throw new ArgumentNullException("includeNames can't be NULL if headers is not NULL");
                    }

                    headerCount = headers.Length;

                    headersPtr      = new IntPtr[headerCount];
                    includeNamesPtr = new IntPtr[headerCount];

                    for (int i = 0; i < headerCount; i++)
                    {
                        headersPtr[i]      = Marshal.StringToHGlobalAnsi(headers[i]);
                        includeNamesPtr[i] = Marshal.StringToHGlobalAnsi(includeNames[i]);
                    }
                }

                _program = new nvrtcProgram();
                res      = NVRTCNativeMethods.nvrtcCreateProgram(ref _program, src, name, headerCount, headersPtr, includeNamesPtr);
                Debug.Write("");                //Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nvrtcCreateProgram", res));
            }
            finally
            {
                if (headersPtr != null)
                {
                    for (int i = 0; i < headersPtr.Length; i++)
                    {
                        Marshal.FreeHGlobal(headersPtr[i]);
                    }
                }

                if (includeNamesPtr != null)
                {
                    for (int i = 0; i < includeNamesPtr.Length; i++)
                    {
                        Marshal.FreeHGlobal(includeNamesPtr[i]);
                    }
                }
            }

            if (res != nvrtcResult.Success)
            {
                throw new NVRTCException(res);
            }
        }
Ejemplo n.º 15
0
 public static extern nvrtcResult nvrtcAddNameExpression(nvrtcProgram prog, [MarshalAs(UnmanagedType.LPStr)] string name_expression);
Ejemplo n.º 16
0
 public static extern nvrtcResult nvrtcGetPTXSize(nvrtcProgram prog, ref SizeT ptxSizeRet);
Ejemplo n.º 17
0
 public static extern nvrtcResult nvrtcGetPTX(nvrtcProgram prog, byte[] ptx);
Ejemplo n.º 18
0
		public static extern nvrtcResult nvrtcGetProgramLogSize(nvrtcProgram prog, ref SizeT logSizeRet);
Ejemplo n.º 19
0
 public static extern nvrtcResult nvrtcGetCUBIN(nvrtcProgram prog, byte[] cubin);
Ejemplo n.º 20
0
		public static extern nvrtcResult nvrtcGetProgramLog(nvrtcProgram prog, byte[] log);
Ejemplo n.º 21
0
 public static extern nvrtcResult nvrtcGetProgramLog(nvrtcProgram prog, byte[] log);
Ejemplo n.º 22
0
		public static extern nvrtcResult nvrtcCreateProgram(ref nvrtcProgram prog,
                               [MarshalAs(UnmanagedType.AnsiBStr)] string src,
                               [MarshalAs(UnmanagedType.AnsiBStr)] string name,
                               int numHeaders,
                               IntPtr[] headers,
                               IntPtr[] includeNames);
Ejemplo n.º 23
0
 public static extern nvrtcResult nvrtcGetLoweredName(nvrtcProgram prog,
                                                      [MarshalAs(UnmanagedType.LPStr)] string name_expression, ref IntPtr lowered_name);
Ejemplo n.º 24
0
		public static extern nvrtcResult nvrtcDestroyProgram(ref nvrtcProgram prog);