- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Zvi,
The problem is that whay you are looking for is a cross-product but array notation is not designed for that. In other words, by using p_in_gains[] with an array section, you are trying to increase the rank by one and then use the reduction to reduce the rank again. Perhaps you were an APL programmer in a former life?
The only thing I can suggest off the top of my head is to use a loop and hope that the auto-vectorizor figures out the reduction. I don't think there's a way to use a #pragma simd because I don't think there is any way to do a reduction into an array section.
-Pablo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Pablo,
I don't think that your interpretation is right: even if I will not use (eliminate) p_in_gains[0:5], there is another [0:5] section - I mean p_ins[0:5] in the second factor at the right. How can I hint to compiler, that I want to reduce for this section ?
- Zvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bluntly, you are using the wrong language - this is something that Fortran handles vastly better. The trouble with CilkPlus is that it starts from C++, and C/C++'s array handling is not brilliant. It wouldn't be elegant in Fortran, but it could be done cleanly and simply. This is almost exactly Pablo's point, incidentally - you can do anything in any Turing-complete language, but some tasks fit better in some languages than in others.
I have thought of how to handle your class of problem in a possibly extended C++, fairly recently, and was defeated. Either it is infeasible, or it needs someone smarter than me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure I would go as far as Nick in saying that you are using the wrong language. If you find that you need to do this kind of thing a lot, then, yes, a different language might be more appropriate. If this is just one small piece of a program that really benefits from C or C++ language features, or if you are simply more comfortable in C or C++, then it probably makes sense to simply accept that this little computation cannot be expressed any more eligantly in Cilk Plus than what you already have. I do think writing it as a loop might make the code easier to follow, less error prone, and possibly more vectorizable.
-Pablo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, yes - what I meant that it is the wrong language to achieve that particular objective. As you say, the effect can be achieved in another way with a bit more complication, and that is quite likely the easiest solution. A third solution is to use Fortran's C interoperability to call a Fortran procedure that does those tasks but, again, that could well be more complicated than just writing alternative C++ code. And there are yet other viable solutions ....
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page