Example #1
0
        public bool PrepareCurves()
        {
            if (!IsPotcurve)
            {
                return(true);
            }
            ArrayList LookUp = new ArrayList();
            ArrayList DWList = new ArrayList();

            uint   i;
            double dze;

            for (i = 0; i < NAtoms; i++)
            {
                if ((type_[i] = LookUp.IndexOf(type[i])) >= 0)
                {
                    if (DW[i] == (double)DWList[type_[i]])
                    {
                    }
                    else
                    {
                        type_[i] = LookUp.Add(type[i]);
                        DWList.Add(DW[i]);
                    }
                }
                else
                {
                    type_[i] = LookUp.Add(type[i]);
                    DWList.Add(DW[i]);
                }
            }
            NTypes = (uint)LookUp.Count;
            MMM    = new MemMan();
            MemMan.Compact();

            if (IsPotRec)
            {
                CurveLength = 0x10000;
            }
            else
            {
                CurveLength = (uint)(atrad / dela);
            }

            dze = (double)N / (2.0 * (a * Math.Sin(gam)));       // gamma  ÐÀÄÈÀÍÀÕ!!!
            dze = Math.Min(dze, (double)M / (2.0 * (b * Math.Sin(gam))));

            if (!MMM.Allocate(NTypes * CurveLength * sizeof(double)))
                return(false); }
Example #2
0
        public bool StartProc()
        {
            if (tmp == null)
            {
                return(false);
            }
            uint MemRequested, MemSupplied;

            unsafe  { MemRequested = tmp.M * tmp.N * (uint)2 * sizeof(double); }

            if (!MM.Allocate(MemRequested))
            {
                Console.WriteLine(ExI + " ----> virtual allocation failed for " + MemRequested.ToString() + " bytes");
                return(false);
                // тут зацикливается на светофор, если память занята просто другими экзекуторами
                // if(MemAlloc>=MemRequest) ....
            }
            Console.WriteLine(ExI + " ----> allocated " + MemRequested + " bytes, total " + MemMan.MemAlloc);

            if ((MemSupplied = MM.LockAtLeast(0, MinWorkingMem, MemRequested)) >= MemRequested)
            {               // установить параметры памяти в tmp
                Console.WriteLine(ExI + " ----> locked " + MemSupplied + " bytes, total " + MemMan.MemLock);
                unsafe
                {
                    tmp.sli = (double *)MM.LockAddress;
                }
                t = new Thread(new ThreadStart(tmp.StartCalculations));
                t.Start();
                t.Join();
                tmp.FlushOld();
                MM.Free();
                return(true);
            }
            Console.WriteLine(ExI + " ----> failed to lock at least 16M out of " + MemRequested + " bytes");
            //здесь семафор, если память просто заблокирована другими экзекуторами
            // if(MemLock>=MinWorkingMem) ....
            return(false);
        }