Ejemplo n.º 1
0
        private static List <IntPtr> AllocateGiem2gDataBuffers(INativeMemoryProvider memoryProvider, ref giem2g_data giem2g_ie_op, int nz)
        {
            var giem2g_ptrs = new List <IntPtr> ();

//			var tmp1=(memoryProvider.AllocateBytes(giem2g_ie_op.tensor_size));
//			giem2g_ie_op.giem2g_tensor=tmp1;
            var tmp1 = giem2g_ie_op.giem2g_tensor;

            giem2g_ptrs.Add(tmp1);

            var tmp2 = (memoryProvider.AllocateComplex(giem2g_ie_op.ie_kernel_buffer_length));

            giem2g_ptrs.Add(new IntPtr(tmp2));
            giem2g_ie_op.kernel_buffer = tmp2;

            var dz = (memoryProvider.AllocateDouble(nz));

            giem2g_ie_op.dz = dz;
            giem2g_ptrs.Add(new IntPtr(dz));

            var sqsigb = (memoryProvider.AllocateDouble(nz));

            giem2g_ie_op.sqsigb = sqsigb;
            giem2g_ptrs.Add(new IntPtr(sqsigb));

            var csigb = (memoryProvider.AllocateComplex(nz));

            giem2g_ie_op.csigb = csigb;
            giem2g_ptrs.Add(new IntPtr(csigb));
            return(giem2g_ptrs);
        }
Ejemplo n.º 2
0
 public FortranMatrix(INativeMemoryProvider memoryProvider, int nx, int ny)
 {
     _ptr            = memoryProvider.AllocateComplex(((long)nx) * ny);
     Nx              = nx;
     Ny              = ny;
     _memoryProvider = memoryProvider;
 }
Ejemplo n.º 3
0
        public void AllocateBuffersAndCreatePlansParallel(int nx, int ny, int nz, Mpi mpi)
        {
            CustomFft  = new CustomDistributedFft(mpi, _profiler);
            IsParallel = true;

            var localSize3Nz = CustomDistributedFft.GetLocalSize(mpi, nx * 2, ny * 2, 3 * nz);

            var ranks = Enumerable.Range(0, mpi.Size / 2).ToArray();

            RealModelPart = mpi.Merge(ranks);

            _inputBuffer  = _memoryProvider.AllocateComplex(localSize3Nz);
            _outputBuffer = _memoryProvider.AllocateComplex(localSize3Nz);

            Plan3Nz = CreatePlan2D(CustomFft, mpi, _inputBuffer, _outputBuffer, nx * 2, ny * 2, 3 * nz);
            Plan1Nz = CreatePlan2D(CustomFft, mpi, _inputBuffer, _outputBuffer, nx * 2, ny * 2, 1 * nz);
            Plan3   = CreatePlan2D(CustomFft, mpi, _inputBuffer, _outputBuffer, nx * 2, ny * 2, 3);
            Plan1   = CreatePlan2D(CustomFft, mpi, _inputBuffer, _outputBuffer, nx * 2, ny * 2, 1);
        }
Ejemplo n.º 4
0
        public static ScalarSegments AllocateScalarSegments(INativeMemoryProvider memoryProvider, ScalarPlan plan, GreenScalars scalars, int length)
        {
            var radii    = scalars.Radii;
            int nRho     = radii.Length - 1;
            var segments = new SingleScalarSegment[nRho];

            int nComp = scalars.GetNumberOfAvailableIs(plan);
            var ptr   = memoryProvider.AllocateComplex(length * nComp * 2L * nRho);

            long oneSegmentSize = length * nComp * 2L;

            for (int i = 0; i < segments.Length; i++)
            {
                var startPtr = ptr + oneSegmentSize * i;
                segments[i] = new SingleScalarSegment(plan, startPtr, length, nComp);
            }

            return(new ScalarSegments(memoryProvider, ptr, radii, segments));
        }
Ejemplo n.º 5
0
        public static GreenTensor AllocateNew(INativeMemoryProvider memoryProvider,
                                              int nx, int ny, int nTr, int nRc, long compSize, params string[] components)
        {
            var gt       = new GreenTensor(memoryProvider, nx, ny, nTr, nRc);
            var fullSize = compSize * components.Length;

            var ptr = memoryProvider.AllocateComplex(fullSize);

            UNM.ClearBuffer(ptr, fullSize);


            var dict = new Dictionary <string, Component>();

            for (int i = 0; i < components.Length; i++)
            {
                var nextPtr = ptr + i * compSize;
                dict.Add(components[i], new Component(gt, nextPtr));
            }

            gt._basePtrs.Add(new IntPtr(ptr));
            gt._components = dict;

            return(gt);
        }
Ejemplo n.º 6
0
 public NativeVector(INativeMemoryProvider memoryProvider, int length)
 {
     _memoryProvider = memoryProvider;
     _ptr            = memoryProvider.AllocateComplex(length);
     Length          = length;
 }