thread error no matching function for call to - multithreading

i getting error like this please help me
test.cpp:147:57: error: no matching function for call to ‘std::thread::thread(void (*)(double*, double (*)[3], int, int, int, int), double [(lines_count + 1)], double [8][3], int, int, int, int)’
my code header is below
void loop(double data[500000],double outputmatrix[50][3],int loopA,int loopB,int indeks,int datasize){}
i trying this code for thread
std::thread th1(&loop,data,test,10,(0+1)*300,0,99999);

Related

Bison bug when passing functions as arguments to yyparse?

I am in the process of re-writing a parser in order to make it reentrant. In that spirit, I am interested in passing a couple of functions to bison and then have bison pass them to lex also.
One of those functions is a callback which I use in my actions and the other one is the the function to be called by flex to get input data.
To do so, I have put this in my .y file:
%lex-param {void (*my_input)(void *, char*, int *, int)}
%parse-param {void (*my_input)(void *, char*, int *, int)}
%parse-param {void *(*my_callback)(void *, char *, int, struct YYLTYPE *, int, ...)}
Then, in my .l file I have declared:
#define YY_DECL int yylex (YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, void (*my_input)(void *, char*, int *, int))
The problem is that I think bison might have a bug when generating its code. When I try bo build, i get the following error:
tmp.tab.c: In function ‘yy_symbol_value_print’:
tmp.tab.c:4043: error: expected expression before ‘)’ token
If we visit that line we get this function:
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, yyscan_t scanner, void (*my_input)(void *, char*, int *, int), void *(*my_callback)(void *, char *, int, struct YYLTYPE *, int, ...))
{
FILE *yyo = yyoutput;
YYUSE (yyo);
YYUSE (yylocationp);
YYUSE (scanner);
YYUSE (int);
YYUSE (int);
if (!yyvaluep)
return;
YYUSE (yytype);
}
The first line with YYUSE(int) is the one throwing the error. As you can see, this function somehow receives the same arguments as yyparse, then it calls a macro called YYUSE() with the arguments received. I think that since two of my arguments are functions (with their arglist, as they have to be declared if I understand correctly) bison calls YYUSE() with the last argument of each of those function prototypes... as far as I know it should be USE(my_input) and USE(my_callback)...
I have a hard time believing this is really a bug, I mean, really, nobody has tried this until now? I find it hard to believe...
The YYUSE() calls are all over the generated files, even though I dont really know what they are for... So changing by hand is not really an option...
Has anybody done this successfully in the past? Is there something I am doing wrong?
Bison's parameter parser is a little primitive. It expects to see something like %param {type name}, and if it finds something more complicated, it may do the wrong thing. (type can be reasonably complicated; it can include const, *, and other such modifiers. But the name needs to be the last thing in the specification.)
This is documented in the Bison manual: (emphasis added)
Directive: %parse-param {argument-declaration} …
Declare that one or more argument-declaration are additional yyparse arguments. The argument-declaration is used when declaring functions or prototypes. The last identifier in argument-declaration must be the argument name.
A similar restriction applies to tagnames in a %union directive.
You can make your program more readable both for bison and for human readers by using typedefs:
Put this in a common header file:
typedef void (*InputFunction)(void *, char*, int *, int);
typedef void *(*CallbackFunction)(void *, char *, int, struct YYLTYPE *, int, ...);
Bison file:
%lex-param {InputFunction my_input}
%parse-param {InputFunction my_input} {CallbackFunction my_callback}
Flex file:
#define YY_DECL int yylex (YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner, InputFunction my_input)
By the way, the intent of the YY_USE macro is to mark parameters as "used", even if they are not; this avoids compiler warnings in functions which happen not to use the arguments. It could be argued that it is the programmer's responsibility to ensure that arguments are either used or marked as unused, but that's not the approach bison happened to take. Regardless, non-conforming parameter declarations such as the one you provided will fail in other interesting ways, even without YY_USE.

wxc-0.91.0.0 failed to install

I'm trying to install reactive-banana, wx, wxcore in cabal sandbox. When cabal install --only-dependencies is run following error message is given:
src\cpp\eljlistctrl.cpp: In function 'int ListCmp(long int, long int, long int)':
src\cpp\eljlistctrl.cpp:16:23: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
src\cpp\eljlistctrl.cpp:16:53: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
src\cpp\eljlistctrl.cpp: In function 'bool wxListCtrl_SortItems(wxListCtrl*, void*, void*)':
src\cpp\eljlistctrl.cpp:478:41: error: cast from 'EiffelSort* {aka _EiffelSort*}' to 'long int' loses precision [-fpermissive]
src\cpp\eljlistctrl.cpp:478:44: error: invalid conversion from 'int (*)(long int, long int, long int)' to 'wxListCtrlCompare {aka int (*)(long long int, long long int, long long int)}' [-fpermissive]
C:\wxWidgets-3.0.2\include/wx/msw/listctrl.h:342:10: error: initializing argument 1 of 'bool wxListCtrl::SortItems(wxListCtrlCompare, wxIntPtr)' [-fpermissive]
What is wrong and how to solve this?
The code in this file just seems to be wrong and uses 32 bit types even in what looks like 64 bit build. Unless it was fixed in later versions, the only solution would be to build it in 32 bits, i.e. use a 32 bit Haskell installation.

