How do I make intel TBB libraries available on Xeon Phi [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am trying to use Intel TBB in a segment of Xeon Phi offload code. The code fails to compile with error error : *MIC* cannot open source file "tbb\parallel_for.h"
I have the MPSS stack installed, I ran the binutils.msi utility, and my includes at the top of the offloaded code file is as follows:
#include <offload.h>
#pragma offload_attribute(push, target(mic))
#include <tbb\parallel_for.h>
#pragma offload_attribute(pop)
//other includes and code follows
Why does this fail?
What do I need to change to offload and run my code sucessfully?
EDIT :
After adding the -tbb option to the "Additional Options for MIC Offload Compiler" the compiler has found the <tbb\parallel_for.h> file however it gives several warnings and errors about tbb library code not being marked shared. follows is my offloaded code segment.
#pragma offload target(mic:0) in(nums) out(results)
tbb::parallel_for<int>(0,ARRAY_SIZE,1,[&](int i)
{
results[i] = findZero(nums[i]);
});

The offload compiler basically consists of two (very) different compilers called separately on the same code. Each of them generally has its own command line, include, and library paths; and not all the command line options translated from host to the MIC compiler. In case of TBB, compiler has special option /Qtbb or just -tbb which takes care of all the paths for both compilers.
Please refer to tbb\examples\GettingStarted\SUB_STRING_FINDER\sub_string_finder_extended.cpp for how to use TBB from offload region. And check out the Makefile for how to build the example.
In order to run the code from MSVC environment, you need to setup the same environment as for Intel Compiler used to build the GettingStarted\Sub_string_finder example. The easy way to duplicate the environment inside MSVC is to run it from the same console window where the example works:
devenv /useenv
Or specifically, you need to set the MIC_LD_LIBRARY_PATH environment variable to point to MIC TBB binaries as shown here for other libraries.

Related

C++ code compiles with Rcpp on Mac but not Windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
This post was edited and submitted for review 15 hours ago.
Improve this question
I'm working on an R software package involving C++ code written by someone else, and on my Mac everything loads and works properly. However, when I migrate the same code to Windows, everything breaks during compilation. I have received two suggestions on how to fix the problem:
In the C++ package it says that I need to add certain CFLAGS to their Makefile to run on Windows, however I don't have a Makefile in my src folder and everything still works on Mac.. is there a proper way to add CFLAGS for Rcpp to run on Windows? Do I need to add a Makefile.win?
The C++ package calls another C++ package (in its external directory) which has compiled Windows binaries in a .vcproj file (besides their actual C++ code). Should this file be included in my src directory for Rcpp to use on Windows?
Thanks!!
Edit: The types of error messages I'm getting on Windows are in two main flavours:
undefined reference to varname (some examples of varname were Rf_xlength, std::basic_streambuf<char, std::char_traits<char> >::seekpos(std::fpos<int>, std::_Ios_Openmode), __imp_R_NilValue, REprintf and __imp__Z11annAllocPtsii.
statements like int figtreeEvaluateDirectTree(int, int, int, double*, double, double*, double*, double, double*) declared without dllimport attribute after being referenced with dll linkage.

Make Program ask for admin rights with code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to make my program ask for admin rights when it starts.
I already found out that you can do this by doing this :
Properties -> Linker -> Manifest File -> UAC Execution Level -> requireAdministrator (/level='requireAdministrator')
So here is my actual question:
Couldn't I change this setting with my code? Because I can do this for example:
#pragma comment (lib, winmm.lib);
and adding a lib is a linker setting too.
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vcprojectengine.vclinkertool.uacexecutionlevel.aspx
I found this but it doesn't seem to work for me, or is there something I may forget by using this code, beacause the compiler tells me that property is undefined?
No you can't do that from code. The #pragma comment directive can pass some information to the linker but it only supports a limited subset of linker commands:
Only the following (comment-type) linker options are available to be
passed to the linker identifier:
/DEFAULTLIB
/EXPORT
/INCLUDE
/MANIFESTDEPENDENCY
/MERGE
/SECTION

Can I port RetroArch to Native Client [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
So I've been cutting my teeth on another coding project, and figured that the best thing that I could try is to port RetroArch all in one Emulator into Native Client, so that it could very well be a packaged app with cloud saves entirely within a browser. Look up the project on Github since I don't have enough links.
The way RetroArch is built on linux is to run a configure script, then make, then sudo make install. Altering the configure agent to select the Native Client compilers, I was able to get a couple seconds into the build when this happened,
http://pastebin.com/0WtrY6aU
using this custom Makefile here.
http://pastebin.com/iv6RmQVr
I figure it's gonna be a long hard road building and debugging this puppy, but where do you recommend I get started?
You're starting from a good place, you've just hit your first compile error.
Here it is:
In file included from settings.c:23:
input/input_common.h:73: error: redefinition of typedef ‘rarch_joypad_driver_t’
driver.h:327: note: previous declaration of ‘rarch_joypad_driver_t’ was here
Here is an excerpt from input_common.h:
typedef struct rarch_joypad_driver
{
...
} rarch_joypad_driver_t;
Here is an excerpt from driver.h:
typedef struct rarch_joypad_driver rarch_joypad_driver_t;
Just as the error says, the typedef is being redefined. I ran a test using gcc 4.6.3 from Ubuntu 12.04:
typedef struct foo { int bar; } foo_t;
typedef struct foo foo_t;
int main() { return 0; }
This compiles and links fine. The same code compiled with x86_64-nacl-gcc (which is using gcc 4.4.3), gives the following error:
typedef.c:2: error: redefinition of typedef ‘foo_t’
typedef.c:1: note: previous declaration of ‘foo_t’ was here
It seems that this error has been relaxed in more recent versions of gcc. I did some searching and found this stackoverflow link: Why "Redefinition of typedef" error with GCC 4.3 but not GCC 4.6?.
It's worth noting that x86_64-nacl-g++ will compile this code unmodified. Here are two things to try:
Compile with CC using x86_64-nacl-g++ instead of x86_64-nacl-gcc
ifdef out the definition in driver.h, and replace the other use in that file with struct rarch_joypad_driver.
For #2, you can use the following:
#ifndef __native_client__
...
#endif
Good luck, there likely will be more compile failures to fix. :)

gdb automatically steps into inline functions

I'm debugging a running program with gdb 6.6 on solaris, and noticed that sometimes gdb steps into (inline) functions, even though I issued a next command.
My development host was recently reinstalled with a slightly newer build of solaris 10, and I know for sure the auto-stepping was not present before the host was reinstalled. The code is compiled with the same options since the makefiles and all the source code is unchanged since host reinstallation.
Is there any setting/new default option which influences gdb's debugging behaviour that I can check? Does anyone know why my gdb now auto-steps? Its a pain really ...
[edit] to clarify: I did not mean the inline keyword, but rather methods/functions which are implemented in the header file. Example:
header.hpp:
class MyClass
{
public:
void someFunc() { ... does something }
}
source.cc:
{
MyClass instance;
instance.someFunc(); // doing NEXT in gdb will actually STEP into header.hpp
}
Your new version of Solaris may have included a new version of the C or C++ compiler. The new compiler may be optimizing more aggressively than it did before. Check your optimization flags. If you are using GCC, you can disable inlining with -fno-inline (note that methods that are implemented in the class in header files are inlined by default which can be disabled with -fno-default-inline). If you are using the native Solaris compiler, you will need to check its documentation.
A similar problem was reported here. In the comment, the poster mentioned changing the debug symbol to use STABS resolved the issue.
You mentioned in a comment to my answer that STABS works, but is not acceptable. Also, you mentioned that you are unable to reproduce the issue with a simple example. It will be difficult to trouble shoot this issue if you have to recompile your entire project each time to perform a test. Try to isolate the problem to a few source files in your project. See what they have in common (do they include a common header file, do they use a pragma, are the compilation options a little different from the other source fies, etc.), and try to create a small example with the same problem. This will make it easier to identify the root cause of your issue and determine how to resolve it. Without this data, we are just the blind leading the blind.

How do I compile a .cpp file on Linux? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm fairly comfortable with Linux and compiling things - I normally just follow the instructions and can manage to get myself out of trouble. This time, I was given a .cpp file by a random Internet citizen and I would really like to know how to compile it. Everything I seem to try (g++, c++, gcc) doesn't seem to work.
Anyhow, here's the file: http://pastebin.ca/2073013
Edit: Updated with verbose output from g++ file.cpp -o whatever: http://pastebin.ca/2073052
You'll need to compile it using:
g++ inputfile.cpp -o outputbinary
The file you are referring has a missing #include <cstdlib> directive, if you also include that in your file, everything shall compile fine.
The compiler is telling you that there are problems starting at line 122 in the middle of that strange FBI-CIA warning message. That message is not valid C++ code and is NOT commented out so of course it will cause compiler errors. Try removing that entire message.
Also, I agree with In silico: you should always tell us what you tried and exactly what error messages you got.
Just type the code and save it in .cpp format. then try "gcc filename.cpp" . This will create the object file. then try "./a.out" (This is the default object file name). If you want to know about gcc you can always try "man gcc"