2013年2月10日 星期日

SystemC TLM2.0 notes

TLM2.0 key notes

  • byte enable
  • endianness
  • generated payload (TRS)
  • extension generated payload(transaction ID)
  • socket base transaction
  • transaction traceback (watch monitor)
  • score board recorder 
  • assertion 
  • coverage  
  • b_transaction(blocking)[LT]
    • no direction
    • wait
    • no method sensitive 
    • no pipe
    • no phase
    • no life time
  • nb_transaction(noblocking)[APT](phase),
    • nb_transaction_fw(forward) / nb_transaction_bw(backward)
    • no wait
    • method/thread sensitive
    • pipe
    • phase (req_bg/ed, data_bg/ed, resp_bg/ed) 
    • life time
  • modify 
    • target    (response pp, extension pp)
    • initiator (address, command, data, pp)
    • interconnect (address, extension pp)
  • notify
    • .notify() to switch event and reschedule event lists 
  • free/release pp(pp memory manager)
    • free pp by life time 
  • DMA(direct mem access)
  • data pointer / shared pp deep shadow copy
  • interface (analysis_interface, debug_interface)
  • socket 

LT(loosely time), APT(approximate time), CAT(cycle accurate time)
Tl3(packetize), Tl2(transaction level), Tl1(adaptor Tl1toTl2, Tl2toTl1), Tl0(pin level assign)
TRS (transaction)
carbon design AXI TLM2.0
greensoc OCP TLM2.0




2013年2月7日 星期四

Python with HighPerformance


最近在讀 high performance python, 底下就隨手記錄一下吧...XD
  • test env
    • MacBook 2.0GHz with 4GB RAM. The GPU is a 9400M

    •  
      • pypy(JIT) > pure python (~6times)
      • cython(move math(complex) part to c) > pure python (1.5~30times)
      • numpy(matrix vector) > pure python(30times) 
      • shedskin(python 2 c++ compile) > pure_python(30times)
    • PyCUDA(real hardware multi cores(DSP)) > numpy(CPU 50times)  


  • using cprofile and dis to trace back where is the performance bottleneck 
    • python -cprofile  
      • @profie decorader in each proc call 
    • python dis.dis(function call) 
      • trace byte code linse, macro blocks, where to improve 
    • serialize code
      • data store in cache > store in memory   
    • RunSnakeRun
      • GUI tool(cprofile results)
  • Multiprocessing: parallel process to multi cores(CPUS)
  • pypy: JIT(just in time) compiler, llvm, byte code optimization, rpython(.Net), cython 
  • numpy: N dimension array vector to one dimension vector array(serialize memory access)
  • cpython: pre-compile python to having object type(int,char...) 
  • PyCUDA: hardware speed up (DSPs)
tips
  • a = {} >  a = dict()
  • "".join(st) > st = "a" + "b" + "c"
  • [i.upper() for i in test] > for i in test: arr.append(i.upper())
  • def test() > global test ...
  • init dict > without init dict
  • pre load(import modules in header) > current load(import modules in middle)
  • reduce the call back counts 
  • xrange > range
  • remap func without recursive loops
  • hash(heap map) > loop searching  

ref:
EuroPython2011_HighPerformanceComputing
performance tips
timecomplex

python + google GAE + checkIO


底下用就用 checkIO ATM + Google GAE(guestbook) 來當今天的玩具好了. 主要改寫 checkIO ATM 的 input/output parts 跟 GAE 的 db handle 部分. 除了可以練習一下 GAE,也可以玩 checkIO 裡的習題.

input   : Web text form
output : results



def checkio_atm(data):
    try:
        data = str(data).replace(' ','').replace('[','').replace(']','')
 datas = [int(d) for d in data.split(",")]
 balance, withdrawal = datas[0], datas[1:-1]
 for a in (0.5 + 1.01*it for it in withdrawal if it %5 ==0):
    balance = floor(balance - a) if balance > a else balance
    return "input = %s, rst = %s" %(data,str(balance))
    except:
     return "CheckIO ATM Error"
GAE key notes
Html key notes
  • css 
  • html embedded query  

project download