using libimagequant in android ndk

Has anyone used successfully the quantizer "libimagequant" library in android NDK?
The library can be found here: http://pngquant.org/lib
The problem I'm facing is when calling liq_image_create_rgba, the compiler complains with:
Invalid arguments '
Candidates are:
* liq_image_create_rgba(*, void *, int, int, double)
'
Seems the problem is the first parameter (liq_attr). But I can't understand why is complaining and how to solve it.
liq_attr* liqAttr = liq_attr_create();
liq_image* liqImage = liq_image_create_rgba(liqAttr, reinterpret_cast<void*>(bitmapPixels), width, height, 0);
In my version of libimagequant.c the liq_image_create_rgba function is declared as follows:
LIQ_EXPORT liq_image *liq_image_create_rgba(liq_attr *attr, void* bitmap, int width, int height, double gamma)
The first parameter is a liq_attr *, maybe yours is missing its pointer type?

Mistake when compiling under Linux a CUDA code originally developed under Windows

The code was developed from Windows system, when I compile my CUDA code in Linux system by command:
nvcc lbm.cu -I/usr/local/cuda_sdk/CUDALibraries/common/inc -lm
Compiler output is:
In file included from lbm.cu:15:
lbm_kernel.h:52:8: warning: extra tokens at end of #endif directive
In file included from lbm.cu:15:
lbm_kernel.h:52:8: warning: extra tokens at end of #endif directive
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "main":
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0xce7): undefined reference to "cutCheckCmdLineFlag"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2103): undefined reference to "diff_wz_w(dim3, int, double*, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2143): undefined reference to "double gpu_sum<double>(int, int, int, int, int, double*, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x21ca): undefined reference to "fabs_wz(dim3, int, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x220a): undefined reference to "double gpu_sum<double>(int, int, int, int, int, double*, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x22a3): undefined reference to "cpy(dim3, int, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2320): undefined reference to "lbm_step(dim3, int, int, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x23b5): undefined reference to "lbm_bounce_back_exit_inlet(dim3, int, int, float, float, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x248f): undefined reference to "lbm_bounce_back_hole_wall_1(dim3, int, int, float, float, int, int, int, int, int, int, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2501): undefined reference to "lbm_bounce_back_wall_2(dim3, int, int, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x25a2): undefined reference to "lbm_stream(dim3, int, int, double*, double*)"
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text+0x2643): undefined reference to "lbm_den_vel(dim3, int, int, double*, double*, double*, double*, double*)"
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "__cutilExit(int, char**)":
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text._Z11__cutilExitiPPc[__cutilExit(int, char**)]+0x21): undefined reference to "cutCheckCmdLineFlag"
/tmp/tmpxft_00001fda_00000000-13_lbm.o: In function "cutilDeviceInit(int, char**)':
tmpxft_00001fda_00000000-1_lbm.cudafe1.cpp:(.text._Z15cutilDeviceInitiPPc[cutilDeviceInit(int, char**)]+0x8b): undefined reference to "cutGetCmdLineArgumenti"
collect2: ld returned 1 exit status
What can I do for my code?
You'll need to include the library that contains the functions that are still listed as "undefined reference:
cutCheckCmdLineFlag
cutGetCmdLineArgument
These functions can probably be added to your link process using a modification of your compile command line to something like this:
nvcc lbm.cu -I/usr/local/cuda_sdk/CUDALibraries/common/inc -L/usr/local/cuda_sdk/shared/lib -lshrutil -lcutil -lm
Anyway, you want to find the libraries libshrutil.a or libshrutil_x86_64.a and libcutil.a or libcutil_x86_64.a and you want to link them into your program by specifying the path to these libraries using the -L switch and specifying the library name (minus the lib in the beginning and the .a at the end) using the -l switch.

GCC warning when using CAPI calling convention

When using CAPI like this:
// libvlc.h
libvlc_instance_t *libvlc_new (int argc, const char *const *argv)
// VLC.hs
foreign import capi "vlc/libvlc.h libvlc_new" vlcNew :: CInt -> Ptr CString -> IO (Ptr Libvlc)
I'm getting the warning
/tmp/ghc3011_0/ghc3011_0.c: In function ‘ghc_wrapper_d18b_libvlc_new’:
/tmp/ghc3011_0/ghc3011_0.c:10:1:
warning: passing argument 2 of ‘libvlc_new’ from incompatible pointer type [enabled by default]
In file included from /tmp/ghc3011_0/ghc3011_0.c:7:0:
/usr/include/vlc/libvlc.h:138:1:
note: expected ‘const char * const*’ but argument is of type ‘HsInt8 **’
Compiles cleanly when using ccall.
It seems to be fine, but it's still a warning. Is there anything I can do about it?

Resources