コード例 #1
0
 //   public void RegisterCallbacks(TransactionCompleteCB readDone, TransactionCompleteCB* writeDone,  (*reportPower)(double bgpower, double burstpower, double refreshpower, double actprepower))){}
 public void RegisterCallbacks(Callback_t readDone, Callback_t writeDone, powerCallBack_t reportPower)
 {
     for (int i = 0; i < Config.dram_config.NUM_CHANS; i++)
     {
         channels[i].RegisterCallbacks(readDone, writeDone, reportPower);
     }
 }
コード例 #2
0
ファイル: DDRMem.cs プロジェクト: hoangt/PIMSim
        public DDRMem(int pid_)
        {
            this.pid = pid_;

            transactionReceiver = new TransactionReceiver();

            memorySystem = new MultiChannelMemorySystem(Config.dram_config_file, megsOfMemory);
            memorySystem.setCPUClockSpeed(0);
            if (Config.dram_config.RETURN_TRANSACTIONS)
            {
                // transactionReceiver=new TransactionReceiver();
                /* create and register our callback functions */
                read_cb = new Callback_t(transactionReceiver.read_complete);
                // new Callback<TransactionReceiver, void, unsigned, uint64_t, uint64_t>(&transactionReceiver, &TransactionReceiver::read_complete);
                write_cb = new Callback_t(transactionReceiver.write_complete);//
                //  new Callback<TransactionReceiver, void, unsigned, uint64_t, uint64_t>(&transactionReceiver, &TransactionReceiver::write_complete);
                memorySystem.RegisterCallbacks(read_cb, write_cb, null);
            }
            TransationQueue = new List <MemRequest>();
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var mInvoker = new ManagedInvoker();
            var pUnk     = Marshal.GetIUnknownForObject(mInvoker);

            var interop = new InteropInvoker();

            interop.SetInvoker(pUnk.ToPointer());
            NativeLib.SetInvoker(pUnk.ToPointer());

            // Instead of marshalling or projecting an interface over an object
            // pass a handle to the object and unwrap it on demand. This does place
            // some additional pressure on the GC when done excessively, but a single
            // instance is practically noise if it is only one object.
            //
            // The delegate must be stored somewhere or else the GC will collected it.
            // This is because the returned function pointer doesn't count as a
            // reference.
            CallbackInstance = new Callback_t(Callback);
            var fptr = Marshal.GetFunctionPointerForDelegate(CallbackInstance);

            // Remember to free the handle or the GC will never collect the object.
            GCHandle handle = GCHandle.Alloc(mInvoker);

            NativeLib.SetInvokerObject(fptr.ToPointer(), GCHandle.ToIntPtr(handle).ToPointer());

            // Warm up process
            for (int i = 0; i < 100; ++i)
            {
                interop.InvokeWithInt(i);
                interop.InvokeWithObject(i);
                NativeLib.InvokeWithInt(i);
                NativeLib.InvokeWithObject(i);
                NativeLib.InvokeWithIntFast(i);
            }

            // Measure
            int iterations = 10_000_000;
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < iterations; ++i)
                {
                    interop.InvokeWithInt(i);
                }
                sw.Stop();
                Console.WriteLine($"{nameof(InteropInvoker)}.{nameof(InteropInvoker.InvokeWithInt)} - {sw.ElapsedMilliseconds}");
            }
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < iterations; ++i)
                {
                    interop.InvokeWithObject(i);
                }
                sw.Stop();
                Console.WriteLine($"{nameof(InteropInvoker)}.{nameof(InteropInvoker.InvokeWithObject)} - {sw.ElapsedMilliseconds}");
            }
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < iterations; ++i)
                {
                    NativeLib.InvokeWithInt(i);
                }
                sw.Stop();
                Console.WriteLine($"{nameof(NativeLib)}.{nameof(NativeLib.InvokeWithInt)} - {sw.ElapsedMilliseconds}");
            }
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < iterations; ++i)
                {
                    NativeLib.InvokeWithObject(i);
                }
                sw.Stop();
                Console.WriteLine($"{nameof(NativeLib)}.{nameof(NativeLib.InvokeWithObject)} - {sw.ElapsedMilliseconds}");
            }
            {
                var sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < iterations; ++i)
                {
                    NativeLib.InvokeWithIntFast(i);
                }
                sw.Stop();
                Console.WriteLine($"{nameof(NativeLib)}.{nameof(NativeLib.InvokeWithIntFast)} - {sw.ElapsedMilliseconds}");
            }
        }
コード例 #4
0
 public void RegisterCallbacks(Callback_t readCB, Callback_t writeCB, powerCallBack_t reportPower)
 {
     ReturnReadData = readCB;
     WriteDataDone  = writeCB;
     ReportPower    = reportPower;
 }