• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Alternative way of getting the column in a list

Stats

  • Locked Locked
  • Replies 16
  • Subscribers 144
  • Views 19947
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Alternative way of getting the column in a list

essej
essej over 11 years ago
I have a function that gets the columns in an assoc list. Its working fine except for the very large size of list around 10 million. I gets a huge memory allocated when I profiled it.

procedure(getColSub(col lList)
  if(onep(length(col)) then
    case(car(col)
      (0 mapcar('car lList))
      (1 mapcar('cadr lList))
      (2 mapcar('caddr lList))
      (3 mapcar('cadddr lList))
      (t mapcar('nth vectorToList(makeVector(length(lList) car(col))) lList))
    )
  else
    mapcar('nth col vectorToList(makeVector(length(col) lList)))
  )
)

Example:
lList=list(list("a" 1) list("b" 2))
col=list(1 0) , gives ((1 "a")(2 "b"))
col=list(1) , gives (1 2)
  • Cancel
  • tweeks
    tweeks over 11 years ago

    Well, you can reduce memory by using vectors or tables instead of lists, and doing the rearrangements in-place.... 

    Optimizing SKILL performance can be tricky because it's usually not obvious how much memory or time various operations use (this is the whole point of using SKILL over C: memory usage is invisible).  You need to have some sense of what the interpreter is doing behind the scenes in order to make good choices.  Doing experiments with the profiler will show you how much various operations cost.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • tweeks
    tweeks over 11 years ago

    We could probably give you better advise if you described what problem you are trying to solve.  What are you making columns of?  Why are you arbitrarily rearranging them?  Are you writing your own sort?  That would be very inefficient. :)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • essej
    essej over 11 years ago

    Im just getting an items in a list. No sorting. Your solution looks good compared to my existing function.

    It gives only this, than mine which is still running. I'll do more testing.. Thanks a lot

    Function Name                        Total   Inside
    -------------                        -----   ------
    TOTAL (Memory Allocated)           7214600  7214600 bytes
    toplevel                           7214600      336
    getColumns                         7200440      368
    mapcar                             7200072  2400024
    list                               4800288  4800288

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • tweeks
    tweeks over 11 years ago

    You're welcome!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 11 years ago

    tweeks said:
    An assoc list is usually a list of pairs, so you can ask for the keys (the first element), or the values (the second element), but asking for the 3rd, 4th, nth element doesn't make sense, because there are only two (right?)

     

    A mild aside on this. I quite often have assoc lists which have more than one element in the sublist (that said, I don't use assoc lists  for large amounts of data, because they are not efficient to look stuff up in, because you have to search them sequentially). One example trick I use sometimes is this:

    data='(
     ("sourceMet" type "rect" layer "Metal1" width 0.5)
     ("gate" type "path" layer "Poly" width 0.2)
     ("drainDiff" type "rect" layer "diffusion" width 0.6)
    )

    then I can do:

    assoc("gate" data)->layer

    which returns "Poly". So each list in the assoc list is a disembodied property list. Often DPLs have nil as the first element, but they don't have to - you can use any value there. So conveniently I'm using that part of the DPL as my key in the assoc list.

    Not really relevant to the discussion in this thread, but thought I'd throw this little idiom into the conversation!

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • tweeks
    tweeks over 11 years ago

    Thanks Andrew!  This is the first time I've seen that idiom. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
<

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information