charm AT lists.siebelschool.illinois.edu
Subject: Charm++ parallel programming system
List archive
- From: Gengbin Zheng <gzheng AT illinois.edu>
- To: "Van Der Wijngaart, Rob F" <rob.f.van.der.wijngaart AT intel.com>, "Hammond, Jeff R" <jeff.r.hammond AT intel.com>, Phil Miller <mille121 AT illinois.edu>
- Cc: Nikhil Jain <nikhil.life AT gmail.com>, "Kunzman, David M" <david.m.kunzman AT intel.com>, "Mattson, Timothy G" <timothy.g.mattson AT intel.com>, "charm AT cs.illinois.edu" <charm AT cs.illinois.edu>
- Subject: Re: [charm] [ppl] Global variables in Charm++
- Date: Mon, 29 Sep 2014 15:15:01 -0500
- List-archive: <http://lists.cs.uiuc.edu/pipermail/charm/>
- List-id: CHARM parallel programming system <charm.cs.uiuc.edu>
Charm++'s interface language was purposely designed to be very simple (so we don't spend too much time on writing a full-fledged compiler). The readonly syntax as defined in xi-grammar.y is like this: ArrayDim : NUMBER { $$ = new Value($1); } | QualName { $$ = new Value($1); } ; QualName : IDENT { $$ = $1; } | QualName ':'':' IDENT { char *tmp = new char[strlen($1)+strlen($4)+3]; sprintf(tmp,"%s::%s", $1, $4); $$ = tmp; } ; Dim : '[' ArrayDim ']' { $$ = $2; } ; DimList : /* Empty */ { $$ = 0; } | Dim DimList { $$ = new ValueList($1, $2); } ; Readonly : READONLY Type QualName DimList { $$ = new Readonly(lineno, $2, $3, $4); } so in brackets, it pretty much only takes numbers or identifiers, no expressions. To workaround your problem, you can: 1. define a macro for your formula and only use the macro in ci file. #define WEIGHT_SIZE (2*RADIUS+1)*(2*RADIUS+1) /* write this in a C header file */ and then: readonly double weight[WEIGHT_SIZE] in ci file. 2. avoid using readonly in ci file, but use readonly templates in C++ file. This is probably not defined in Charm manual, but it is like putting the following in a C++ code: roarray<double, (2*RADIUS+1)*(2*RADIUS+1)> weight; This way, you don't need to write any readonly thing in the ci file. Gengbin On 9/29/2014 2:47 PM, Van Der
Wijngaart, Rob F wrote:
Eh, that would stink spectacularly. I refuse to accept that “double weight[3+3+3];” may result in a syntax error. I invite the Charm++ team to explain why this would be reasonable.
Rob
From:
Hammond, Jeff R
Can you do something evil where you extern pointer to storage and then declare it in a generic C++ file that will be preprocessed properly?
Obviously, may provoke the question “what is that terrible smell?” but I’ve seen far worse workarounds associated with legacy Fortran :-)
Jeff
From:
"<Van
Der Wijngaart>", Rob F <rob.f.van.der.wijngaart AT intel.com>
OK, it appears not to be the problem of running the preprocessor per se, but of having expressions in array dimensions. I replaced readonly double weight[(2*RADIUS+1)*(2*RADIUS+1)]; with readonly double weight[3+3+3]; and got another syntax error. This looks like a pretty serious limitation to me. I am now required to do the array dimension computation for charmc and stuff that into the .ci file explicitly as a constant. This means running another script/preprocessor before I can run charmc.
Rob
From:
Van Der Wijngaart, Rob F
Thanks Phil. I just added –E to my OPTS parameter, but then all hell breaks loose. This is what charmc says is happening when it tries to compile my .ci file: ../../../bin/charmc -Ofast -DRADIUS=1 -DSTAR -E jacobi2d.ci And this is the line in my .ci file that it complains about: readonly double weight[(2*RADIUS+1)*(2*RADIUS+1)];
Output: [rfvander@bar1 PRKstencil5]$ make ../../../bin/charmc -Ofast -DRADIUS=1 -DSTAR -E jacobi2d.ci STDIN:8: Charmxi syntax error> syntax error Invalid construct Fatal Error by charmc in directory /home/rfvander/charm/examples/charm++/PRKstencil5 Command ../../../bin/charmxi -orig-file jacobi2d.ci returned error code 1 charmc exiting... ../../../bin/charmc -Ofast -DRADIUS=1 -DSTAR -c jacobi2d.C jacobi2d.C(1): catastrophic error: cannot open source file "jacobi2d.decl.h" #include "jacobi2d.decl.h"
By the way, you may wonder about the subject line of this message. It started because I wanted a (small) 2D array as a global variable. I couldn’t get that to work (is that by design?), so made it into a 1D array. And then I ran into the issue I just reported.
Rob
From:unmobile AT gmail.com
[mailto:unmobile AT gmail.com]
On Behalf Of Phil Miller
For historical reasons [1],
charmc defaults to *not* running the preprocessor on
.ci files. Preprocessing .ci files can be enabled by
passing charmc the -E flag when it's working on .ci
files. [1] Enabling pre-processing when it wasn't historically the default risks breaking existing application code by having macros that may have been used as identifiers in .ci files suddenly be subject to expansion/substitution.
On Fri, Sep 26, 2014 at 5:31 PM, Van Der Wijngaart, Rob F <rob.f.van.der.wijngaart AT intel.com> wrote: Hello Nikhil,
I have a symbol that I define on the compile line (i.e. I stuff it in OPTS, as below): OPTS=-DRADIUS=1 CHARMC=../../../bin/charmc $(OPTS) When I now use RADIUS in my .C file, the C preprocessor does its work nicely and recognizes that I have defined RADIUS, and also what its value is. However, when I use RADIUS in the .ci file, charmc croaks. So is it true that no preprocessor is run on .ci files? Thanks!
Rob
_______________________________________________ charm mailing list charm AT cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/charm _______________________________________________ ppl mailing list ppl AT cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/ppl |
- [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/26/2014
- Re: [charm] Global variables in Charm++, Phil Miller, 09/26/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/26/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/26/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Hammond, Jeff R, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] [ppl] Global variables in Charm++, Gengbin Zheng, 09/29/2014
- Re: [charm] [ppl] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] [ppl] Global variables in Charm++, Gengbin Zheng, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Kunzman, David M, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] [ppl] Global variables in Charm++, Gengbin Zheng, 09/29/2014
- Re: [charm] [ppl] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Kunzman, David M, 09/29/2014
- Re: [charm] Global variables in Charm++, Kunzman, David M, 09/29/2014
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/29/2014
- Re: [charm] Global variables in Charm++, Hammond, Jeff R, 09/29/2014
- Re: [charm] Global variables in Charm++, Phil Miller, 09/26/2014
- <Possible follow-up(s)>
- Re: [charm] Global variables in Charm++, Van Der Wijngaart, Rob F, 09/26/2014
- Re: [charm] Global variables in Charm++, Kale, Laxmikant V, 09/29/2014
Archive powered by MHonArc 2.6.16.