Shop OBEX P1 Docs P2 Docs Learn Events
Programming Language Converted — Parallax Forums

Programming Language Converted

HumanoidoHumanoido Posts: 5,770
edited 2010-08-19 08:59 in Propeller 1
The operating speed of a programming language can become an issue with some apps. PASM is very fast and SPIN is probably next fastest. There are several languages which can be converted. Which languages rate at the fastest operating speeds when converted? Thank you in advance.

Humanoido

Comments

  • LeonLeon Posts: 7,620
    edited 2010-08-18 13:02
    I'd say that Spin was one of the slower languages for the Propeller. C and Forth will be faster.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-18 13:14
    Check out this compiler benchmark thread here http://forums.parallax.com/showthread.php?t=124168&highlight=compiler+benchmarks&page=5 for some actual measurements with Catlina, Prop BASIC, Zog etc.

    I'd say PASM was fastest Zog is trailing last a bit after Spin. Catalina is quick but big.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-08-18 14:49
    Catalina appears good in ratings. But which languages compile into PASM and run fast?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-18 14:58
    PropBasic compiles into PASM by default. It can compile into LMM as well.

    Catalina compiles into LMM although I think it's using small "overlays" of PASM.

    ImageCraft's C also compiles into LMM. I'm not sure yet whether it's also using small pieces of PASM. I know this was planned, but I don't know whether they implemented it.

    PropForth has its own assembler and programs can consist of a mix of Forth and assembly, but it doesn't actually compile Forth into assembly.

    Regarding Spin vs. Forth or C. It all depends on how you measure it and what's important. Spin is stack-based which adds a cost for execution. Forth is stack-based as well, but can use the stack in a simpler fashion which can produce more speed. C doesn't need a data stack, just a call stack. Spin has some optimizations for local variable use that can make a big difference in code size, but not much difference in execution speed. The current C implementations are, compared to Spin, space hogs. If speed is more important than code size, C or Forth are much better than Spin. If code size is important, Spin may be better to use overall.
  • HumanoidoHumanoido Posts: 5,770
    edited 2010-08-18 15:35
    Mike Green wrote: »
    PropBasic compiles into PASM by default...
    Mike, thank you for the informative details. I'm looking through hundreds of PropBasic postings but didn't see a value, i.e. after compiling into PASM, what percent efficiency (speed mainly) is the compilation relative to writing it directly in PASM? I know a lot of this is subjective (programmers technique) but an average guess would help.

    Another question, is compiled PropBasic considerably faster than SPIN?

    Humanoido
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-08-18 15:39
    Humanoido wrote: »
    Another question, is compiled PropBasic considerably faster than SPIN?

    Humanoido


    Yes. As Mike pointed out, PropBASIC compiles directly to PASM.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-18 16:03
    The question "what percent efficiency ... relative to writing in PASM?" is pretty meaningless. First of all, you can include PASM instructions in a PropBasic program. Some things compile directly into efficient sequences of instructions and some things can be written significantly more efficiently using features of the Prop instruction set that can't be expressed in PropBasic.

    You obviously like to be able to categorize things and to compare things. This is one of those cases where you're comparing "apples" and "oranges". They're both fruit, but you need to be very explicit about the criteria you're using when you attempt to compare them otherwise. "faster" or "smaller" depends too much on the specifics of the situation to make meaningful comparisons. If you use too general a measure, the comparison is useless in any real way.

    Compiled PropBasic would be faster than the equivalent Spin code. On the other hand, there are many things that you could write in Spin, but not in PropBasic, either due to lack of features or (more likely) due to memory constraints when compiling to native Propeller instructions.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-18 16:08
    Is there some reason a SPIN to ASM compiler hasn't been developed?

    Seems like that would offer the best of both worlds - a simple language and the speed of compiled native language run-time executables (instead of being interpreted during run time).

    "Code written in the Spin language is interpreted during run time by a cog running the Spin Interpreter while code written in Propeller Assembly is run in its pure form directly by a cog."
  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-18 16:15
    Ron,
    The main reason (I believe) for not having a Spin to PASM compiler is that the amount of space available in the cog (496 long words) is too small for anything but hand written / hand optimized code or the output of a high quality code optimizer (which is a major undertaking). In addition, a lot of features used heavily in timing dependent code are very hard to handle in an automated code optimizer (like conditional execution or cog synchronization).
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-18 16:27
    Mike,
    That sounds logical - I figured it must be related to size issues.
    Too bad, that approach would take longer to compile but would scream when being executed.
  • jazzedjazzed Posts: 11,803
    edited 2010-08-18 17:13
    ICC and Catalina both use LMM (not PASM overlays unless you mean 1 at a time overlay ;) ). Anything that uses LMM is limited to about 5MIPS.

    SpinLMM is a Spin interpreter that offers an in-line LMM interface for speedup where necessary.

    A threaded LMM that Bill has proposed (similar to pjv's threaded PASM but programs live in HUB). Threaded LMM holds the potential to allow 8*N applications per Propeller (N is arbitrary). No one has reported using it yet, but any language that uses LMM today could potentially implement threaded LMM.

    Cheers.
    --Steve
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-18 17:30
    What exactly is LMM? I can't seem to find any info on it.
    I've only had a Propeller for 3 weeks, so I'm not up on all the technology and lingo...
  • AribaAriba Posts: 2,690
    edited 2010-08-18 18:27
  • jazzedjazzed Posts: 11,803
    edited 2010-08-18 19:53
    What exactly is LMM? I can't seem to find any info on it.
    Sorry about that. Andy's link provides lots of detail.

    In summary, LMM is a way to execute PASM instructions by loading one instruction at a time into a COG.

    Advantages are 1) faster than Spin running from HUB, 2) allows running programs > COG memory size, 3) allows running programs from external memory depending on the hardware being used.

    Drawbacks are 1) slower than PASM - it takes 16 cycles minimum to load an instruction to execute (4 to 5 MIPS @ 80MHz), 2) some instructions must be interpreted (jmp and friends), 3) code is minimum 2x larger than equivalent Spin code depending on language implementation.

    Some languages/platforms depend on other loading methods.

    --Steve
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2010-08-19 08:59
    Andy & Steve,
    Thanks for the explanation. Looks like complicated stuff but I can see that it could be very useful in certain situations.

    The thread from 2006 was impressive with many knowledgeable participants. I noticed that there seemed to be assembler instructions that are not available in the Propeller Tool IDE. I guess they are "masked" or suppressed for various reasons.

    Although I used to write PC assembler programs on IBM/Microsoft DOS computers, I have not programmed code that far "down to the metal".
    My career was higher level languages and technologies like COBOL in the 70' and 80's to SQLServer, VB, Visual Studio and web development before I retired.

    The microcontroller stuff is a lot more fun - but no related paycheck!
Sign In or Register to comment.