pgi

How is variable in device memory used by external function?

荒凉一梦 提交于 2019-12-11 05:38:45
问题 In this code: #include <iostream> void intfun(int * variable, int value){ #pragma acc parallel present(variable[:1]) num_gangs(1) num_workers(1) { *variable = value; } } int main(){ int var, value = 29; #pragma acc enter data create(var) copyin(value) intfun(&var,value); #pragma acc exit data copyout(var) delete(value) std::cout << var << std::endl; } How is int value recognized to be on device memory in intfun ? If I replace present(variable[:1]) by present(variable[:1],value) in the intfun

c - Linking a PGI OpenACC-enabled library with gcc

泪湿孤枕 提交于 2019-12-11 05:18:29
问题 Briefly speaking , my question relies in between compiling/building files (using libraries) with two different compilers while exploiting OpenACC constructs in source files. I have a C source file that has an OpenACC construct. It has only a simple function that computes total sum of an array: #include <stdio.h> #include <stdlib.h> #include <openacc.h> double calculate_sum(int n, double *a) { double sum = 0; int i; printf("Num devices: %d\n", acc_get_num_devices(acc_device_nvidia)); #pragma

Name mangling in CUDA and C++

≡放荡痞女 提交于 2019-12-11 02:46:41
问题 My C++ project main.cpp , compiled with pgcpp from PGI, calls a function cuda() containing CUDA code in a separate file cuda.cu , compiled with nvcc . Unless I wrap the cuda() function with extern "C" in the function declaration and the common header file, I get linking errors (undefined references). Without extern "C" (symbol name mismatch => undefined reference): $ nm main.o | grep -y cuda U cuda__FPfPiT2iN32 $ nm cuda.o | grep -y cuda T _Z13cudaPfPiS0_iS0_S0_S0_ With extern "C" (symbol

Random number generator in PGI Fortran not so random

可紊 提交于 2019-12-10 20:36:05
问题 The following code just generates a simple triple of random numbers: program testrand integer, parameter :: nz = 160, nf = 160, nlt = 90 real :: tmpidx(3) integer :: idxarr(3), idx1, idx2, idx3, seed_size, ticks integer, allocatable :: seed(:) call random_seed(size=seed_size) allocate(seed(seed_size)) call system_clock(count=ticks) seed = ticks+37*(/(i-1, i=1,seed_size)/) call random_seed(put=seed) deallocate(seed) call random_number(tmpidx) idxarr = tmpidx * (/nz, nf, nlt/) idx1 = max(1

What should COMPILER_OPTIONS() return in Fortran?

痴心易碎 提交于 2019-12-10 20:26:21
问题 Fortran 2008 added a new procedure called COMPILER_OPTIONS() which according to GNU documentation should return a string with the options used for compiling the file. According to Fortran 2003 status wiki, almost all compilers including GNU and PGI seem to support this feature. I created a simple program COMPILER_OPTIONS.f08 shown below use iso_fortran_env print '(4a)', 'This file was compiled by using the options ', compiler_options() end Here are my results from gfortran and pgfortran

Calculating PI with Fortran & CUDA

試著忘記壹切 提交于 2019-12-08 13:44:58
问题 I am trying to make a simple program in PGI's fortran compiler. This simple program will use the graphics card to calculate pi using the "dart board" algorithm. After battling with this program for quite some time now I have finally got it to behave for the most part. However, I am currently stuck on passing back the results properly. I must say, this is a rather tricky program to debug since I can no longer shove any print statements into the subroutine. This program currently returns all

Using OpenACC to parallelize nested loops

℡╲_俬逩灬. 提交于 2019-11-30 10:33:56
I am very new to openacc and have just high-level knowledge so any help and explanation of what I am doing wrong would be appreciated. I am trying to accelerate(parallelize) a not so straightforward nested loop that updates a flattened (3D to 1D) array using openacc directives. I have posted a simplified sample code below that when compiled using pgcc -acc -Minfo=accel test.c gives the following error: call to cuStreamSynchronize returned error 700: Illegal address during kernel execution Code: #include <stdio.h> #include <stdlib.h> #define min(a,b) (a > b) ? b : a #define max(a,b) (a < b) ? b