Esempio n. 1
0
        public GPU_func()
        {
            km = CudafyTranslator.Cudafy();

            gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
            gpu.LoadModule(km);

            GPU_prop = gpu.GetDeviceProperties();
        }
        ///// <summary>
        ///// Releases unmanaged resources and performs other cleanup operations before the
        ///// <see cref="EmulatedGPU"/> is reclaimed by garbage collection.
        ///// </summary>
        //~EmulatedGPU()
        //{
        //    lock (_lock)
        //    {
        //        FreeAll();
        //        HostFreeAll();
        //    }
        //}


#warning Make configurable at EmulatedGPU level
#pragma warning disable 1591
        /// <summary>
        /// Gets the device properties.
        /// </summary>
        /// <returns>Device properties instance.</returns>
        public override GPGPUProperties GetDeviceProperties(bool useAdvanced = true)
        {
            int i1K  = 1024;
            int i64K = 64 * i1K;
            int i32K = 32 * i1K;

            //Computer comp = new Computer();
            GPGPUProperties props = new GPGPUProperties();

            props.UseAdvanced = useAdvanced;
            props.Capability  = new Version(0, 1, 0, 0);
            props.Name        = "Emulated GPGPU Kernel";
            props.DeviceId    = DeviceId;

            ulong freeMem = FreeMemory;

            props.TotalMemory          = freeMem;
            props.ClockRate            = 0;
            props.IsSimulated          = true;
            props.TotalConstantMemory  = i64K;
            props.MaxGridSize          = new dim3(i64K, i64K);
            props.MaxThreadsSize       = new dim3(i1K, i1K);
            props.MaxThreadsPerBlock   = i1K;
            props.MemoryPitch          = 2147483647;
            props.RegistersPerBlock    = i32K;
            props.SharedMemoryPerBlock = 49152;
            props.WarpSize             = 32;
            props.TextureAlignment     = 512;
            if (useAdvanced)
            {
                props.MultiProcessorCount = Environment.ProcessorCount;
            }
            else
            {
                props.MultiProcessorCount = 0;
            }
            return(props);
        }