{"id":19115051,"url":"https://github.com/ptahmose/colortwist","last_synced_at":"2025-09-04T04:44:55.913Z","repository":{"id":53755693,"uuid":"304118128","full_name":"ptahmose/colortwist","owner":"ptahmose","description":"an exercise in SIMD-optimization","archived":false,"fork":false,"pushed_at":"2024-10-16T22:37:46.000Z","size":4285,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-03T06:59:27.637Z","etag":null,"topics":["arm","avx-instructions","avx2","cpp","image-processing","neon"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ptahmose.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":"2020-10-14T19:40:50.000Z","updated_at":"2024-10-16T22:37:50.000Z","dependencies_parsed_at":"2023-12-22T15:30:52.364Z","dependency_job_id":"1663959a-616a-419f-9b74-99155c5b66c2","html_url":"https://github.com/ptahmose/colortwist","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/ptahmose%2Fcolortwist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptahmose%2Fcolortwist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptahmose%2Fcolortwist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptahmose%2Fcolortwist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ptahmose","download_url":"https://codeload.github.com/ptahmose/colortwist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240170091,"owners_count":19759145,"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":["arm","avx-instructions","avx2","cpp","image-processing","neon"],"created_at":"2024-11-09T04:45:24.649Z","updated_at":"2025-02-22T12:13:52.182Z","avatar_url":"https://github.com/ptahmose.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# colortwist\n\nThis is a little finger exercise in SIMD-optimization. The example we try to optimize is an image processing operation known as \"color twist\". It is a matrix-multication of an RGB-triple and a given matrix.\nSo, if we have the source pixel values r, g, b, then the destination pixels R, G, B are calculated as \n\n$$\nR = t_{11} \\cdot r + t_{12} \\cdot g + t_{13} \\cdot b + t_{14}\n$$\n\n$$\nG = t_{21} \\cdot r + t_{22} \\cdot g + t_{23} \\cdot b + t_{24}\n$$\n\n$$\nB = t_{31} \\cdot r + t_{32} \\cdot g + t_{33} \\cdot b + t_{34}\n$$\n\nwhere \n\n$$\n\\begin{equation}\nT = \\begin{pmatrix}\n    t_{11} \u0026 t_{12} \u0026 t_{13} \u0026 t_{14} \\\\\n    t_{21} \u0026 t_{22} \u0026 t_{23} \u0026 t_{24} \\\\\n    t_{31} \u0026 t_{32} \u0026 t_{33} \u0026 t_{34}\n\\end{pmatrix}\n\\end{equation}\n$$\n\nis the color twist matrix.\n\nThere are SIMD-optimized versions leveraging [AVX-instructions](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) (for x86) and [Neon-instructions](https://en.wikipedia.org/wiki/ARM_architecture#Advanced_SIMD_(NEON)) (for ARM).\n\n# How fast is it?\n\nHere are some numbers (1MB = 1,000,000 bytes):\n\n[Intel Core i7-8700K @ 3.70GHz](https://ark.intel.com/content/www/us/en/ark/products/126684/intel-core-i7-8700k-processor-12m-cache-up-to-4-70-ghz.html), msvc 19.27.29112, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1226.24             |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 1720.98  |\n| colorTwistRGB48_AVX    | 3291.02             |\n| colorTwistRGB48_AVX2   | 4297.74             |\n| colorTwistRGB48_AVX3   | 5175.55             |\n| colorTwistRGB24_C      | 318.01              |\n| colorTwistRGB24_IPP    | 892.93              |\n| colorTwistRGB24_AVX3   | 2966.55             |\n\n[Intel Core i7-8700K @ 3.70GHz](https://ark.intel.com/content/www/us/en/ark/products/126684/intel-core-i7-8700k-processor-12m-cache-up-to-4-70-ghz.html), Intel icl 19.1.3.311, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1313.22             |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 1809.26  |\n| colorTwistRGB48_AVX    | 3354.22             |\n| colorTwistRGB48_AVX2   | 4452.38             |\n| colorTwistRGB48_AVX3   | 5207.50             |\n| colorTwistRGB24_C      | 340.01              |\n| colorTwistRGB24_IPP    | 922.14              |\n| colorTwistRGB24_AVX3   | 3180.88             |\n\nIntel Core i7-8700K @ 3.70GHz, gcc 10.2.0, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1453.32             |\n| colorTwistRGB48_AVX    | 3334.76             |\n| colorTwistRGB48_AVX2   | 4315.26             |\n| colorTwistRGB48_AVX3   | 5011.39             |\n| colorTwistRGB24_C      | 328.43              |\n| colorTwistRGB24_AVX3   | 2998.93             |\n\nRaspberry Pi 4, gcc 8.3.0-6, 32bit : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 366.99              |\n| colorTwistRGB48_NEON   | 410.42              |\n| colorTwistRGB48_NEON2  | 1009.3              |\n| colorTwistRGB24_C      | 96.14               |\n| colorTwistRGB24_NEON2  | 480.69              |\n\nRaspberry Pi 4, gcc 10.3.0, 64bit : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 439.89              |\n| colorTwistRGB48_NEON   | 417.84              |\n| colorTwistRGB48_NEON2  | 942.86              |\n| colorTwistRGB24_C      | 120.64              |\n| colorTwistRGB24_NEON2  | 462.34              |\n\nRaspberry Pi 3b, gcc 8.3.0-6, 32bit : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 208.69              |\n| colorTwistRGB48_NEON   | 187.42              |\n| colorTwistRGB48_NEON2  | 435.30              |\n| colorTwistRGB24_C      | 63.30               |\n| colorTwistRGB24_NEON2  | 285.971             |\n\nAMD Ryzen 7 4700U, msvc 19.27.29112, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1202.02             |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 1836.64  |\n| colorTwistRGB48_AVX    | 3810.53             |\n| colorTwistRGB48_AVX2   | 4970.00             |\n| colorTwistRGB48_AVX3   | 5572.38             |\n| colorTwistRGB24_C      | 297.13              |\n| colorTwistRGB24_IPP    | 920.24              |\n| colorTwistRGB24_AVX3   | 2548.42             |\n\nAMD Ryzen 7 4700U,  Intel icl 19.1.3.311, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1355.20             |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 1862.04  |\n| colorTwistRGB48_AVX    | 3881.71             |\n| colorTwistRGB48_AVX2   | 5150.99             |\n| colorTwistRGB48_AVX3   | 5736.88             |\n| colorTwistRGB24_C      | 287.26              |\n| colorTwistRGB24_IPP    | 952.50              |\n| colorTwistRGB24_AVX3   | 2508.71             |\n\n[Intel Core m3-6Y30 @ 0.9GHz](https://ark.intel.com/content/www/us/en/ark/products/88198/intel-core-m3-6y30-processor-4m-cache-up-to-2-20-ghz.html), msvc 19.27.29112, x64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 650.32              |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 935.62  |\n| colorTwistRGB48_AVX    | 1769.30             |\n| colorTwistRGB48_AVX2   | 2370.21             |\n| colorTwistRGB48_AVX3   | 2943.29             |\n| colorTwistRGB24_C      | 157.44              |\n| colorTwistRGB24_IPP    | 466.74              |\n| colorTwistRGB24_AVX3   | 1793.66             |\n\nSamsung Galaxy Book Go ([Snapdragon 7c Gen2 @ 2.55GHz](https://www.qualcomm.com/products/snapdragon-7c-gen-2-compute-platform)), msvc 19.29.30133.0, ARM64 : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 827.08              |\n| colorTwistRGB48_NEON   | 1252.92             |\n| colorTwistRGB48_NEON2  | 2758.96             |\n| colorTwistRGB24_C      | 222.86              |\n| colorTwistRGB24_NEON2  | 1201.04             |\n\nSamsung Galaxy Book Go ([Snapdragon 7c Gen2 @ 2.55GHz](https://www.qualcomm.com/products/snapdragon-7c-gen-2-compute-platform)), msvc 19.29.30133.0, ARM : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 583.61              |\n| colorTwistRGB48_NEON   | 1241.57             |\n| colorTwistRGB48_NEON2  | 2581.25             |\n| colorTwistRGB24_C      | 208.34              |\n| colorTwistRGB24_NEON2  | 1336.50             |\n\n[AMD Ryzen 5 1600X](https://www.amd.com/en/products/cpu/amd-ryzen-5-1600x), gcc 7.5.0, Linux x64  : 2048x2048 RGB48 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1344.27             |\n| colorTwistRGB48_AVX    | 3186.97             |\n| colorTwistRGB48_AVX2   | 3445.82             |\n| colorTwistRGB48_AVX3   | 4008.93             |\n| colorTwistRGB24_C      | 281.88              |\n| colorTwistRGB24_AVX3   | 2014.70             |\n\n[Intel Core i9-12900K @ 3.20GHz](https://ark.intel.com/content/www/us/en/ark/products/134599/intel-core-i912900k-processor-30m-cache-up-to-5-20-ghz.html), msvc 19.31.31106.2, x64 : 2048x2048 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1928.36             |\n| [colorTwistRGB48_IPP](https://software.intel.com/content/www/us/en/develop/documentation/ipp-dev-reference/top/volume-2-image-processing/image-color-conversion/color-twist.html)  | 2203.86  |\n| colorTwistRGB48_AVX    | 4058.93             |\n| colorTwistRGB48_AVX2   | 8323.63             |\n| colorTwistRGB48_AVX3   | 9091.08             |\n| colorTwistRGB24_C      | 440.10              |\n| colorTwistRGB24_IPP    | 1116.93             |\n| colorTwistRGB24_AVX3   | 5441.54             |\n\n[MacBook Pro M2](https://www.apple.com/macbook-pro-13/specs/), clang-1400.0.29.202, arm64 : 2048x2048 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 5301.62             |\n| colorTwistRGB48_NEON   | 7226.25             |\n| colorTwistRGB48_NEON2  | 9188.08             |\n| colorTwistRGB24_C      | 2863.86             |\n| colorTwistRGB24_NEON2  | 4584.36             |\n\n[Lenovo Yoga Slim 7x](https://www.lenovo.com/us/en/p/laptops/yoga/yoga-slim-series/yoga-slim-7x-gen-9-14-inch-snapdragon/len101y0049), MSVC 19.41.34123.0, arm64 : 2048x2048 bitmap\n\n| version                | performance in MB/s |\n| ---------------------- | ------------------- |\n| colorTwistRGB48_C      | 1733.64             |\n| colorTwistRGB48_NEON   | 10817.1             |\n| colorTwistRGB24_C      | 353.98              |\n| colorTwistRGB24_NEON2  | 5184.21             |\n\n\n\n# Building\n\nFor Windows-on-ARM, run the following:\n\n```\nmkdir build\ncmake .. -G \"Visual Studio 16 2019\" -A ARM64\ncmake  --build . --config Release\n```\n\nFor a 32-bit build, use\n\n```\nmkdir build\ncmake .. -G \"Visual Studio 16 2019\" -A ARM\ncmake  --build . --config Release\n```\n\nFor x86-Windows, use for x64-build:\n\n```\nmkdir build\ncmake .. -G \"Visual Studio 16 2019\" -A x64\ncmake  --build . --config Release\n```\n\nFor x86-build, run\n\n```\nmkdir build\ncmake .. -G \"Visual Studio 16 2019\" -A Win32\ncmake  --build . --config Release\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptahmose%2Fcolortwist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fptahmose%2Fcolortwist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptahmose%2Fcolortwist/lists"}