<< lib/cpu/examples/run-workloads-on-cpus.sleela SLeeLa example: assign resources and run C / C++ / Sleela workloads on CPUs. Shows the uniform contract every CPU in lib/cpu now honors: build an SLCPUResource grant, wrap a source file as an SLWorkload, and hand it to any CPU's runWorkload(). The same program runs identically regardless of source language (C, C++, Sleela) and regardless of which architecture it runs on, because each CPU maps the compiled image onto the canonical opcode substrate. >> #sleela 2.5 material; class RunWorkloadsExample { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10481; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-09"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 7; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } int cOut; int sleelaOut; int crossArchOut; void main() { < A normal-priority grant: 4096 words of memory, a 100k-instruction slice. > SLCPUResource grant = new SLCPUResource(); grant.configure(4096, 100000, grant.PRIORITY_NORMAL); < 1) Run a C workload on a 6502. > SLWorkload cJob = new SLWorkload(); cJob.configure("hello-c", "examples/hello.c", cJob.LANG_C, grant); SL6502CPU mos = new SL6502CPU(); mos.configure(); cOut = mos.runWorkload(cJob); print("C on 6502 -> " + cOut); < 2) Run the equivalent Sleela workload on an ARM, fresh grant. > SLCPUResource grant2 = new SLCPUResource(); grant2.configure(4096, 100000, grant2.PRIORITY_NORMAL); SLWorkload sJob = new SLWorkload(); sJob.configure("hello-sl", "examples/hello.sleela", sJob.LANG_SLEELA, grant2); SLARMCPU arm = new SLARMCPU(); arm.configure(); sleelaOut = arm.runWorkload(sJob); print("Sleela on ARM -> " + sleelaOut); < 3) Same C++ workload on a RISC-V and a PowerPC: cross-architecture, same > < observable result (1:1 Turing effect). > SLCPUResource grant3 = new SLCPUResource(); grant3.configure(4096, 100000, grant3.PRIORITY_HIGH); SLWorkload cppJob = new SLWorkload(); cppJob.configure("compute-cpp", "examples/compute.cpp", cppJob.LANG_CPP, grant3); SLRISCVCPU rv = new SLRISCVCPU(); rv.configure("IM"); crossArchOut = rv.runWorkload(cppJob); print("C++ on RISC-V -> " + crossArchOut + " (used " + grant3.used() + "/" + grant3.budget() + " instructions)"); } }