Which header file to be included for following code snippet to measure time using cuda event mathods?
cudaEvent_t start,stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);
float Elapsed=0,Cycle;
for (int p=1; p<=MSG_NUM; p++)
{
cudaEventRecord(start,0);
add<<<R, (M+R), (M+R)* sizeof(int)>>>( d_msg, d_checkSumArray );
cudaEventRecord(stop,0);
cudaEventSynchronize(stop);
cudaElapsedTime(&Cycle,start,stop);
Elapsed += Cycle;
}
printf("Time = %f",Elapsed);
My program show following error as no header file included.
error : identifier "cudaElapsedTime" is undefined
Can someone give the solution please?
The correct API call is cudaEventElapsedTime(...).
Other than that your parameters look correct.
You don't need any special include headers if you are compiling with nvcc.
Related
mpdf.create_pvf(card, mpImgBytes, mlen, L"");
int inDoc = mpdf.open_pdi_document(card, L"");
I am using pdflib version 9.3.
open_pdi_document returns -1
create_pvf creates an empty file of size 0.
Any idea on what could be wrong?
I am running pdflib on Windows 10, using C++.
I would recommend that you also retrieve the error reason in case of an error (open_pdi_document() returns -1) or work with the PDFlib errorpolicy "exception". Then you will get a first impression what the problem might be, then your code could looks like
/* Open the input PDF */
indoc = mpdf.open_pdi_document(card, L"");
if (indoc == -1) {
wcerr << L"Error: " << mpdf.get_errmsg() << endl;
return 2;
}
create_pvf creates an empty file of size 0.
how did you identify that?
Not sure how relevant my answer is, but this could help someone.
Installing ghostscript on my machine, resolved the error.
I am learning vulkan and have come accross an error "Unhandled exception at 0x00007FF98C0D16B5 (vulkan-1.dll) in ProjectV.exe: 0xC0000005: Access violation reading location 0x0000000000000000. occured"in an unusual step.
Usually at this step I am not supposesd to encounter any problems.In the second line of the code snippet Ive counted the number of QueueFamilies using the countIndex variable.I used this function before in a different method while creating Logical Device but have not received any error then but now I do so.I am receiving the title error at line 3 of the snippet, at the cout line.
Although I am not supposed to get error at such simple step.I even tried static_cast while printing because I thought the data type created a problem, but that too did not work.
uint32_t countIndex=0, queue_fam_index=0; VkBool32 check = VK_FALSE;
vkGetPhysicalDeviceQueueFamilyProperties(dev, &countIndex,nullptr);
std::cout << static_cast<int>(countIndex) << "\n";
std::vector<VkQueueFamilyProperties> que_fam(countIndex);
vkGetPhysicalDeviceQueueFamilyProperties(
dev,&countIndex,que_fam.data());
I have a function as below :
function LONG ImportSSL(hMSI)
STRING exeDir;
STRING sslDir;
NUMBER nvSize;
LONG ret;
begin
nvSize = 256;
MsiGetProperty (hMSI, "SETUPEXEDIR", exeDir, nvSize);
sslDir = exeDir ^ "ssl\\myCertificate.pfx";
ret = LaunchAppAndWait(WINDIR, "certutil -f -p \"\" -importpfx \"" + sslDir + "\"", WAIT);
if (ret != 0) then return ret; endif;
return 0;
end;
by running Setup.exe as below:
MySetup.exe /v"/l*v c:\SetupLog.log"
I see the below error in log file :
CustomAction ImportSSL returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 16:25:25: ImportSSL. Return value 3.
but when I execute certutil -f -p "" -importpfx "C:\myCertificate.pfx" by command prompt there is no any error , and that certeficate imported into IIS.
How can I know the details of error?
Any help will be truly appreciated.
The problem solution will depend on the following: 1)Is certificate file being delivered by the installer, or is it supposed to be present on the target machine? Check that the installer delivers it as a permanent file, or support file (in [SUPPORTDIR]), or if the file really exists; 2) where this custom action is located? Normally actions like that should be placed after InstallFinalize.
For some reason, I get this error message whenever I try to compile this simple function: Test.hx:1: lines 1-7 : Invalid -main : Test has invalid main function
public static function main(a:Int, b:Int){
trace("Calling main function");
return a+b;
}
I'm not sure why this is happening. What's wrong with this function definition, and how can I get it to compile correctly? I tried reading the documentation, and found it to be unclear in its explanation of how to properly set function return types.
The special main entry function must be a Void->Void function. i.e. No param and no return value is allowed. Remember there is no command line argument concept in JS/Flash, which Haxe also compiles to. So we have to use system targets' API for that:
Sys.args() : Array<String> to get the command line params.
Sys.exit( code : Int ) : Void to exit with exit code.
FYI, the doc of Sys is at http://haxe.org/api/sys
I am having some serious trouble getting a Python 2 based C++ engine to work in Python3. I know the whole IO stack has changed, but everything I seem to try just ends up in failure. Below is the pre-code (Python2) and post code (Python3). I am hoping someone can help me figure out what I'm doing wrong.I am also using boost::python to control the references.
The program is supposed to load a Python Object into memory via a map and then upon using the run function it then finds the file loaded in memory and runs it. I based my code off an example from the delta3d python manager, where they load in a file and run it immediately. I have not seen anything equivalent in Python3.
Python2 Code Begins here:
// what this does is first calls the Python C-API to load the file, then pass the returned
// PyObject* into handle, which takes reference and sets it as a boost::python::object.
// this takes care of all future referencing and dereferencing.
try{
bp::object file_object(bp::handle<>(PyFile_FromString(fullPath(filename), "r" )));
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_object));
}
catch(...)
{
getExceptionFromPy();
}
Next I load the file from the std::map and attempt to execute it:
bp::object loaded_file = getLoadedFile(filename);
try
{
PyRun_SimpleFile( PyFile_AsFile( loaded_file.ptr()), fullPath(filename) );
}
catch(...)
{
getExceptionFromPy();
}
Python3 Code Begins here: This is what I have so far based off some suggestions here... SO Question
Load:
PyObject *ioMod, *opened_file, *fd_obj;
ioMod = PyImport_ImportModule("io");
opened_file = PyObject_CallMethod(ioMod, "open", "ss", fullPath(filename), "r");
bp::handle<> h_open(opened_file);
bp::object file_obj(h_open);
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_obj));
Run:
bp::object loaded_file = getLoadedFile(filename);
int fd = PyObject_AsFileDescriptor(loaded_file.ptr());
PyObject* fileObj = PyFile_FromFd(fd,fullPath(filename),"r",-1,"", "\n","", 0);
FILE* f_open = _fdopen(fd,"r");
PyRun_SimpleFile( f_open, fullPath(filename) );
Lastly, the general state of the program at this point is the file gets loaded in as TextIOWrapper and in the Run: section the fd that is returned is always 3 and for some reason _fdopen can never open the FILE which means I can't do something like PyRun_SimpleFile. The error itself is a debug ASSERTION on _fdopen. Is there a better way to do all this I really appreciate any help.
If you want to see the full program of the Python2 version it's on Github
So this question was pretty hard to understand and I'm sorry, but I found out my old code wasn't quite working as I expected. Here's what I wanted the code to do. Load the python file into memory, store it into a map and then at a later date execute that code in memory. I accomplished this a bit differently than I expected, but it makes a lot of sense now.
Open the file using ifstream, see the code below
Convert the char into a boost::python::str
Execute the boost::python::str with boost::python::exec
Profit ???
Step 1)
vector<char> input;
ifstream file(fullPath(filename), ios::in);
if (!file.is_open())
{
// set our error message here
setCantFindFileError();
input.push_back('\0');
return input;
}
file >> std::noskipws;
copy(istream_iterator<char>(file), istream_iterator<char>(), back_inserter(input));
input.push_back('\n');
input.push_back('\0');
Step 2)
bp::str file_str(string(&input[0]));
loaded_files_.insert(std::make_pair(std::string(fullPath(filename)), file_str));
Step 3)
bp::str loaded_file = getLoadedFile(filename);
// Retrieve the main module
bp::object main = bp::import("__main__");
// Retrieve the main module's namespace
bp::object global(main.attr("__dict__"));
bp::exec(loaded_file, global, global);
Full Code is located on github: