سؤال

I'm trying to accelerate a piece of code using cuda fortran. This code uses the common statement in the definition of the variables which is not valid in the device code with cuda.

What I did is define the variables in a module instead of using the common statement but this gives me a wrong answer. I'm doing all of these on normal code in order to find a substitute to the common statement.

Code(common)

Code(without common)

I think it should work this way, because these variables are only used by these functions, but it doesn't. Why is that? And what can I do to fix this problem?

هل كانت مفيدة؟

المحلول

After taking a look at your files, I see that you are using OpenACC for Fortran, which is not what I would call CUDA Fortran. I will assume that that is your intent, and that you are not actually intending to use CUDA fortran, but instead you are trying to make the OpenACC code work correctly.

I have 2 suggestions.

  1. Be specific. Which variables, which functions are not working correctly, and what are the results you are getting and what are the results you are expecting? The best scenario would be to provide a short complete, compilable example, rather than just dumping entire files of code into a question. Narrow your problem down to a specific example of something that is not working.
  2. Again, assuming your intent is to use OpenACC fortran, you have already demonstrated that you have at least some idea of how to use the !acc kernels directive. I took a quick look at your code, and the loops you were encasing did not look terribly complicated. My suggestion is that you identify all of the data that is required (input) to these loops and generated (output) from these loops, and include additional !acc data directives, to specify these as copyin for input data and copyout for output data. A specific example/tutorial is given here. Having said that, as long as the data is in scope when the compiler is attempting to use it in an !acc kernels region, I don't think you should be getting incorrect results. But to pursue this further, I think a specific example would be appropriate. In general, use of the !acc data directive will help you to focus your attention on the data needed and make sure the compiler understands how to transfer it to/from the device and when.

And as I mentioned already, please paste code examples that you want others to look at in the actual question, rather than including links.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top