{ "info": { "author": "Andreas Kloeckner", "author_email": "inform@tiker.net", "bugtrack_url": null, "classifiers": [], "description": "CnD is a source-to-source translator that makes using n-dimensional arrays\nin C more pleasant. It will turn this code::\n\n void sgemm(float *a, float *b, float *c, int n)\n {\n dimension \"fortran\" a[n, n];\n dimension \"fortran\" b[n, n];\n dimension c[n, n];\n\n for (int i = 1; i <= n; ++i)\n for (int j = 1; j <= n; ++j)\n {\n float tmp = 0;\n\n for (int k = 1; k <= n; ++k)\n tmp += a[i,k]*b[k,j];\n\n c[i-1,j-1] = tmp;\n }\n }\n\ninto this::\n\n void sgemm(float *a, float *b, float *c, int n)\n {\n for (int i = 1; i <= n; ++i)\n for (int j = 1; j <= n; ++j)\n {\n float tmp = 0;\n for (int k = 1; k <= n; ++k)\n tmp += a[((k - 1) * ((n - 1) + 1)) + (i - 1)] * b[((j - 1) * ((n - 1) + 1)) + (k - 1)];\n\n c[((i - 1) * n) + (j - 1)] = tmp;\n }\n }\n\nYou may also take a look at a `more comprehensive example\n`_\nthat shows a few extra bells and whistles.\n\nThe only effect of a `dimension` declaration is to modify the interpretation of\nthe `array(idx)` subscript operator. `dimension` declarations obey regular C\nscoping rules.\n\nI'd also like to note that CnD is a robust, parser-based translator, not a flaky\ntext replacement tool. It understands all of C99, plus many GNU extensions.\n\nEach axis specification in a `dimension` declaration has the following form::\n\n start:end:stride:leading_dimension\n\n`start` may be omitted. `end` and `stride` may also be omitted, but if entries\nafter them are to be specified, their trailing colons must remain in place. For\nexample, the axis specification `:5` simply specifies a stride of 5. The stride\nsimply acts as a multiplier on the index. No plausibility checking whatsoever\nis done on the dimension declaration. You may shoot yourself in the foot any way\nyou like.\n\nIf the layout is given as `\"c\"` or `\"row-major\"` or not given at all, the following things are true:\n\n* The array is laid out in row-major order.\n* The `end` index is taken to be exclusive, if specified.\n* The `start` index defaults to 0.\n\nIf the layout is given as `\"col-major\"`, the following things are true:\n\n* The array is laid out in column-major order.\n* The `end` index is taken to be exclusive, if specified.\n* The `start` index defaults to 0.\n\nIf the layout is given as `\"fortran\"`, the following things are true:\n\n* The array is laid out in column-major order.\n* The `end` index is taken to be inclusive, if specified.\n* The `start` index defaults to 1.\n\n(Most) of the knowledge contained in the `dimension` declaration may be reobtained\nprogrammatically by the follwing functions:\n\n* `rankof(a)`\n* `nitemsof(a)`\n* `lboundof(a, axis)`\n* `uboundof(a, axis)` (returns the user-specified upper bound)\n* `puboundof(a, axis)` (returns the index just past the end of axis)\n* `ldimof(a, axis)`\n* `strideof(a, axis)`\n\nIn each case, `axis` must be a constant integer (not a constant expression, a\nplain integer).\n\nInstallation / Usage\n--------------------\n\nYou may obtain CnD by downloading the tarball from the `package index\n`_, or from `github\n`_::\n\n $ git clone git://github.com/inducer/cnd.git\n $ cd cnd\n $ git submodule init\n $ git submodule update\n\nTo use CnD, simply add `distribution-dir/bin` to your `PATH`.\n\nTo get started, simply run (from within the `cnd` root)::\n\n $ cd examples\n $ ../bin/cndcc gcc -std=c99 basic.c\n $ ./a.out\n\nIf you would like more fine-grained control over the translation process, the\n`cnd` command exposes just the source-to-source translation. Note that `cnd`\nexpects preprocessed source. You may pass the option `-E` to have `cnd` run the\npreprocessor on your source for you. Run::\n\n $ cnd -h\n\nto get full help on the command line interface. You may set the `CND_CPP`\nenvironment variable to the preprocessor you wish to use.\n\nFAQ\n---\n\nBut isn't there a preprocessor issue with this syntax?\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nGreat point. Consider the following stiuation::\n\n #define MY_MACRO(a) /* something rather */\n\n MY_MACRO(array[i,j])\n\nThe preprocessor sees the comma and rips our array access apart into two macro\narguments, and then complains that `MY_MACRO` takes only one argument. Not\nvery smart, but such is life. (Credit for discovering this goes to Zydrunas\nGimbutas.)\n\nThe easiest fix is to use the following syntax::\n\n MY_MACRO(array[(i,j)])\n\nThis is guaranteed to work, always. Some C standard 'functions' may also turn\nout to be macros, so in principle you are obliged to use this syntax whenever\nyou pass the result of a multi-D array access to a function that you haven't\ndeclared yourself. That's obviously inconvienient, so there's one more plot\ntwist. CnD will rewrite your main source file (but not any included headers!)\nby inserting parentheses within brackets (in non-string, non-char-constant,\nnon-preprocessor contexts). This is a no-op as far as C99 is concerned. As a\nresult, you are obliged to use the parenthesized syntax only in files that are\nnot top-level compiled files and only in contexts where the array access might\nbe part of a macro expansion.\n\nVersion History\n---------------\n\n2011.4\n^^^^^^\n\n(December 11, 2012)\n\n* Syntax change from `a[i;j]` to `a[i,j]`.\n* Still more parser support for real-life headers.\n\n2011.3\n^^^^^^\n\n(December 10, 2012)\n\n* Syntax change from `a(i,j)` to `a[i;j]`.\n* Parser support for many more GNU extensions, `tgmath.h`\n now works on OS X (10.7) and Linux.\n\n2011.2\n^^^^^^\n\n(December 10, 2012)\n\n* Syntax change from `a[i,j]` to `a(i,j)`.\n* Fixes for OS X and two bugs.\n* Generate #line directives.\n\n2011.1\n^^^^^^\n\n(December 9, 2012)\n\nInitial release.\n\nFuture Features\n^^^^^^^^^^^^^^^\n\n* Caching of lexer/parser tables (faster startup)\n* Bounds checking.\n\nAuthor\n------\n\nAndreas Kloeckner , based on discussions with Zydrunas Gimbutas.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://mathema.tician.de/software/cnd", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "cnd", "package_url": "https://pypi.org/project/cnd/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cnd/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://mathema.tician.de/software/cnd" }, "release_url": "https://pypi.org/project/cnd/2012.1/", "requires_dist": null, "requires_python": null, "summary": "A preprocessor that gives C multidimensional arrays", "version": "2012.1" }, "last_serial": 673928, "releases": { "2011.1": [ { "comment_text": "", "digests": { "md5": "9b3faaa658d4936d16988640c24560fc", "sha256": "84ca95dff1392d479ecdd26472966bbb2b1ddef51d3e8ff44fdf3c83acdb7b5b" }, "downloads": -1, "filename": "cnd-2011.1.tar.gz", "has_sig": false, "md5_digest": "9b3faaa658d4936d16988640c24560fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 91948, "upload_time": "2011-12-10T00:55:16", "url": "https://files.pythonhosted.org/packages/d3/b7/ec3182b8320c338acb2919fcc09ccd254a44a3506db0a0f988e43b9b91f1/cnd-2011.1.tar.gz" } ], "2011.2": [ { "comment_text": "", "digests": { "md5": "f28857cc3b56d0ffb24f55d53320072d", "sha256": "20d4a6eecc3cf4d6e61fb0bf166974be2e3546a2cfce3a3ff17c0f9314495907" }, "downloads": -1, "filename": "cnd-2011.2.tar.gz", "has_sig": false, "md5_digest": "f28857cc3b56d0ffb24f55d53320072d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 93205, "upload_time": "2011-12-10T05:08:06", "url": "https://files.pythonhosted.org/packages/ef/2f/667ea646a3e8c21b89faac3b5712505253ef8e525080f565ec40d4c98ca6/cnd-2011.2.tar.gz" } ], "2011.3": [ { "comment_text": "", "digests": { "md5": "2d71651f0d34de47cbb939124d561f97", "sha256": "cc2fb4f2fea9af517fe71aa266f4deb4b4c51de75bee76d642c6789f74632a01" }, "downloads": -1, "filename": "cnd-2011.3.tar.gz", "has_sig": false, "md5_digest": "2d71651f0d34de47cbb939124d561f97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 95318, "upload_time": "2011-12-10T22:54:42", "url": "https://files.pythonhosted.org/packages/27/3b/c0d49d68d4183c6451f18fcac1ad996a3959cf003ce164413274e80232b9/cnd-2011.3.tar.gz" } ], "2011.4": [ { "comment_text": "", "digests": { "md5": "26e8f3495aed83f8944b69507aa1dfd7", "sha256": "2b8640954083e7be60270e720b7422df52d323b521577f4d446bbfdb8e22b86b" }, "downloads": -1, "filename": "cnd-2011.4.tar.gz", "has_sig": false, "md5_digest": "26e8f3495aed83f8944b69507aa1dfd7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 96200, "upload_time": "2011-12-11T23:10:20", "url": "https://files.pythonhosted.org/packages/4d/9e/0093088ddea80ea789587adb5d70f6c0e440589183cb73c2889bb411d109/cnd-2011.4.tar.gz" } ], "2012.1": [ { "comment_text": "", "digests": { "md5": "98d76be505946e134d03842a38cc1704", "sha256": "0da72edcfdc1d13a45367b1fb4e2222ab217f324bf079f0e2397588790b59a66" }, "downloads": -1, "filename": "cnd-2012.1.tar.gz", "has_sig": false, "md5_digest": "98d76be505946e134d03842a38cc1704", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 100607, "upload_time": "2012-11-09T15:20:38", "url": "https://files.pythonhosted.org/packages/6e/f2/473cf418c28aea9a07359c7b2f16edd2c5d24796ab6ce610b4def09f3536/cnd-2012.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "98d76be505946e134d03842a38cc1704", "sha256": "0da72edcfdc1d13a45367b1fb4e2222ab217f324bf079f0e2397588790b59a66" }, "downloads": -1, "filename": "cnd-2012.1.tar.gz", "has_sig": false, "md5_digest": "98d76be505946e134d03842a38cc1704", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 100607, "upload_time": "2012-11-09T15:20:38", "url": "https://files.pythonhosted.org/packages/6e/f2/473cf418c28aea9a07359c7b2f16edd2c5d24796ab6ce610b4def09f3536/cnd-2012.1.tar.gz" } ] }