public CArray(int n, EType type, EMemorySpace side, CModel model, string name) { alloc(n, type, side, model); _model = model; _suballocated = false; _number_of_internal_buffers = 0; _internal_buffer_pointers = null; _name = name; }
public CArray(CArray buf, uint offset_in_bytes, int sz, CModel model, string name) { if (buf == null) throw new System.Exception(); if (sz > buf._sz - offset_in_bytes) throw new System.Exception(); this._ptr = buf._ptr + offset_in_bytes; this._length = 0; this._sz = sz; this._side = buf._side; _model = model; _suballocated = false; _number_of_internal_buffers = 0; _internal_buffer_pointers = null; _name = name; }
public VanillaPayoffEvaluator(CModel model, double s) { numBatches = model.mcplan._nbatches; numScenPerBatch = model.mcplan._nscen_per_batch; lastStep = model.mcplan.nk - 1; gridMap = model.grid.host_d_xval_y; strike = s; results = new double[numBatches * numScenPerBatch]; }
private void alloc(int n, EType type, EMemorySpace side, CModel model) { if (n == 0) return; if (_model == null) { _model = model; } else { if (_model != model) throw new System.Exception(); } this._type = type; this._side = side; if (_sz == 0) { if (side == EMemorySpace.device) { if (_suballocated) throw new System.Exception(); _ptr = opcuda_mem_alloc((uint)(Size_of_one * n)); } else { if (_suballocated) throw new System.Exception(); _hptr = opcuda_mem_alloc_host((uint)(Size_of_one * n)); } int status = opcuda_get_status(); if (status != 0) throw new System.Exception(); _length = n; _sz = Size_of_one * n; return; } if (_sz < Size_of_one * n) { if (side == EMemorySpace.device) { if (_suballocated) throw new System.Exception(); opcuda_mem_free_device(ptr); _ptr = opcuda_mem_alloc((uint)(Size_of_one * n)); } else { if (_suballocated) throw new System.Exception(); opcuda_mem_free_host(hptr); _hptr = opcuda_mem_alloc_host((uint)(Size_of_one * n)); } int status = opcuda_get_status(); if (status != 0) throw new System.Exception(); _sz = Size_of_one * n; _length = n; return; } _length = n; }
private CArray(CModel model) { _model = model; _suballocated = false; _number_of_internal_buffers = 0; _internal_buffer_pointers = null; }
public static void alloc(ref CArray buf, int n, EType type, EMemorySpace side, CModel model, string name) { if (buf == null) { buf = new CArray(n, type, side, model, name); return; } if (buf._suballocated) throw new System.Exception(); if (buf.sz < n * sizeof_type(type)) { if (model != buf._model) throw new System.Exception(); buf = new CArray(n, type, side, model, name); return; } if (model != buf._model) throw new System.Exception(); }