Shop OBEX P1 Docs P2 Docs Learn Events
Question about threads — Parallax Forums

Question about threads

pedwardpedward Posts: 1,642
edited 2012-05-03 00:31 in Propeller 1
I was reading the propeller lib info and had a question about threads.

Will the PropGCC kernel automatically launch threads on unused COGs to help distribute cycles among free COGs?

By definition, if you are using pthreads you assume that the threads can run simultaneously or serially, depending on the architecture.

The way the documentation is written, I am getting the feeling that pthreads run on the COG they are invoked from.

BTW, very nice work. It's clear that most of the PropGCC effort isn't in the compiler, but rather the kernel that implements the runtime interface, eg: XMM, device drivers, pthreads, libc/libm.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2012-04-29 19:17
    pedward wrote: »
    Will the PropGCC kernel automatically launch threads on unused COGs to help distribute cycles among free COGs?

    Yes, using pthreads with LMM mode gives you full SMP (Symmetric Multiprocessing) ability. That is, all threads get evenly distributed across all COGs. However, in XMM modes (XMMC, XMM-SINGLE, XMM-SPLIT), multi-threading is limited to one COG.
    pedward wrote: »
    BTW, very nice work. It's clear that most of the PropGCC effort isn't in the compiler, but rather the kernel that implements the runtime interface, eg: XMM, device drivers, pthreads, libc/libm.

    Thanks.

    Also, I wanted to ask about packaging GCC on your USB key later after General Availability. One of the reasons I started a USB stick design last year was to create a demo/distribution package for Propeller GCC. Maybe we could use yours?

    One thing I added was a couple of QuadSPI flash chips to demo XMMC mode - that design beats everything I've seen so far in performance. Even EEPROM XMMC beats SD Card XMMC performance.

    An alternate XMMC or XMM-SINGLE solution is to use an FRAM chip - FRAM only comes in SOIC-8 though. It's pricey, but competitively priced with other solutions. Assuming you might be interested in that, a GCC special edition might be worth the extra effort/FRAM cost.

    --Steve
  • pedwardpedward Posts: 1,642
    edited 2012-04-29 19:53
    I'm jazzed about the SMP pthreads! ;)

    The only thing that doesn't seem intuitive is creating projects where you mix COG, LMM, and XMMC code in the same project. To take advantage of LMM code, but XMMC for the main body of code. Launch a pthread in LMM, run main code from XMMC, have drivers in COG.

    Yeah, the PropKey makes for a great dev platform for PropGCC. I think a QR code to download the SIDE would go a long way towards getting adoption.

    I tested COG, LMM, and XMMC with EEPROM and SD on the PropKey, all worked well. The PK runs at 96 Mhz, so a little faster than the convention and it has 64KB of EEPROM, though this can be made larger.

    A SIP daughter card would give you some SPI flash, since power an the P31-P20 are on the same side of the board.

    The SD card pins are brought out too, so you could hang SPI off of those pins too.
  • pedwardpedward Posts: 1,642
    edited 2012-04-29 20:10
    The biggest EEPROM I could find is 128KB, not a whole lot better than 64K.
  • jazzedjazzed Posts: 11,803
    edited 2012-04-29 20:28
    pedward wrote: »
    The biggest EEPROM I could find is 128KB, not a whole lot better than 64K.

    Actually that makes a difference. We can use up to about 124KB of a 128KB part for programs. ST makes a 256KB part.

    I was going to ask you if you could squeeze in a couple of SOIC8 QuadSPI chips for 4MB+ Flash, but figured you didn't need such a distraction or wouldn't have room. I've done this on a board already, but need to change to the SSOP16 FTDI chip. My fingers are too fat for QFN.
    pedward wrote: »
    The only thing that doesn't seem intuitive is creating projects where you mix COG, LMM, and XMMC code in the same project. To take advantage of LMM code, but XMMC for the main body of code. Launch a pthread in LMM, run main code from XMMC, have drivers in COG.

    The way it's done now is: set the memory model to XMMC, put LMM code into HUBTEXT sections, and add COG C code in foo.cogc (or use PASM in a .spin file). Add files to the project and build with the hammer.
  • pedwardpedward Posts: 1,642
    edited 2012-04-29 21:39
    How about a piggy back with room for SPI flash and SPI RAM?

    Will PropGCC use SPI ram effectively in this scenario?

    I can easily make a little board that plugs on top, that has flash. The XMMSIP it could be called.

    If you wanted 8 bit SPI, P20-P27 are free, it would be a 16 pin SIP module that plugged vertically on the right side of the board.

    You could steal the clock line for I2C or perhaps the SD card. Too bad a CS wastes a pin.
  • pedwardpedward Posts: 1,642
    edited 2012-04-29 22:11
    I found a Ramtron FRAM part that is a direct replacement for the I2C EEPROM, and it runs at 3.4Mhz. Cost is $12.70 ea, but would allow a bit of leeway. The size is 128KB.

    LOL, that said, I can make a daughter board and put memory on that for less than the cost of the FRAM.

    How does 16MB of dual qSPI flash sound? The chips are around ~$3.75 each, initial estimates would be $25 assembled I think.

    http://media.digikey.com/pdf/Data Sheets/Winbond PDFs/W25Q64FV.pdf

    The part above supports QPI, so you can transmit the commands 4 bits at a time, which should help with XMMC a lot, they specifically callout XIP as something that can benefit. XIP and XMM are the same thing basically.
  • jazzedjazzed Posts: 11,803
    edited 2012-04-30 06:59
    We already have functional XMMC cache drivers for quad-spi parts. One uses 2 pieces of W25Q on P0..7 for best performance. Another allows a single W25Q device to be used anywhere on 4 consecutive data pins (slower but more flexible). We also have a driver for a single SST device on any 4 consecutive data pins. W25Q parts are about $1 each for 2MB and are generally available. SST parts are slightly faster, more expensive, are not generally available, and can not be used in single-bit SPI mode. W25Q parts are usable in single-bit SPI mode.

    If you want to make an adapter board for QuadSPI it's ok by me. I may revive my design from last year with the new SSOP16 FTDI part since it would be cheaper.

    FRAM as you note would be a drop-in replacement for existing EEPROM, and a new driver would be used for speed. Some folks think it could also be used like an SRAM for XMM-SINGLE mode. I cringe at the price, but it has some utility.

    Thanks,
    --Steve
    pedward wrote: »
    I found a Ramtron FRAM part that is a direct replacement for the I2C EEPROM, and it runs at 3.4Mhz. Cost is $12.70 ea, but would allow a bit of leeway. The size is 128KB.

    LOL, that said, I can make a daughter board and put memory on that for less than the cost of the FRAM.

    How does 16MB of dual qSPI flash sound? The chips are around ~$3.75 each, initial estimates would be $25 assembled I think.

    http://media.digikey.com/pdf/Data Sheets/Winbond PDFs/W25Q64FV.pdf

    The part above supports QPI, so you can transmit the commands 4 bits at a time, which should help with XMMC a lot, they specifically callout XIP as something that can benefit. XIP and XMM are the same thing basically.
  • pedwardpedward Posts: 1,642
    edited 2012-04-30 15:04
    I can push the release of the PropKey to design a qSPI chip into it, but I think a daughter board would be a more appropriate solution.

    As it stands, I have to order about 75 boards for a general release, and I have to get the order in May 14th, which is cutting it close from the time I'll get the latest release candidate back.

    I will design a daughter board, and depending on the demand for it, I can incorporate the FLASH and new FT230X/FT231X into version 1.2.
  • jazzedjazzed Posts: 11,803
    edited 2012-04-30 15:23
    Sounds good. Don't let me get in your way. I'll support whatever you decide.

    pedward wrote: »
    I can push the release of the PropKey to design a qSPI chip into it, but I think a daughter board would be a more appropriate solution.

    As it stands, I have to order about 75 boards for a general release, and I have to get the order in May 14th, which is cutting it close from the time I'll get the latest release candidate back.

    I will design a daughter board, and depending on the demand for it, I can incorporate the FLASH and new FT230X/FT231X into version 1.2.
Sign In or Register to comment.