{"id":15289153,"url":"https://github.com/jsyiek/parallang","last_synced_at":"2025-09-11T07:40:31.612Z","repository":{"id":239177856,"uuid":"798789141","full_name":"jsyiek/parallang","owner":"jsyiek","description":"Scalable parallel computer simulator","archived":false,"fork":false,"pushed_at":"2024-06-21T23:49:43.000Z","size":47591,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T09:46:31.125Z","etag":null,"topics":["concurrency","dsl","parallang","parallelism","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsyiek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T13:27:59.000Z","updated_at":"2024-06-21T23:49:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"8e683b3c-abe2-4b6f-842a-9683149986db","html_url":"https://github.com/jsyiek/parallang","commit_stats":null,"previous_names":["jsyiek/parallang"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsyiek/parallang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsyiek%2Fparallang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsyiek%2Fparallang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsyiek%2Fparallang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsyiek%2Fparallang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsyiek","download_url":"https://codeload.github.com/jsyiek/parallang/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsyiek%2Fparallang/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274596017,"owners_count":25314021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","dsl","parallang","parallelism","scala"],"created_at":"2024-09-30T15:59:26.099Z","updated_at":"2025-09-11T07:40:31.584Z","avatar_url":"https://github.com/jsyiek.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Parallang Simulator\n\n## What is this?\n\nThe *Parallang Simulator* is a scalable platform-independent solution to simulate parallel message-passing algorithms and evaluate their relative costs. \n\n*Key features*:\n- **Parallang DSL**: The simulator is equipped with a strongly typed interpreted programming language with a C-like syntax called Parallang. Parallang is a portmanteau of \"parallel\" and \"language.\"\n- **Messages**: Through simple `send x -\u003e worker i, j` and `recv x \u003c- worker i, j` instructions, parallel algorithms on the simulator can send messages between processors. Message forwarding is implicitly performed, and the costs are modeled.\n- **Data cache model**: The simulator can use an arbitrary user-specified data cache hierarchy. Programmed replacement strategies include LRU, tree-PLRU, and NLU.\n- **Latency and memory estimates**: The system estimates running time and tracks memory usage throughout program execution, providing the user with this information at the end.\n- **Communication environments**: A modular parameter set system can define communication costs, modeling anything from a multicore system-on-chip to a platform distributed over the internet.\n- **Events system**: Latency and memory are tracked through *events* emitted throughout program execution. Users can add real-time event listeners to process these and gauge metrics of interest.\n- **Output visualization and graph compression**: Several Jupyter Notebooks provide *graph compression* and *evaluation graph* functionality to visualize the simulator's output.\n\n## What is a parallel algorithm?\n\nTo answer this, let's define the *parallel computer abstraction*. Conceptually, a parallel computer is a group of *processing elements* (PEs) linked together in a *message-passing topology*. Each PE executes a sequential algorithm independently and may send *data* directly to any connected PEs during execution: we call this a message. \n\nA *parallel algorithm* is any algorithm that uses some coordination technique, such as message-passing, to distribute computation tasks over PEs and achieve higher aggregate performance than its sequential counterpart. \n\n## Tutorials\n\nThese tutorials assume you have a *Parallang program* you want to run. If you do not, write one! See the sample code below and in `src/main/parallang`.\n\n### Defining a simple simulation: a bus topology\n\nA simulation is defined in Scala using a straightforward API. Before any simulation, you must set the number of PEs and define the connections. PEs are assumed to be arranged in a 2D grid for ease of use.\n\n```scala\nimport uk.ac.cam.crsid.Parallang.Interpreter.CommunicationModel.InterconnectionNetwork\n\nobject TutorialSimulation {\n    def main(args: Array[String]): Unit = {\n        val pathToProgram = ...\n\n        // Set up a 10x1 topology: a bus!\n        InterconnectionNetwork.resetLengthWidth(10, 1)\n        for (i \u003c- 0 until 9) {\n            InterconnectionNetwork.addLink((i, 1), (i+1, 1))\n            InterconnectionNetwork.addLink((i+1, 1), (i, 1))\n        }\n\n        InterconnectionNetwork.launchWith(pathToProgram)\n    }\n}\n```\n\n### Changing the parameter set\n\nBy default, the Parallang Simulator uses the `MulticoreComputer` parameter set. Other parameter sets, such as `Datacenter` or `HighPowerInternet`, can be used. Users may also define their own by extending the `LatencyParameterSet` trait.\n\n```scala\nimport uk.ac.cam.crsid.Parallang.Interpreter.CommunicationModel.{InterconnectionNetwork, HighPowerInternet}\n\nInterconnectionNetwork.setLatencyParameterSet(HighPowerInternet)\n```\n\n### Defining an event listener\n\nTBD\n\n### Defining a cache hierarchy\n\nTBD\n\n### Communicating with a running program\n\nTBD\n\n## Sample code in Parallang\n\nHere is an implementation of the Fox-Otto algorithm for solving APSP.\n\n```\nfn foxs_general(a: array[array[int]], b: array[array[int]], c: array[array[int]], maxIt: int) -\u003e array[array[int]] {\n    var southNeighbor: int = mod(myX+1, q);\n    var northNeighbor: int = mod(myX+q-1, q);\n\n    var p: array[array[int]] = array[array[int]](len(a), array[int](len(a[0]), 0));\n    var pPrev: array[array[int]] = array[array[int]](len(a), array[int](len(a[0]), 0));\n\n    for (var r: int = 0; r \u003c len(a); r = r + 1) {\n        for (var c: int = 0; c \u003c len(a[0]); c = c + 1) {\n            p[r][c] = c+scaleFactor_global*myY;\n            pPrev[r][c] = c+scaleFactor_global*myY;\n        }\n    }\n\n    for (var r: int = 0; r \u003c len(a); r = r + 1) {\n        for (var col: int = 0; col \u003c len(a[0]); col = col + 1) {\n            c[r][col] = a[r][col];\n            if (a[r][col] != inf) {\n                p[r][col] = r+scaleFactor_global*myX;\n                pPrev[r][col] = r+scaleFactor_global*myX;\n            }\n        }\n    }\n\n    for (var it: int = 0; it \u003c maxIt; it = it + 1) {\n        printIfMain(-1*it);\n        for (var k: int = 0; k \u003c q; k = k + 1) {\n            printIfMain(k);\n            var bCastProc: int = mod(myX+k, q);\n            if (myX == 0) {\n            }\n            if (bCastProc == myY) {\n                send a -\u003e broadcast_row;\n                matSquareWithPredecessor(a, b, c, p, pPrev);\n            } else {\n                recv[array[array[int]]] tempBlock \u003c- worker myX, bCastProc;\n                matSquareWithPredecessor(tempBlock, b, c, p, pPrev);\n            }\n            send b -\u003e worker northNeighbor, myY;\n            send pPrev -\u003e worker northNeighbor, myY;\n            recv b \u003c- worker southNeighbor, myY;\n            recv pPrev \u003c- worker southNeighbor, myY;\n        }\n\n        var temp: array[array[int]] = pPrev;\n        pPrev = p;\n        p = temp;\n\n        for (var r: int = 0; r \u003c len(a); r = r + 1) {\n            for (var col: int = 0; col \u003c len(a[0]); col = col + 1) {\n                p[r][col] = pPrev[r][col];\n                a[r][col] = c[r][col];\n            }\n        }\n        b = a;\n    }\n```\n\n## Origins\n\nThis code was produced for my undergraduate dissertation for the *Computer Science* tripos at the *University of Cambridge*: \"Evaluation of parallel routing algorithms.\" \n\nI examined five parallelizations of solutions to the *all-pairs shortest paths* problem: Cannon's algorithm and the Fox-Otto algorithm for min-plus matrix exponentiation, the Floyd-Warshall algorithm, the distance vector algorithm, and the Bellman-Ford algorithm. The simulator was created to accomplish analysis at scale and be free of the variability in the underlying host computer. My results used road-network datasets and demonstrated that *superlinear speedup* could be achieved for the first three, that the Bellman-Ford algorithm was the fastest, and that the distance vector algorithm is abysmally inefficient. \n\nMy supervisor was *Dr Jagdish Modi*, who suggested the project. I achieved a high class I mark on this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsyiek%2Fparallang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsyiek%2Fparallang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsyiek%2Fparallang/lists"}