Пример #1
0
 public CudaEncoder(CudaModule module)
     : base(module.IntermediateModule, module.TargetData)
 {
     this.Assembly         = module.SourceAssembly;
     this.PtxModule        = module.CompiledModule;
     this.Context          = module.Context;
     this.pendingBuffers   = new List <MirrorBufferPtr>();
     this.allocatedBuffers = new List <CUdeviceptr>();
 }
Пример #2
0
        public CudaDecoder(
            CudaModule module,
            IReadOnlyDictionary <CUdeviceptr, object> existingObjects)
            : base(
                module.IntermediateModule,
                module.TargetData,
                existingObjects.ToDictionary(p => new BoxPointer(p.Key, 0), p => p.Value))
        {
            this.TypeSystem = module.SourceAssembly.Resolver.TypeEnvironment;
            this.Context    = module.Context;

            this.downloadedObjects = new Dictionary <CUdeviceptr, DownloadedBox>();
            this.metadataToType    = new Dictionary <CUdeviceptr, IType>();

            // Map metadata to types.
            foreach (var type in module.IntermediateModule.Metadata.TypesWithMetadata)
            {
                var   meta = module.IntermediateModule.Metadata.GetMetadata(type, module.IntermediateModule);
                SizeT size;
                var   addr = CudaEncoder.GetGlobalAddress(meta, module.CompiledModule, out size);
                metadataToType[addr] = type;
            }
        }