Пример #1
0
 public void UpdatePerformanceRecord(CoreGenDescription desc, PerformanceRecord prec)
 {
     using (var conn = Connect())
     {
         EnsureCreateTable(conn, desc);
         if (QueryPerformanceRecord(conn, desc) == null)
         {
             InsertPerformanceRecord(conn, desc, prec);
         }
         else
         {
             UpdatePerformanceRecord(conn, desc, prec);
         }
     }
 }
Пример #2
0
        public static string GetSql_UpdateRecord(this CoreGenDescription desc, PerformanceRecord prec)
        {
            Contract.Requires(desc != null);
            Contract.Requires(prec != null);
            if (desc.SelectCommand == null)
                throw new InvalidOperationException("no select command");

            var sb = new StringBuilder();
            sb.Append("UPDATE ");
            sb.AppendLine(desc.GetSql_TableName());
            sb.Append("SET ");
            var prprops = typeof(PerformanceRecord).GetProperties();
            var values = new List<string>();
            foreach (var pi in prprops)
            {
                values.Add(pi.Name + "=" + WrapSqlValue(pi.GetValue(prec, new object[0])));
            }
            sb.AppendLine(string.Join(", ", values));
            sb.Append("WHERE ");
            var keys = new List<string>();
            foreach (var setcmd in desc.SetCommands)
            {
                keys.Add(setcmd.AttrName + "=" + WrapSqlValue(setcmd.AttrValue, setcmd.CILType));
            }
            foreach (var csetcmd in desc.CSetCommands)
            {
                keys.Add(csetcmd.AttrName + "=" + WrapSqlValue(csetcmd.AttrValue, csetcmd.CILType));
            }
            sb.Append(string.Join(" AND ", keys));
            sb.AppendLine(";");
            return sb.ToString();
        }
Пример #3
0
 private void UpdatePerformanceRecord(SQLiteConnection conn, CoreGenDescription desc, PerformanceRecord prec)
 {
     var cmd = conn.CreateCommand();
     cmd.CommandText = desc.GetSql_UpdateRecord(prec);
     if (cmd.ExecuteNonQuery() < 0)
         throw new IPDatabaseException("unable to update performance record");
 }
Пример #4
0
 private PerformanceRecord QueryPerformanceRecord(SQLiteConnection conn, CoreGenDescription desc)
 {
     var cmd = conn.CreateCommand();
     cmd.CommandText = desc.GetSql_QueryRecord();
     var reader = cmd.ExecuteReader();
     if (reader.Read())
     {
         var result = new PerformanceRecord();
         var props = typeof(PerformanceRecord).GetProperties();
         foreach (var pi in props)
         {
             object value = SqlCommands.UnwrapSqlValue(reader[pi.Name], pi.PropertyType);
             pi.SetValue(result, value, new object[0]);
         }
         return result;
     }
     else
     {
         return null;
     }
 }
Пример #5
0
 public static void UpdateCache(Component core, PerformanceRecord prec)
 {
     string className = GetClassName(core);
     var coreData = LoadIPCoreData(className);
     if (coreData == null)
     {
         coreData = new IPCore()
         {
             className = className,
             generator = "",
             variants = new IPCoreVariant[0]
         };
     }
     var paramSet = ExtractPerformanceParameters(core);
     var coreVar = LookupVariant(coreData,
         prec.Device.ToString(),
         prec.SpeedGrade.ToString(),
         prec.ISEVersion.ToString(),
         paramSet);
     var rlist = new List<IPCoreVariantResource>();
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.SliceRegisters, EPropAssoc.PARReport),
         amount = prec.SliceRegisters
     });
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.SliceLUTs, EPropAssoc.PARReport),
         amount = prec.SliceLUTs
     });
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.OccupiedSlices, EPropAssoc.PARReport),
         amount = prec.OccupiedSlices
     });
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.RAMB18s, EPropAssoc.PARReport),
         amount = prec.RAMB18s
     });
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.RAMB36s, EPropAssoc.PARReport),
         amount = prec.RAMB36s
     });
     rlist.Add(new IPCoreVariantResource()
     {
         name = PropEnum.ToString(EDeviceResource.DSP48E1s, EPropAssoc.PARReport),
         amount = prec.DSP48E1s
     });
     if (coreVar == null)
     {
         coreVar = new IPCoreVariant()
         {
             deviceName = prec.Device.ToString(),
             iseVersion = prec.ISEVersion.ToString(),
             package = "",
             speedGrade = prec.SpeedGrade.ToString(),
             timestamp = DateTime.Now,
             minPeriod = prec.MinPeriod.ScaleTo(ETimeUnit.ns),
             parameters = paramSet.ToArray()
         };
         coreData.variants = coreData.variants.Concat(new IPCoreVariant[] { coreVar }).ToArray();
     }
     coreVar.consumedResources = rlist.ToArray();
     string path = GetIPCoreDataPath(className);
     using (var wr = new StreamWriter(path))
     {
         IPCoreDataSerializer.Serialize(wr, coreData);
         wr.Close();
     }
 }
Пример #6
0
 public static PerformanceRecord QueryIPCorePerformance(Component core, EDevice device, ESpeedGrade speedGrade, EISEVersion iseVersion)
 {
     string className = GetClassName(core);
     var coreData = LoadIPCoreData(className);
     if (coreData == null)
         return null;
     var paramSet = ExtractPerformanceParameters(core);
     var coreVar = LookupVariant(coreData,
         device.ToString(),
         speedGrade.ToString(),
         iseVersion.ToString(), 
         paramSet);
     if (coreVar == null)
         return null;
     var result = new PerformanceRecord()
     {
         Device = device,
         SpeedGrade = speedGrade,
         ISEVersion = iseVersion,
         MinPeriod = new Time(coreVar.minPeriod, ETimeUnit.ns)
     };
     foreach (var resrec in coreVar.consumedResources)
     {
         EDeviceResource res;
         if (DeviceResources.ResolveResourceType(resrec.name, out res))
         {
             result.AssignResource(res, resrec.amount);
         }
     }
     return result;
 }
Пример #7
0
        private void UpdatePerformanceRecord(SQLiteConnection conn, CoreGenDescription desc, PerformanceRecord prec)
        {
            var cmd = conn.CreateCommand();

            cmd.CommandText = desc.GetSql_UpdateRecord(prec);
            if (cmd.ExecuteNonQuery() < 0)
            {
                throw new IPDatabaseException("unable to update performance record");
            }
        }