Esempio n. 1
0
 public void Launch(CUfunction func)
 {
     this.LastError = CUDADriver.cuLaunch(func);
 }
Esempio n. 2
0
        public override void DoLayout()
        {
            CUdeviceptr p1 = new CUdeviceptr();

            CUDADriver.cuMemAlloc(ref p1, 1 << 10);
            byte[] b = new byte[1 << 10];
            CUDADriver.cuMemcpyHtoD(p1, b, (uint)b.Length);

            CUfunction func = new CUfunction();
            CUResult   res;

            int nnodes = (int)Network.VertexCount * 2;
            int blocks = 32;

            if (nnodes < 1024 * blocks)
            {
                nnodes = 1024 * blocks;
            }
            while ((nnodes & (prop.SIMDWidth - 1)) != 0)
            {
                nnodes++;
            }
            nnodes--;

            //float dtime = 0.025f;  float dthf = dtime * 0.5f;
            //float epssq = 0.05f * 0.05f;
            //float itolsq = 1.0f / (0.5f * 0.5f);

            CUDADriver.cuModuleGetFunction(ref func, mod, "dummy");

            // Float4[] data = new Float4[100];
            CUdeviceptr ptr = new CUdeviceptr();

            //CUDADriver.cuMemAlloc(ref ptr, (uint) 100 * System.Runtime.InteropServices.Marshal.SizeOf(Float4));
            CUDADriver.cuParamSeti(func, 0, (uint)ptr.Pointer);
            CUDADriver.cuParamSetSize(func, 4);

            res = CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in dummy function: " + res.ToString());
            }

            // InitializationKernel<<<1, 1>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "InitializationKernel");
            res = CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in InitializationKernel: " + res.ToString());
            }

            // BoundingBoxKernel<<<blocks * FACTOR1, THREADS1>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "BoundingBoxKernel: " + res.ToString());
            CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in BoundingBoxKernel: " + res.ToString());
            }

            // TreeBuildingKernel<<<blocks * FACTOR2, THREADS2>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "TreeBuildingKernel: " + res.ToString());
            CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in TreeBuildingKernel: " + res.ToString());
            }

            // SummarizationKernel<<<blocks * FACTOR3, THREADS3>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "SummarizationKernel: " + res.ToString());
            CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in SummarizationKernel: " + res.ToString());
            }

            // ForceCalculationKernel<<<blocks * FACTOR5, THREADS5>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "ForceCalculationKernel: " + res.ToString());
            CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in ForceCalculationKernel: " + res.ToString());
            }

            // IntegrationKernel<<<blocks * FACTOR6, THREADS6>>>();
            CUDADriver.cuModuleGetFunction(ref func, mod, "IntegrationKernel");
            CUDADriver.cuLaunch(func);
            if (res != CUResult.Success)
            {
                Logger.AddMessage(LogEntryType.Warning, "CUDA Error in IntegrationKernel: " + res.ToString());
            }
        }