{"id":18730422,"url":"https://github.com/dfordivam/perf-check","last_synced_at":"2025-11-12T11:30:17.142Z","repository":{"id":140635486,"uuid":"47753370","full_name":"dfordivam/perf-check","owner":"dfordivam","description":"Some code to check performance of mulit-threaded code in haskell and openMP","archived":false,"fork":false,"pushed_at":"2015-12-14T10:36:19.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T21:39:55.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dfordivam.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-10T10:00:02.000Z","updated_at":"2021-05-02T18:58:21.000Z","dependencies_parsed_at":"2023-04-06T05:19:28.119Z","dependency_job_id":null,"html_url":"https://github.com/dfordivam/perf-check","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfordivam%2Fperf-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfordivam%2Fperf-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfordivam%2Fperf-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dfordivam%2Fperf-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dfordivam","download_url":"https://codeload.github.com/dfordivam/perf-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599788,"owners_count":19666054,"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","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":[],"created_at":"2024-11-07T14:41:26.102Z","updated_at":"2025-11-12T11:30:17.099Z","avatar_url":"https://github.com/dfordivam.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\np1 : Naive implementation of parallelism in openMP and haskell\n    The tasks are really simple and therefore the single-threaded execution has an edge over multiple threads.\n    The benefits of parallelism happen after \u003e1000 tasks per thread per iteration.\n    The haskell seems to do better than openMP\n\np2 : Tasks operate on random data.\n    Tasks are still simple (same as p1), but each iteration operates on random set of data.\n    Here openMP does very bad for NUM_TASK ~1000 (9x slower, haskell 2x slower)\n    For NUM_TASK 10000 per iteration haskell does better than single threaded, openMP is still 3x slower\n\np3 : Unequal distribution of tasks in threads\n    For unequal distribution the number of tasks in each thread is same\n    But some threads will get additional heavy task randomly.\n    Here if we keep NUM_TASK 10000 then openMP performs slightly better than single thread\n    Haskell performs much better ~1.5x speedup on 3 cores\n\np4 : Every Task does an atomic operation in the end (Increment a counter)\n    Here openMP is 2x slow with NUM_TASK 1000, 1x with 10000\n    Haskell has a callback routine with atomicModifyIORef\n    It is 4x slower with 1000, and 3.5x slower with 10000\n    So most of degradation is due to callback into haskell\n    Note: With MVar the haskell just stops running. (\u003e100x slower?)\n\np5 : More realistic example\n    1. Task reads/write only 10% of memory of the array\n    2. Number of arrays is 200k \n        (should be more but my system's memory is limited)\n    3. Array size is 1k\n        (should be more but my system's memory is limited)\n\n    The openMP parallel pragma should come just before the execution\n    of parallel blocks. If we call generateExecTask inside the parallel\n    pragma region, then it can cause degradation of upto 1.5-2x\n\n    Here performance of openMP and haskell are similar\n\n    Note : Here I removed the callback of haskell and used\n    openMP atomic instead. Haskell callback is an overkill\n    to do for each task\n\np6 : Task is more realistic. Its access of memory is non contiguous\n    Important finding: If the array of execTasks (for all iterations)\n    is known before the openMP iterations start, then there is a \n    significant speedup (upto 1.5x on 3 cores).\n    (Though this scenario is un-realistic as the next\n    set of execution tasks is not known beforehand)\n\n    Other changes : Task access localization- There is a provision\n    to limit the task on either half, one-third, etc. arrays\n    This is essential as the real world tasks (in an iteration)\n    are limited to a part of heap memory.\n\n    Result Comparison- Added some infrastructure to compare the result\n    with single threaded run. The openMP with single core gives correct result.\n    Haskell on the other hand always cause thread race and mismatch in result.\n\np7 : Same as p6, but execTasks are 'created'(actually copied) for each iteration\n    \np8 : Compare and swap mechanism in each task to check if values are valid\n    This resulted in 2.5x degradation in single thread performance\n    and with 3 cores 2x slowdown compared to single-thread version without CAS.\n\np9 : Added sort on execution tasks just before the iteration starts\n     This effectively removes the result mismatch issue\n    Without sort the speedup on 3 core is 2.15x\n    with sort 1.5x\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfordivam%2Fperf-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdfordivam%2Fperf-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdfordivam%2Fperf-check/lists"}