From: Karl R. <ru...@iu...> - 2013-03-16 23:26:05
|
Hi, please use the empty constructor when putting objects into global scope, i.e. viennacl::vector<double> x; The OpenCL backend only becomes available in main(). You can then resize x accordingly: x.resize(s); This should resolve the issue. Best regards, Karli On 03/16/2013 04:21 PM, Sajjadul Islam wrote: > Hi > > Here goes the backtrace output from the gdb: > > /////////////////////////////////////////////////////////////// > (gdb) bt > #0 0xb7d9ac5d in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () > from /usr/lib/i386-linux-gnu/libstdc++.so.6 > #1 0x0804ca92 in std::_Rb_tree<long, std::pair<long const, bool>, > std::_Select1st<std::pair<long const, bool> >, std::less<long>, > std::allocator<std::pair<long const, bool> > > >::_M_insert_unique(std::pair<long const, bool> const&) [clone > .constprop.312] () > #2 0x0804ccc3 in std::_Rb_tree<long, std::pair<long const, bool>, > std::_Select1st<std::pair<long const, bool> >, std::less<long>, > std::allocator<std::pair<long const, bool> > > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<long const, > bool> >, std::pair<long const, bool> const&) [clone .constprop.310] () > #3 0x08057bdb in viennacl::ocl::backend<false>::current_context() () > #4 0x0805827e in > viennacl::backend::memory_create(viennacl::backend::mem_handle&, > unsigned int, void const*) () > #5 0x08058fd2 in viennacl::vector<float, 1u>::vector(unsigned int) () > #6 0x0804c41f in _GLOBAL__sub_I_hvfield () > #7 0x08078542 in __libc_csu_init () > #8 0xb7b6746a in __libc_start_main () from /lib/i386-linux-gnu/libc.so.6 > #9 0x0804c611 in _start () > (gdb) > /////////////////////////////////////////////////////////////// > > > Thanks > Sajjadul > > On Sat, Mar 16, 2013 at 7:44 PM, Karl Rupp <ru...@iu... > <mailto:ru...@iu...>> wrote: > > Hi, > > well, I can't trace the problem with sources I can't compile ;-) > Could you please compile your program (with global > viennacl::vector<> objects) with debug symbols, run it in a debugger > and send me the stacktrace when it segfaults? > > On Linux this is something like > $> gdb path_to/your_program > (gdb) r > (gdb) bt > > Thanks and best regards, > Karli > > > > On 03/16/2013 12:19 PM, Sajjadul Islam wrote: > > Hi > > Lets give you the glimpse of the inclusion ,declaration and > definition > of viennacl stuffs in the project. After the inclusion of the > opencl and > opengl related header files i include the viennacl stuff as follows: > > //////////////////////////////__//////////////////////////////__//////////////////////////////__//////////////////////////////__/ > #define VIENNACL_WITH_OPENCL > > > // include basic scalar and vector types of ViennaCL > #include "viennacl/vector.hpp" > #include "viennacl/matrix.hpp" > > // include FFT routines > #include "viennacl/fft.hpp" > > //////////////////////////////__//////////////////////////////__//////////////////////////////__//////////////////////////////__/ > > Then i declare the std and viennacl vector in the global scope > as follows: > > > //////////////////////////////__//////////////////////////////__//////////////////////////////__/////////////////////////// > typedef float cData; > > > > //allocate a host vector with a certain size > //we are storing the 2D vector field, so each x-component > //and y-component are stored in a linear manner > //so the dimension DS is multiplied by 2 > std::vector<cData> hvfield(DS * 2); > > //allocate the vector of same size on the device > viennacl::vector<cData> dvfield(DS * 2); > > > viennacl::vector<cData> vxfield(PDS * 2); > viennacl::vector<cData> vyfield(PDS * 2); > > //////////////////////////////__//////////////////////////////__//////////////////////////////__//// > > > Then i compile and get the segmentation fault if i try to run > it. I do > not get any segmentation fault if i put the immediate above > declaration > inside the main() scope and the application runs fine. > > > I am using the recent release from the repository. For sake of more > clarity . i am attaching the main file which you might not be > able to > compile since i am using some of the NVDIA SDK's pre-built function > here. Look for "SAJJAD'S INCLUSION" and "SAJJAD'S ADDITION" in > the file. > > Let me know if i described enough details. > > Thanks > Sajjadul > > On Sat, Mar 16, 2013 at 5:45 PM, Karl Rupp > <ru...@iu... <mailto:ru...@iu...> > <mailto:ru...@iu... <mailto:ru...@iu...>>__> > wrote: > > Hi, > > you can of course pass vectors to functions, preferably by > reference > in order to avoid expensive copies. > > Could you please describe the segmentation faults you're > getting > when using global variables in more detail? Are you using > the latest > 1.4.1 release? This was a bug in 1.3.x, but should be fixed > now. > > Best regards, > Karli > > > > On 03/15/2013 08:23 PM, Sajjadul Islam wrote: > > Hi > > > Thanks for the hint! > > I need to use the vectors build on the device to be > usable across > several function in the host. For example > > > //////////////////////////////____////////////////////////////__//__//////////////////////////__////__//////// > > > int main() > { > ......................... > > ......................... > > //allocate a host vector with a certain size > //we are storing the 2D vector field, so each > x-component > //and y-component are stored in a linear manner > //so the dimension DS is multiplied by 2 > std::vector<cData> hvfield(DS * 2); > //fill the cpu vector with the default values - 0.0f > std::fill(hvfield.begin(),____hvfield.end(),0.0f); > > > //allocate the vector of same size on the device > viennacl::vector<cData> dvfield(DS * 2); > > //copy the vector from the cpu to the gpu > > copy(hvfield.begin(),hvfield.____end(),dvfield.begin()); > > viennacl::vector<cData> vxfield(PDS * 2); > viennacl::vector<cData> vyfield(PDS * 2); > > > ..............................____............................__..__........ > > > ..............................____............................__..__........ > > > } > > > void display() > { > simulateFluids(); > } > > > void simulateFluids(.....) > { > //i need to use some vectors here that has been > allocated > in the > main function > } > > > //////////////////////////////____////////////////////////////__//__//////////////////////////__////__//////// > > > > Now if i put the vector allocation at the global scope > i get > segmentation fault while running the program. OpenGL's > callback > display() function do the necessary calculation for the > fluid > simulation > and i need to access the vectors i have allocated. Can > they (the > ones > allocated on the device) be sent as reference in the > function > parameter ? > > I checked the tutorials and none of them matched my > requirements. > > Any hint? > > > Regards > Sajjadul > > On Wed, Mar 13, 2013 at 4:50 PM, Karl Rupp > <ru...@iu... <mailto:ru...@iu...> > <mailto:ru...@iu... <mailto:ru...@iu...>> > <mailto:ru...@iu... > <mailto:ru...@iu...> <mailto:ru...@iu... > <mailto:ru...@iu...>>__>__> > > wrote: > > Hi Sajjadul, > > just define a > viennacl::vector<float>(2*PDS)______; > or > viennacl::vector<double>(2*______PDS); > > > and then fill it with the real part on locations > [0],[2], > etc. and > the imaginary part on locations [1],[3], etc. > This is pretty similar to what you actually do > with cufft. > > The lack of complex_t in current OpenCL is one of the > reasons why > FFT in ViennaCL is still experimental. Thus, you > cannot > properly > define a float2 on the CPU without running into > compiler > problems > (nvcc can only do this because they have control > over the full > compilation and thus can do any non-standard-compliant > stuff they want). > > Best regards, > Karli > > > > > > On 03/13/2013 09:43 AM, Sajjadul Islam wrote: > > Hi forum, > > > I am trying to port an existing CUDA > application to > OpenCL, and the > process seems not to be so trivial while > working with > the custom > data > type and FFT. Below i am describing some > custom data > type that > has been > assigned in CUDA and my effort to convert them to > opencl and > also the > issues that i am currently stuck with: > > > *CUDA* > * > * > * > > * > // Vector data type used to velocity and force > fields > //typedef is a built-in vector types > typedef float2 cData; > > > //each of the allocation is of size 131584 > cudaMalloc((void**)&vxfield, > sizeof(cData) * PDS); > cudaMalloc((void**)&vyfield, > sizeof(cData) * PDS); > > > ..............................______......... > ..............................______........ > > > > // Create CUFFT transform plan configuration > // create a simple plan for 2D transformation > cufftPlan2d(&planr2c, DIM, DIM, CUFFT_R2C); > cufftPlan2d(&planc2r, DIM, DIM, CUFFT_C2R); > // TODO: update kernels to use the new > unpadded memory > layout for perf > // rather than the old FFTW-compatible layout > cufftSetCompatibilityMode(______planr2c, > CUFFT_COMPATIBILITY_FFTW_______PADDING); > cufftSetCompatibilityMode(______planc2r, > CUFFT_COMPATIBILITY_FFTW_______PADDING); > > > ..............................______. > > > .............................. > > // Forward FFT > cufftExecR2C(planr2c, (cufftReal*)vx, > (cufftComplex*)vx); > cufftExecR2C(planr2c, (cufftReal*)vy, > (cufftComplex*)vy); > > ..............................______. > > > .............................. > > // Inverse FFT > cufftExecC2R(planc2r, (cufftComplex*)vx, > (cufftReal*)vx); > cufftExecC2R(planc2r, (cufftComplex*)vy, > (cufftReal*)vy); > > > > *OpenCL* > * > > * > Even if i define custom data type for i am not > sure if > i can use it > along with the ViennaCL as you currently are not > supporting any type > other than double / float. > > I need to send data to fft function that is of > type > cl_float2 as > you can > imagine from the above CUDA fft statements. > > Still i believe that there must be some way > to get > around this > issue > and i need you suggestion. > > > I shall be eagerly waiting for your response > over this > issue. > > > > Regards > Sajjad > > > > > ------------------------------______--------------------------__--__--__------------------ > > > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_______d2d_mar > <http://p.sf.net/sfu/appdyn_____d2d_mar> > <http://p.sf.net/sfu/appdyn_____d2d_mar > <http://p.sf.net/sfu/appdyn___d2d_mar>> > <http://p.sf.net/sfu/appdyn_____d2d_mar > <http://p.sf.net/sfu/appdyn___d2d_mar> > <http://p.sf.net/sfu/appdyn___d2d_mar > <http://p.sf.net/sfu/appdyn_d2d_mar>>> > > > > > _____________________________________________________ > ViennaCL-support mailing list > ViennaCL-support@lists.__sourc____eforge.net > <http://sourc__eforge.net> > <http://sourceforge.net> > <mailto:ViennaCL-support@ > <mailto:ViennaCL-support@>__lis__ts.sourceforge.net > <http://lists.sourceforge.net> > <mailto:ViennaCL-support@__lists.sourceforge.net > <mailto:Vie...@li...>>> > https://lists.sourceforge.net/______lists/listinfo/viennacl-______support > <https://lists.sourceforge.net/____lists/listinfo/viennacl-____support> > > <https://lists.sourceforge.__net/__lists/listinfo/viennacl-____support > <https://lists.sourceforge.net/__lists/listinfo/viennacl-__support>> > > <https://lists.sourceforge.____net/lists/listinfo/viennacl-____support > > <https://lists.sourceforge.__net/lists/listinfo/viennacl-__support > <https://lists.sourceforge.net/lists/listinfo/viennacl-support>>> > > > > > > > > > ------------------------------____----------------------------__--__------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_____d2d_mar > <http://p.sf.net/sfu/appdyn___d2d_mar> > <http://p.sf.net/sfu/appdyn___d2d_mar > <http://p.sf.net/sfu/appdyn_d2d_mar>> > > > > ___________________________________________________ > ViennaCL-support mailing list > ViennaCL-support@lists.__sourc__eforge.net > <http://sourceforge.net> > <mailto:ViennaCL-support@__lists.sourceforge.net > <mailto:Vie...@li...>> > https://lists.sourceforge.net/____lists/listinfo/viennacl-____support > <https://lists.sourceforge.net/__lists/listinfo/viennacl-__support> > <https://lists.sourceforge.__net/lists/listinfo/viennacl-__support > <https://lists.sourceforge.net/lists/listinfo/viennacl-support>> > > > > > > ------------------------------__------------------------------__------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn___d2d_mar > <http://p.sf.net/sfu/appdyn_d2d_mar> > > > > _________________________________________________ > ViennaCL-support mailing list > ViennaCL-support@lists.__sourceforge.net > <mailto:Vie...@li...> > https://lists.sourceforge.net/__lists/listinfo/viennacl-__support <https://lists.sourceforge.net/lists/listinfo/viennacl-support> > > > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar > > > > _______________________________________________ > ViennaCL-support mailing list > Vie...@li... > https://lists.sourceforge.net/lists/listinfo/viennacl-support > |