My cuda code works fine. but when I include the following on top of my code it gives some errors.
surface<void,2> sImg;
fatal : Parsing error near '.surf': syntax error
How can I solve this?
When I declare "sImg" inside the main method it compiles..
The following doesnt work..
surface<void,2> sImg;
int main()
{
return 0;
}
I changed
Properties-->CUDA Runtime API-->GPU-->GPR Architecture1 to sm_20
Now it compiles..
Are you declaring it inside a .cu file where the kernel using the surface is declared ?
That statements needs to be parsed by the nvcc compiler to become effective.
If that does not work then post the error log of the compiler.
Related
I'd like to be able to obtain untyped pointers to functions/procedures while in {$MODE FPC} so code illustrated by the following example can work instead of getting an "Incompatible types" error, anyone know how?
program Project1;
{$MODE FPC}
{$MODESWITCH POINTERTOPROCVAR ON} // doesn't stop error
{$TYPEDADDRESS OFF} // doesn't stop error
function new_getmem(asize:longint):pointer;
begin
new_getmem:=nil;
end;
var
mem_mgr_new:tmemorymanager;
begin
mem_mgr_new.GetMem:=#new_getmem; // Error: Incompatible types...
pointer(mem_mgr_new.GetMem):=#new_getmem; // both those work but I'd prefer the
mem_mgr_new.GetMem:=pointer(#new_getmem); // clean code of the line that doesn't work
end.
EDIT:
There used to be an answer below that answered this properly, but it went away. The discussion allowed me to find out that both {$MODESWITCH CLASSICPROCVARS ON} and {$MODESWITCH POINTERTOPROCVAR ON} need to be specified for the desired line to compile, but like was explained, this opens up lots of possibilities for errors, so use with care only when necessary.
I'm running CPLEX through the COIN/OSI interface (OsiCpxSolverInterface). For some large LPs I get an error message CPX0000 CPLEX Error 1001: Out of memory.
Despite the error message, no exception (CoinError) is thrown. Looking at the source code of OsiCpxSolverInterface it looks like the return code of CPXlpopt must have been 0.
To be clear: my question is not how to avoid the out-of-memory problem. I'm just looking for a way to detect it from my program.
I found a hack that works for me. Setting an error handlers log level to 0 only allows error messages through. Overwriting the MessageHandler's print method then allows to react to the error. This workaround is definitely a hack. If anyone has any better suggestions, I'd be happy to accept a different answer.
class ErrorCatchingCoinMessageHandler: public CoinMessageHandler {
public:
ErrorCatchingCoinMessageHandler()
: CoinMessageHandler() {
// Would be nice to also overwrite setLogLevel to avoid later changes
// but its not virtual
setLogLevel(0);
}
virtual int print() __attribute__((noreturn)) {
CoinMessageHandler::print();
abort(); // or throw a CoinError
}
};
// Use it like this
lp_solver->passInMessageHandler(new ErrorCatchingCoinMessageHandler());
I was working on a class "Board" that seemed to do everything just fine. Somehow, after about an hour of work on other classes, Board showed some pretty odd behavior in terms of errors.
//headerfile
#pragma once
using namespace System;
#include "stdafx.h"
ref class Board
{
public:
Board();
~Board();
void printToConsole();
private:
array<int^, 2>^ boardData;
};
The Errors i got for this code are:
Error 1 error C2143: syntax error : missing ';' before 'using' e:\users\felix\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\Board.h Line:4 Column:1 ConsoleApplication1
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int e:\users\felix\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\Board.h Line:4 Column:1 ConsoleApplication1
Line 4 is "using namespace System;" Can anybody explain what I did wrong?
This seems particularly odd because I've got another class "Pattern" that looks pretty much like this but does not output any error.
EDIT:
So as some of you already told me, the semicolon may be missing in the headerfile i included before this one. Also there was a similar question, thanks for posting that one ;)
so this now is my stdafx.h (without comments):
#pragma once
#include "Board.h"
#include "Pattern.h"
#include <string>
#include <iostream>
as far as I know this pragma was there when I created this Console Application with VS, so there doesn't seem to be anything ever executed before including "Board.h".
I overlooked all my other files and I have never included Board anywhere else than here...
EDIT 2:
as I try to track down the error further, i noticed a missing "using namespace System;" in another class which I inserted. This resulted in a pretty interesting behavior, as the error now gets located in stdafx.h when I use namespace System in there aswell. If I don't the error will be located in the first file that gets included in stdafx.h
When I change the order of files, the first one always is the one that seems to be missing a ; before "using"... strange thing.
Heureka!
The mistake lay in stdafx.cpp wich I find strange because I can't remember to have ever edited it but, oh well.
stdafx//.cpp : source file that includes just the standard includes
// ConsoleApplication1.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
as you can clearly see, "stdafx" got interpreted as an incomplete statement where a type-specifier and a ';' were missing, thus the two errors.
As everyone in the comments already told me correctly, the error then was kinda send downwards by inclusion to the other classes. and was shown where the first real line of code (not directives) occurred.
the chain worked as follows:
stdafx.cpp -> stdafx.h -> the first headerfile included in stdafx.h -> "using namespace System;"
Anyway thanks for the help, I wouldn't have figured this out anyway else :)
I am trying to use ITK within QT (New to QT and rusty in ITK) I was finally able to define the include paths and .lib but I am still not able to run my code. It is a simple dicom reader:
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
typedef itk::Image< InputPixelType, InputDimension > InputImageType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "C:\Users\dmilford\Desktop\PvMRIm1" );
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
The error comes at the last line and I get the following error
ITKIOGDCM-4.2.lib(itkGDCMImageIO.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall gdcm::Rescaler::SetPixelFormat(class gdcm::PixelFormat const &)" (__imp_?SetPixelFormat#Rescaler#gdcm##QAEXABVPixelFormat#2##Z) referenced in function "public: virtual void __thiscall itk::GDCMImageIO::Read(void *)" (?Read#GDCMImageIO#itk##UAEXPAX#Z)
100 odd times over.
Does anyone know how to solve this linker error or know were I might get a hint to the answer?
This link error probably is from the inconsistent compiled version between ITK and your Qt compiler. Make sure your ITK is built with the MSVC2010, for example, while your Qt SDK default compiler is the same.
Please try using CMake to generate the build files. It takes much less time, and all your issues will go away.
In cython when my code is compiled with
#cython.wraparound(True)
and I use the following cast function to convert (cast) a float to an integer
cdef DTYPE_t_I float_int(np.float_t val):
return <DTYPE_t_I>val
it runs ok
BUT
when I turn off
#cython.wraparound(False)
the code compiles normally and when it runs it gives the following error
CORE GENERATED
It happens compiling in linux with gcc and windows with MGS
What is wrong? Should it be like this?
Because I am trying to gain speed, I would like to know to switch off these flag.