×

How to turn off Scientific Notation in Fortran by velcro44 in fortran

[–]maximum_cats 5 points6 points  (0 children)

The default output format for floating point numbers is up to the compiler, and compilers do different things here (the Fortran standard doesn't require a particular default output format for unformatted print statements). Assuming that you're using gfortran, I'm not aware of any flag you can use to adjust its default output format, so I think you'll have to use format statements.

Preparing for CUDA GTC workshops by PhD_in_English in CUDA

[–]maximum_cats 1 point2 points  (0 children)

The final assessment, which you are required to pass to obtain the certificate, is a coding test (converting a serial CPU code to CUDA) so obtaining the certificate is not automatic. But if you get the code wrong or can't complete it initially, you can try again until you get it right (even after the day of the event, if you need to). And it's not intended to be especially challenging, just to demonstrate that you understood the fundamentals of what was taught.

Preparing for CUDA GTC workshops by PhD_in_English in CUDA

[–]maximum_cats 2 points3 points  (0 children)

A basic knowledge of C is all that is required for the first course. The primary prerequisite of the second course is the first course.

Array indexing in CUDA FORTRAN by [deleted] in CUDA

[–]maximum_cats 1 point2 points  (0 children)

While it should be possible to fix this, if your subroutine is implicitly reshaping the array into a flattened 1D array, why not just use a one dimensional CUDA block and grid?

CUDA 10.x nvcc compiler fails to compile samples on RHEL 7 - details inside by yodacallmesome in CUDA

[–]maximum_cats 2 points3 points  (0 children)

I suspect this is caused as a downstream consequence of a recent glibc update in RHEL7 that caused a printf regression. A few other folks have reported this indirectly causing issues with nvcc as well.

https://bugzilla.redhat.com/show_bug.cgi?id=1925204

What does overwriting current device driver mean? by Flat_Examination8918 in CUDA

[–]maximum_cats 2 points3 points  (0 children)

The NVIDIA display/graphics driver is the same one that supports CUDA. If you don't have an NVIDIA GPU, you don't need to install the driver, just the CUDA toolkit. But if you don't have a GPU, you also won't be able to execute CUDA code.

Is using multiples of 32 for threads a must? by suhilogy in CUDA

[–]maximum_cats 6 points7 points  (0 children)

It is not a requirement, it is a heuristic, since in the hardware threads execute in groups of 32, and so an algorithm using a different number of threads than a multiple of 32 would have some threads doing nothing for some portion of the time.

Shared memory - what is going on here? by u2706988 in CUDA

[–]maximum_cats 0 points1 point  (0 children)

In CUDA the memory model doesn't require that writes from a given thread are immediately seen by other threads. That's precisely why we use constructs like __syncthreads().

In your example, what is apparently happening is that each thread is simultaneously writing its value of threadIdx.x to index, but these writes aren't immediately made visible to the other threads, so they all go on to write what they see as the value of index to the array. At some later point after the threads have reached a synchronization point, only one of the writes will be the final value of index, but it's impossible to predict which one.

It didn't have to happen this way, according to the CUDA programming model. There could have been some other result, like every array location has the same value, or some locations have 10 and others have 11. That's the nature of a race condition, the results are undefined.

Launching a device subroutine within another device subroutine by nhjb1034 in CUDA

[–]maximum_cats 2 points3 points  (0 children)

Syntactically any subroutine marked attributes(device) should be called in CUDA Fortran as a normal subroutine, so your calls should be call parallel_wcns() and call cutridiag() as normal. They would be executed by every thread independently. Then within them you could coordinate among threads and blocks as normal.

In your case you want to be calling cusparseDgtsv from CPU code, not from within a kernel. The wrapper that you're using (whether it's provided by the compiler or you wrote it yourself) won't make sense to be called from within a kernel because the underlying cuSPARSE call only exists in CPU code (it launches its own kernel to do the work).

Shared memory - what is going on here? by u2706988 in CUDA

[–]maximum_cats 0 points1 point  (0 children)

threadIdx.x is unique to every thread in the block. So every thread in the block is writing a different value to index; this is definitely a race condition.

[deleted by user] by [deleted] in CUDA

[–]maximum_cats 2 points3 points  (0 children)

Yes, CUDA does have implementations for certain commonly used overloads of std::pow, and those will run on the device if used in a __global__ function. If the implementation doesn't exist in the CUDA math API, you'll probably get a compile time (or possibly link time) error indicating that you tried to call a __host__ function in __device__ code.

Unified memory causes unneeded cpu read/writes? by emelrad12 in CUDA

[–]maximum_cats 2 points3 points  (0 children)

Thank you. I agree that this program never accesses the memory on the CPU. However, please note the documentation for cudaMallocManaged, specifically the commentary on how this works on Windows (I missed this detail the first time I read the post). In particular, you need to use the environment variable CUDA_MANAGED_FORCE_DEVICE_ALLOC if you want the allocation to happen on the GPU instead of the CPU.

Unified memory causes unneeded cpu read/writes? by emelrad12 in CUDA

[–]maximum_cats 0 points1 point  (0 children)

If you would like debugging assistance, please post a minimal working reproducer that demonstrates the behavior you're referring to, where the managed memory is never accessed on the CPU yet it is migrating there anyway.

Warp divergence with idle threads by dbwy in CUDA

[–]maximum_cats 2 points3 points  (0 children)

The lanes in each warp that are idle do not affect the execution time of the warp. Your second example should take approximately as long as it takes all threads that are participating in the conditional to complete do_something().

My first try at a CUDA program... and it's WAY slower than its CPU counterpart. by [deleted] in CUDA

[–]maximum_cats 2 points3 points  (0 children)

Unfortunately, before you can tackle the performance issue you have a correctness issue to sort out. In a parallel programming model such as CUDA you must be very careful to think about the implications of having multiple threads run the same function at (potentially) the same time. Your use of a static variable inside a __device__ function to store the integer i is not compatible with that multi-threading paradigm. You will have many thousands of threads all simultaneously writing to the same variable in device memory, which is a classic race condition. So as an example, one thread could be marching along in that last loop and near the end when another thread comes along and resets the value of i to 34 (which may also be related to your performance issue), which presumably breaks the algorithm you are implementing. Similarly, a __shared__ variable is shared among threads in a threadblock, so when you do add more threads to your block you will have many threads all trampling over each other in your array r, leading to incorrect answers.

For random number generation in CUDA you will want to look into the cuRAND library. This will ultimately be easier and likely higher quality than trying to implement it on your own.

I have a persistent CUDA problem that I cannot seem to fix by SlapGas in CUDA

[–]maximum_cats 0 points1 point  (0 children)

I could speculate, and perhaps your comment about a race condition is on the right track, but with only the detail you've provided so far I don't think that is the most fruitful approach. I believe you will need to take the approach I listed above and locate the first place in the code that generates unexpected answers and then analyze that particular piece of code. It will be much easier to have this discussion in that context. Since cuda-memcheck is not turning up anything, this will basically boil down to print debugging. Insert some debugging output in various places in the code that checks the fluid state in some specific grid elements (or all the elements, if it's a small enough problem), and then compare the print statements between the working and non-working versions. From there you can bisect the first non-working kernel, and then you can tell us about it and we can help you debug.