Shop OBEX P1 Docs P2 Docs Learn Events
Random question: why is COGID a hubop? — Parallax Forums

Random question: why is COGID a hubop?

agsags Posts: 386
edited 2013-08-20 13:49 in Propeller 1
Long stream of consciousness led me to this as I am updating another thread. Understanding that there really is just one HUBOP instruction (one opcode for all 8 hub operations, with the assembler kindly providing "aliases" that set the correct src value for each of the 8 options) - why is COGID a hubop at all? Each cog is a unique physical core - why does the hub need to be involved in returning the three-bit value that is unique to each cog?

Just wondering.

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2013-08-20 08:46
    My guess would be that since all the COGs are identical hunks of silicon, they really have no way of knowing their identity. They are just a COG that can talk to the HUB. The HUB is the only place they have a unique identity because it needs to know for the management it does. Just like HUB being the keeper/manager of the locks.
  • agsags Posts: 386
    edited 2013-08-20 08:52
    Could be. But it would be trivial for each cog to not be identical. It's just one mask layer affected to enable each to know it's own name (id).
    It may also be that this would be such a different operation compared to all other instructions that it would take a lot of other changes to support. But it seems possible theoretically, and I would guess there is a very good reason for it.
  • AribaAriba Posts: 2,690
    edited 2013-08-20 09:22
    I guess it it was the simplest way to provide the instruction without wasteing a full opcode with source and destination fields.
    The speed of COGID is not that important, and you can execute it once after cog start and hold the ID in a register.

    You can also use COGID to synchronize the code to the hubslots of the cog, without modifying anything in hubmemory,locks or other cogs.

    Andy
  • ericballericball Posts: 774
    edited 2013-08-20 09:27
    I suspect Rick is correct - the cogs don't care what index they are. But the hub has to care for the coginit hubop. So since the hub has to care but the cog doesn't then it make sense to put the cogid opcode logic into the hub rather than the cog.
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 09:32
    That is a deep philosphical question.
    How do you know who you are without asking everyone else?
    We are not born with our names or social security numbers or whatever engraved in our souls.
    Why should a COG be different?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-08-20 09:36
    Heater. wrote: »
    That is a deep philosphical question.
    How do you know who you are without asking everyone else?
    We are not born with our names or social security numbers or whatever engraved in our souls.
    Why should a COG be different?

    Just wanted you to know that I nearly snarfed my water while reading your reply. Please include snarf warnings in the future! :tongue:
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-08-20 09:50
    Heater. wrote: »
    That is a deep philosphical question.
    How do you know who you are without asking everyone else?
    We are not born with our names or social security numbers or whatever engraved in our souls.
    Why should a COG be different?

    This could be the best Heaterism ever!!
  • agsags Posts: 386
    edited 2013-08-20 10:03
    Heater. wrote: »
    That is a deep philosphical question.
    How do you know who you are without asking everyone else?
    We are not born with our names or social security numbers or whatever engraved in our souls.
    Why should a COG be different?

    Another perspective is that every one of us knows our name innately. It roughly translates to "me". There is only an issue when we have to interact with others. Then we have to publish and agree on them. Same thing here. Devices all innately known their MAC address; they must be assigned an IP address.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-08-20 11:07
    I seem to have read somewhere in the Propeller Manuals that there is one teeny-tiny 8 bit register that exists physically in the hub to manage all this... including the Locks.

    Is this real, or am I once again imagining things?

    Be wary of MAC addresses... very easy to clone in Linux and to travel under a false flag.
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 11:46
    Good grief what happened here?

    @Chris,
    ...snarfed my water...
    As an English guy with little understanding of American I can only try to guess what that means:
    Did you pee your pants?
    Did you choke on your mineral water?

    Google translate is not helping here. Seems like an over-reaction to a slightly sideways look at things anyway.

    @mindrobots.
    ...Heaterism...
    I did not know there were such things. I'll try to live up to them in future:)

    @ags,
    ...every one of us knows our name innately. It roughly translates to "me".
    Did I say this was philosophical? In the absence of anyone else why would I think of having a name? There is no need for one. I might not even realize that there is a "me".
    There is only an issue when we have to interact with others.
    Exactly.
    Devices all innately known their MAC address.
    I know what you mean. But not me, my "MAC address" was strapped to my wrist in the maternity ward. Similarly in the computer world MAC addresses belong to external things like network cards, they are assigned by an external authority, and thank God I can change them if I want.
  • dnalordnalor Posts: 222
    edited 2013-08-20 12:26
    Heater. wrote: »
    Good grief what happened here?

    @Chris,

    As an English guy with little understanding of American I can only try to guess what that means:
    Did you pee your pants?
    Did you choke on your mineral water?

    Google translate is not helping here. Seems like an over-reaction to a slightly sideways look at things anyway.

    But google finds everything:
    http://en.wiktionary.org/wiki/snarf -> To expel fluid or food through the mouth or nostrils accidentally, usually while attempting to stifle laughter with one's mouth full.
  • photomankcphotomankc Posts: 943
    edited 2013-08-20 12:33
    Heater. wrote: »
    That is a deep philosphical question.
    How do you know who you are without asking everyone else?
    We are not born with our names or social security numbers or whatever engraved in our souls.
    Why should a COG be different?

    [golf clap]
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 12:45
    @dnalor,

    It's hard work. I only got as far boring stuff like:
    snarf - To eat or drink rapidly or eagerly; devour:
    snarf - to acquire for onesself, with little concern for social norms, but not quite by stealing.

    @photomanks
    [golf clap]
    Ouch, there is another one. A phrase with so many meanings...
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-08-20 12:49
    Heater. wrote: »
    [golf clap]

    Ouch, there is another one. A phrase with so many meanings...

    Would [soccer hooligan head butt] fit better?? :lol:
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 12:51
    Now, back to that COGID thing.

    Why do we ever need to know or care about the ID of a COG that is doing work for us?
    Like slaves back in the day we don't care which one does the job as long as it gets done.

    On the other hand why does a COG ever need to know it's ID.
    It only has to do what it has been told and keep quite otherwise.

    And so, who cares how long it takes a COG to find it's ID? They never should do that.
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 12:57
    mindrobots,
    Would [soccer hooligan head butt] fit better??
    Wid that be a glescae winch yer talking aboot?
  • dnalordnalor Posts: 222
    edited 2013-08-20 13:09
    Heater. wrote: »
    Wid that be a glescae winch yer talking aboot?

    That's not fair! Should I write something bavarian. ;-)
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-08-20 13:13
    Heater. wrote: »
    mindrobots,

    Wid that be a glescae winch yer talking aboot?

    I love it! Google found me a Glaswegian dictionary!!
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 13:16
    dnalor,
    That's not fair! Should I write something bavarian.
    That's was the Queens English as spoken by her humble subjects. What's the problem?
  • photomankcphotomankc Posts: 943
    edited 2013-08-20 13:20
    Heater. wrote: »
    Now, back to that COGID thing.
    On the other hand why does a COG ever need to know it's ID.
    It only has to do what it has been told and keep quite otherwise.
    And so, who cares how long it takes a COG to find it's ID? They never should do that.

    This is what I'm thinking. I suppose there could be corner cases where how close a cog is to the IO lines might be at issue and I'm certainly not proficient enough to be delving into it to that level anyway but the cog can't launch itself anyway so I can't even see why it needs to know that then. The rest of the time what cog is actually doing the work is irrelevant. The only thing I have ever really needed is of course the supervisor program to know which cog to stop if loading and unloading dynamically. I can see no need to dedicate silicon to it or make it lightning fast even in a case where knowing it proved necessary.


    Golf Clap in this scenario is a 'well played sir'.
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 13:31
    photomankc,

    That's how I'm looking at it.

    So the question is not "Why is cogid a slow hubop?" But rather "Why is there a cogid instruction at all?"

    That opcode space could perhaps have been used for something useful.

    What are we missing here?
  • agsags Posts: 386
    edited 2013-08-20 13:36
    Heater. wrote: »
    Good grief what happened here?
    I think I asked a valid question. It is interesting to me at least, I can say that much. It seems I, and others, enjoyed your philosophical reply.
    Did I say this was philosophical?
    Yes, and I understood. I did not think it necessary to restate.
    I know what you mean. But not me, my "MAC address" was strapped to my wrist in the maternity ward. Similarly in the computer world MAC addresses belong to external things like network cards, they are assigned by an external authority, and thank God I can change them if I want.

    So let me not be so vague, and back to the (technical) question. The cogid instruction exists. Its behavior is that it will provide a cog with it's unique ID. I agree that I see no criticality regarding the speed of this operation in any use I can think of (but I don't think of everything). No cog can determine another cog's ID through a single instruction. So if a cog can only ask its own ID, why involve the hub?

    A better analogy than MAC/IP address could be DNA: a "creator" (please, let's not let this thread wander there philosophically) - let's arbitrarily assign a name to this non-deity, something like... "Chip" - could create a bunch of entities that are all exact clones. Only Chip could tell them apart. That appears to be what has happened. Every time one of the creations is curious about its name, it has to ask Chip. Doesn't Chip have other things to better spend his time with? An alternative is to make each creation just the slightest bit different, just enough so that its DNA is not 100% identical to any other. Chip can decide what that difference is, and make sure that he doesn't allow any two DNA sequences to be identical. He could even do so in such a way there was an order to the difference. Then, if for some reason (whether good or bad reason - it's about the instruction existing, not its utility) if any one of the creations want to know its name, it can just look. Chip can continue doing other more important things.

    Presuming that Chip is an intelligent and thoughtful creator, I am wondering if anyone can elaborate on why Chip decided on the former strategy (or could disabuse me of an incorrect presumption). Maybe it was because final verification, or just handling the mask data, was made easier by having 8 exact instances (although I doubt there wasn't some cover cell over the entire chip which could have supported this). Maybe the idea of a cogid wasn't originally planned, and it was easier to modify the hub to provide this rather than the cog processors. Maybe the connections from hub to cog are not direct but switched, and it has to have an address to communicate (doubtful). I can only guess, and wonder what the real reason is.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-08-20 13:38
    Cogs need to find out their ID because there are several instructions that depend on that. COGSTOP and COGINIT in particular come to mind. The first because one cog may need to stop another which it or some other cog may have started. This is dealth with most occasions by COGNEW returning the ID of the cog started. COGINIT(COGID,...) is used when a program wants to launch a fresh cog contents using its own cog. Another case is in a loader where a program is to be replaced entirely with a new program except for one or more cogs running some set of I/O drivers. Programs like FemtoBasic and Spinix and Sphinx use this to stop everything but specific I/O cogs and the currently executing cog (which gets restarted with COGINIT(COGID,...)).

    Since some of the other COGxxx instructions clearly use the hub mechanism, it makes sense to group things like COGID with them rather than separating it out.
  • agsags Posts: 386
    edited 2013-08-20 13:46
    Just to be clear: If you go back to OP, the question was never "why is cogid a slow hub operation", it was simply "why is cogid a hub operation (at all)".

    Also, I do use cogid for exactly the (bootloaderj) scenario Mike Green offers. I absolutely need to uniquely identify cog instances.

    It's not about if the cogid instruction should exist, or be used, or be fast. I am only asking why was it made a hub operation.
  • Heater.Heater. Posts: 21,230
    edited 2013-08-20 13:49
    Mike,

    Thank goodness you turned up. The voice of reason.

    Actually, now that you mention it, I think I have even used COGID in a ZOG loader so that a cog can commit suicide after starting up whatever it was loading.
Sign In or Register to comment.