Saturday, January 30, 2010

comp.lang.c++ - 20 new messages in 12 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* isspace - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en
* system("ls") - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ea8887c99b1a8b02?hl=en
* advice on try - throw - catch - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/24c6f05e5ff8da82?hl=en
* typedefs and namespaces - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/14757947dce647b0?hl=en
* change function - 4 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/98d241e38cad9662?hl=en
* Another strange linux kernel change - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e05a4158a9750a03?hl=en
* Help: Want to setup the IPP environment inside of my program - 3 messages, 2
authors
http://groups.google.com/group/comp.lang.c++/t/7a5ab98ed0dde279?hl=en
* Looking for C++ IDE,... - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/e8a1db0949215858?hl=en
* Help: libiomp5md.dll takes 46.22% individual work reported by Visual Studio
Profiler - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/08adc6ce31d50518?hl=en
* Advice on using templates and vector to improve exception handling - 2
messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/36f052e700775e41?hl=en
* web designer , netobjectsfusion 11 , fusion9 , kaufen artikel , nof vista ,
website design services , web page designing , nof europe , webseiten designer
software , pc spiele bestellen , - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e7156786f895b1f4?hl=en
* DavidC - Trung Kien - Brian - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/248b5df63ba9c39f?hl=en

==============================================================================
TOPIC: isspace
http://groups.google.com/group/comp.lang.c++/t/89ca303518428e34?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 10:12 am
From: Paavo Helde


gervaz <gervaz@gmail.com> wrote in
news:995e2805-ab97-4c11-ae49-fcce01682bb3@b9g2000yqd.googlegroups.com:

> On 29 Gen, 09:09, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
>> gervaz <ger...@gmail.com> wrote in news:df9f84a1-a933-4063-bca5-
>> f18c440b9...@l19g2000yqb.googlegroups.com:
>>
>>
>>
>> > On Jan 28, 11:46 pm, James Kanze <james.ka...@gmail.com> wrote:
>> >> On 28 Jan, 21:25, gervaz <ger...@gmail.com> wrote:
>>
>> >> > On Jan 28, 9:40 pm, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
>> >> > > gervaz <ger...@gmail.com> wrote in
>> >> > > news:198ffd0f-8a21-4d23-802f-
>> >> > > cf0f0fee0...@o28g2000yqh.googlegroups.com:
>> >> > > > Hi all, is there a C++ function similar to isspace that
>> >> > > > can handle w_chars? Does the regex library handles
>> >> > > > w_chars?
>> >> > > Yes, there is a template function declared in <locale> and
>> >> > > named std::isspace, curiously enough.
>> >> > > There is no regex librar in the official C++ standard yet I
>> >> > > think. The Boost regex library is fully templated and ought
>> >> > > to support wchar_t as well, but I have not tried this.
>> >> > > According to Boost documentation one needs a separate ICU
>> >> > > library for full Unicode support though.
>> >> > Well, take a look at my snippet:
>> >> > std::ifstream infile(argv[1]);
>> >> > std::string s;
>> >> > while (getline(infile, s))
>> >> > {
>> >> > s.erase(std::remove_if(s.begin(), s.end(), std::isspace), s.end
>> >> > ());
>> >> > std::cout << s;
>> >> > }
>> >> > Using locale on VC++2008 I've got an error reporting that
>> >> > std::isspace expects 2 arguments,
>>
>> >> That's because std::isspace requires two arguments, the
>> >> character to be tested, and the locale.
>>
>> >> > and still I don't know if the file contains unicode characters
>> >> > can be correctly handles.
>>
>> >> The functions in <locale> are pretty useless, since they only
>> >> handle single byte characters. The "approved" solution is to
>> >> read into a wstring using wifstream (embedded with the
>> >> appropriate locale), and use isspace (again with the appropriate
>> >> locale) on the wchar_t in the wstring.
>>
>> >> --
>> >> James Kanze
>>
>> > Ok, well, suppose I want to use UTF-8 encoding, how do I specify it
>>
>> With UTF-8 one is using char, not wchar_t. Note that if char is a
>> signed type, then one must take care to cast char to unsigned char in
>> places where a non-negative value is expected.
>>
>> By historic reasons the locale and encoding stuff has been mixed up.
>> Are you more interested in locales or in encodings? Locales affect
>> such stuff
>  
>> as the character of representing the decimal point in numbers, look
>> of the dates and whether V and W are sorted together or separately,
>> and whether cyrillic characters are considered alphabetic characters
>> or not. Encoding is a fully different business, specifying for
>> example how those cyrillic characters are encoded in the binary data,
>> if at all.
>>
>> If you just want to translate different encodings, then you do not
>> need any locale stuff at all. When a web page comes in, you do not
>> know if the decimal point used in numbers therein is a dot or a
>> comma, for example, so strictly speaking you cannot set the correct
>> locale for processing the page. What you can do is to look at BOM
>> markers and charset encoding, and to translate the file from its
>> charset to the encoding you are using internally, for example. For
>> that, again no locales are needed, but instead one needs some kind os
>> system-sepcific code or other library like iconv.
>>
>> > using locale? And where can I find a list of the possible locale
>> > encoding configuration (e.g. if I wanted to correctly decode a web
>> > page just parsing the fist bytes looking for 'charset')?
>>
>> http://www.iana.org/assignments/character-sets
>>
>> But you don't want to deal with this by yourself. Use a library like
>> iconv.
>>
>> hth
>> Paavo
>
> Ok, so suppose I want to split a russian text into words and the base
> method look at every character in order to decide if a space is found,
> what do you suggest?

If you mean space as ASCII character 32, then I would use the text
encoded in UTF-8 and compare each byte with ' '.

However, if you mean any whitespace, then I would start by finding out at
unicode.org site if there are any non-ASCII whitespace characters defined
in the standard Russian locale. If there are, and wchar_t on the given
platform is wide enough to represent all of them in a single wchar_t,
then I could encode the text as UTF-16 or UTF-32 as appropriate for
wchar_t on the given platform and use std::isspace<wchar_t>() with the
Russian locale.

Or I could keep the text in UTF-8 and use my own custom function for
checking for the whitespace, checking directly for all Unicode whitespace
characters as listed in http://en.wikipedia.org/wiki/Whitespace_%
28computer_science%29
, this seems to me much less error-prone than
worrying if Russian locale and std::isspace are working correctly on all
platforms.

hth
Paavo

==============================================================================
TOPIC: system("ls")
http://groups.google.com/group/comp.lang.c++/t/ea8887c99b1a8b02?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 11:35 am
From: Juha Nieminen


Matko wrote:
> I am pleased with your responds. Nevertheless, i have used system("ls >
> file.txt") which was sufficient for my case.

What happens if there was a file.txt already in the directory where
you are running the program from (possibly a file you don't want to
destroy)?

What happens if you run the program in a directory where you don't
have write permissions to?

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

==============================================================================
TOPIC: advice on try - throw - catch
http://groups.google.com/group/comp.lang.c++/t/24c6f05e5ff8da82?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 11:45 am
From: "John H."


On Jan 29, 10:46 am, Gus Gassmann <horand.gassm...@googlemail.com>
wrote:
> if (m_sInstanceName.length() <= 0) {

From an efficiency perspective, m_sInstanceName.empty() is preferable
to m_sInstanceName.length()<=0.

> m_sInstanceName = instanceHeader->Name;
> }
> return m_sInstance.Name;

At one point you mention a m_sInstanceName and at another point you
mention m_sInstance.Name. I can't tell from code not included, but
this may or may not be a typo.

> what happens after the method does catch the error and throws it
> upstairs? Do I have to have another try-catch in the calling routine?
> What if I don't?

Throwing comes from the code that detected the problem. try/catching
is for the code that wants to know about (or deal with) the problem.

> if (instanceHeader == NULL)
> throw ErrorClass("instanceHeader object does not
> exist");
> m_sInstanceName = instanceHeader->Name;
> }
> return m_sInstance.Name;
> }
> catch(const ErrorClass& eclass) {

Here you throw and then catch right away. This isn't necessary,
because any code you execute when you caught could just be done
instead of throwing it to begin with.

> catch(const ErrorClass& eclass) {
> throw (ErrorClass eclass.errormsg);
> }

When you caught the exception, you immediately threw it again without
taking any other action. This doesn't serve any purpose because the
behavior would have been the same if you hadn't caught it at all.

> what happens after the method does catch the error and throws it
> upstairs? Do I have to have another try-catch in the calling routine?
> What if I don't?

Throwing an exception is a way to indicate to a function further up
the call stack ("upstairs") that a problem happened. When an
exception is thrown, it will work its way up the call stack until it
is caught. If works all the way up and exits main in this way, then
(depending on the compiler/OS), some message of varying detail may be
given to the user.
So if you want to handle the exception in some specific manner (which
is often the case), then yes, you will want a try/catch in the calling
routine (or the routine that called that routine, etc.)

> Would your approach be different in open source and
> closed source code?

No.

I will make up a little example that shows how exception might be used
in this scenario:

string OSInstance::getInstanceName() {
if (m_sInstanceName.length() <= 0) {
if (instanceHeader == NULL)
throw ErrorClass("instanceHeader object does not exist");
m_sInstanceName = instanceHeader->Name;
}
return m_sInstanceName;
}

void printName(OSInstance & os)
{
try
{
std::cout << os.getInstanceName();
}
catch(const ErrorClass& eclass)
{
std::cout << "Unable to print name (" << eclass.errormsg <<
")" << endl;
}
std::cout << "Have a nice day." << endl;
}

int main()
{
OSInstance os;
printName(os);
return 0;
}

Notice in this example, the function that throws the exception didn't
try to catch it. It was some upstream function that catches it. In
this case, it was printName. printName prints some error message and
then continues to run as normal (in this case,print have a nice day
and then return).

An alternative could have been:
void printName(OSInstance & os)
{
std::cout << os.getInstanceName();
std::cout << "Have a nice day." std::endl;
}

int main()
{
OSInstance os;
try
{
printName(os);
}
catch(const ErrorClass& eclass)
{
std::cout << "os failed to print name (" << eclass.errormsg <<
")" << endl;
}
return 0;
}

Here notice that if printName() runs and getInstanceName throw the
exception, the exception will go to printName, who doesn't catch it,
so the excpetion continues to main(). printName's "Have a nice day
message" will not get printed.

Yet another example:

void printName(OSInstance & os)
{
try
{
std::cout << os.getInstanceName();
}
catch(const ErrorClass& eclass)
{
std::cout << "Unable to print name (" << eclass.errormsg <<
")" << endl;
throw ErrorClass(string("Unable to print because ") +
eclass.errmsg);
}
std::cout << "Have a nice day." << endl;
}

int main()
{
OSInstance os;
try
{
printName(os);
}
catch(const ErrorClass& eclass)
{
std::cout << eclass.errormsg << endl;
os.instanceHeader = new InstanceHeader;
printName(os);
}
return 0;
}

Here printName catchs the exception, does some action, and then
rethrows the exception. main then catches it, and can do some more
actions.

A final example would be if neither main nor printName has a try/
catch. Then you would see some default platform specific behavior I
mentioned previously.

The examples are just for illustration, not saying they are reasonable
or correct.

==============================================================================
TOPIC: typedefs and namespaces
http://groups.google.com/group/comp.lang.c++/t/14757947dce647b0?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 1:32 pm
From: alariq


On Jan 29, 6:45 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
>
> Use the function to do *what*?

Blind I am! Thank you Viktor. I guess, it just was not my hard day
today...

==============================================================================
TOPIC: change function
http://groups.google.com/group/comp.lang.c++/t/98d241e38cad9662?hl=en
==============================================================================

== 1 of 4 ==
Date: Fri, Jan 29 2010 2:14 pm
From: "Larry"


Hi,

I would like to turn this function:

std::string Socket::ReceiveBytes() {
std::string ret;
char buf[1024];

while (1) {
u_long arg = 0;
if (ioctlsocket(s_, FIONREAD, &arg) != 0)
break;

if (arg == 0)
break;

if (arg > 1024) arg = 1024;

int rv = recv (s_, buf, arg, 0);
if (rv <= 0) break;

std::string t;

t.assign (buf, rv);
ret += t;
}

return ret;
}

into something like:

bool Socket::ReceiveBytes(char * buffer, const int buffersize);

how should I change it internally?

thanks


== 2 of 4 ==
Date: Fri, Jan 29 2010 3:58 pm
From: "Larry"


"Larry" <dontmewithme@got.it> ha scritto nel messaggio
news:4b635ddc$0$1137$4fafbaef@reader1.news.tin.it...

> into something like:

this is what I have figure out so far: (untested)


#include <algorithm>

int Socket::ReceiveBytes(char * buffer, int buffersize)
{
if(buffersize > 32768)
buffersize = 32768;

char temp[32768];
int byrv = 0;

while (1)
{
u_long arg = 0;

if (ioctlsocket(s_, FIONREAD, &arg) != 0)
return -1;

if (arg == 0)
return byrv;

if (arg > buffersize)
arg = buffersize;

int rv = recv (s_, temp, arg, 0);

if (rv <= 0)
return -1;

std::copy(temp, temp + rv, buffer);
byrv += rv;
}
}

== 3 of 4 ==
Date: Fri, Jan 29 2010 5:22 pm
From: "Larry"


"Larry" <dontmewithme@got.it> ha scritto nel messaggio
news:4b637617$0$820$4fafbaef@reader5.news.tin.it...

> this is what I have figure out so far: (untested)

#include <algorithm>

int Socket::ReceiveBytes(char * buffer, int buffersize)
{
if(buffersize > 32768)
buffersize = 32768;

char temp[32768];

u_long arg = 0;

if (ioctlsocket(s_, FIONREAD, &arg) != 0)
return -1;

if (arg == 0)
return 0;

if (arg > buffersize)
arg = buffersize;

int rv = recv (s_, temp, arg, 0);

if (rv <= 0)
return -1;

if (rv == 0)
return 0;

if (rv > 0)
std::copy(temp, temp + rv, buffer);

}

where FIONREAD:

Determine the amount of data which can be read atomically from socket s.
argp points to an unsigned long in which ioctlsocket stores the result. If s
is stream oriented (for example, type SOCK_STREAM), FIONREAD returns an
amount of data which can be read in a single recv; this may or may not be
the same as the total amount of data queued on the socket. If s is message
oriented (for example, type SOCK_DGRAM), FIONREAD returns the size of the
first datagram (message) queued on the socket.

So I basically I will recv according to ioctlsocket. if the latter is > then
buffersize I will read buffersize (arg = buffersize) if it's
less...well...be just happy with that...if it's 0 or less don't even bother
copying the buffer and return accordingly.

that's all

what about my idea?

thanks

== 4 of 4 ==
Date: Fri, Jan 29 2010 5:21 pm
From: "Larry"


"Larry" <dontmewithme@got.it> ha scritto nel messaggio
news:4b637617$0$820$4fafbaef@reader5.news.tin.it...

> this is what I have figure out so far: (untested)

#include <algorithm>

int Socket::ReceiveBytes(char * buffer, int buffersize)
{
if(buffersize > 32768)
buffersize = 32768;

char temp[32768];

u_long arg = 0;

if (ioctlsocket(s_, FIONREAD, &arg) != 0)
return -1;

if (arg == 0)
return 0;

if (arg > buffersize)
arg = buffersize;

int rv = recv (s_, temp, arg, 0);

if (rv <= 0)
return -1;

if (rv == 0)
return 0;

if (rv > 0)
std::copy(temp, temp + rv, buffer);

}

where FIONREAD:

Determine the amount of data which can be read atomically from socket s.
argp points to an unsigned long in which ioctlsocket stores the result. If s
is stream oriented (for example, type SOCK_STREAM), FIONREAD returns an
amount of data which can be read in a single recv; this may or may not be
the same as the total amount of data queued on the socket. If s is message
oriented (for example, type SOCK_DGRAM), FIONREAD returns the size of the
first datagram (message) queued on the socket.

So I basically I will recv according to ioctlsocket. if the latter is > then
buffersize I will read buffersize (arg = buffersize) if it's
less...well...be just happy with that...if it's 0 or less don't even bother
copying the buffer and return accordingly.

that's all

what about my idea?

thanks


==============================================================================
TOPIC: Another strange linux kernel change
http://groups.google.com/group/comp.lang.c++/t/e05a4158a9750a03?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 2:23 pm
From: ram@zedat.fu-berlin.de (Stefan Ram)


Vladimir Jovic <vladaspams@gmail.com> writes:
>>>> i++ --> ++i, on a separate line! Does it matter?
>>>No.
>>Are you saying that
>>j = i++;
>>and
>>j = ++i;
>>have the same effect?
>Yes, that's what I said (shame on me). Fortunately I do not have to
>debug offset by 1 in the j ;)

The OP said »on a separate line«, so that should be:
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
j =
i++
;

versus

j =
++i
;

(Of course, this is irrelevant, but the question was put in
this way.)


==============================================================================
TOPIC: Help: Want to setup the IPP environment inside of my program
http://groups.google.com/group/comp.lang.c++/t/7a5ab98ed0dde279?hl=en
==============================================================================

== 1 of 3 ==
Date: Fri, Jan 29 2010 2:57 pm
From: Johnson


Thank you for your time in reading my post.

I am developing a C++ program with Visual Studio 2008 at Windows Vista
platform. I would like to set a few OpenMP environment variables inside
of my program. For example, I would like to set "KMP_AFFINITY=compact".
Could anybody show me how to do it? I think setenv only works for UNIX
and LINUX, right?

I also would like to know how to set the OpenMP environment variables
manually or in the script. Is there any script/configuration file for
the IPP? Can I set the OpenMP environment variables the same way as
other windows system variables? I mean, buy opening "My Computer",
select "Environment Variables", and create a variable for the
environment variable then set its value?

Thank you!

Johnson

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---


== 2 of 3 ==
Date: Fri, Jan 29 2010 3:21 pm
From: Johnson


I tried _putenv to assign the environment variables. However, I was not
sure if it is the right way to assign to set the OpenMP environment
variables. Please let me know if it is right.

_putenv( "KMP_AFFINITY=compact" );


Johnson wrote:
> Thank you for your time in reading my post.
>
> I am developing a C++ program with Visual Studio 2008 at Windows Vista
> platform. I would like to set a few OpenMP environment variables inside
> of my program. For example, I would like to set "KMP_AFFINITY=compact".
> Could anybody show me how to do it? I think setenv only works for UNIX
> and LINUX, right?
>
> I also would like to know how to set the OpenMP environment variables
> manually or in the script. Is there any script/configuration file for
> the IPP? Can I set the OpenMP environment variables the same way as
> other windows system variables? I mean, buy opening "My Computer",
> select "Environment Variables", and create a variable for the
> environment variable then set its value?
>
> Thank you!
>
> Johnson
>
> --- news://freenews.netfront.net/ - complaints: news@netfront.net ---

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---


== 3 of 3 ==
Date: Fri, Jan 29 2010 3:43 pm
From: Kaz Kylheku


On 2010-01-29, Johnson <gpsabove@yahoo.com> wrote:
> I tried _putenv to assign the environment variables. However, I was not
> sure if it is the right way to assign to set the OpenMP environment
> variables. Please let me know if it is right.
>
> _putenv( "KMP_AFFINITY=compact" );

How do you know that the place where you call this is not too late for OpenMP
to notice? Where is it documented that you can do this from within the program,
when it's already running?

15 seconds of googling confirms the intuition that there is a library API to
obtain the same effect, from within the program, as setting the KMP_AFFINITY
variable before running the program.

The documentation even provides a code sample for how to mimic the
behavior of KMP_AFFINITY=compact. Quote:

``Therefore, by creating a parallel region at the start of the program whose
sole purpose is to set the affinity mask for each thread, the user can
mimic the behavior of the KMP_AFFINITY environment variable with low-level
affinity API calls, if program execution obeys the three aforementioned
rules from the OpenMP specification. Consider again the example presented
in the previous figure. To mimic KMP_AFFINITY=compact, in each OpenMP
thread with global thread ID n, we need to create an affinity mask
containing OS proc IDs n modulo c, n modulo c + c, and so on, where c is
the number of cores. This can be accomplished by inserting the following C
code fragment into the application that gets executed at program startup
time: ...''

RTFM for the code.

==============================================================================
TOPIC: Looking for C++ IDE,...
http://groups.google.com/group/comp.lang.c++/t/e8a1db0949215858?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Jan 29 2010 3:23 pm
From: jamm


Kerem Gümrükcü wrote:

> Hi,
>
> i am looking fo a (free, non-microsoft!) C++ IDE for windows, that
> can do most of the MSVC++ stuff (resources, projects, etc.) but most
> important is the abillity to easily switch between processor targets
> for the compiler/linker e.g. it should have a 32 and 64 bit compiler
> included in the environment and 64 bit code can be compiled on
> a 32 bit system. I want to target Windows only (windows api is the
> foundation or will be), so there is no need to use a mixed environment.
>
> What can you recommend,...?
>
>
> Thanks in advance,...
>
> Regards
>
> Kerem
>

CodeBlocks is nice. Not sure if it supports 64bit cross compiling though.

--
*From the 1966 TV series:*
Robin: You can't get away from Batman that easy!
Batman: Easily.
Robin: Easily.
Batman: Good grammer is essential, Robin.


== 2 of 2 ==
Date: Fri, Jan 29 2010 4:10 pm
From: Wing


On 1/29/2010 7:27 AM, Kerem Gümrükcü wrote:
> Hi,
>
> i am looking fo a (free, non-microsoft!) C++ IDE for windows, that
> can do most of the MSVC++ stuff (resources, projects, etc.) but most
> important is the abillity to easily switch between processor targets
> for the compiler/linker e.g. it should have a 32 and 64 bit compiler
> included in the environment and 64 bit code can be compiled on
> a 32 bit system. I want to target Windows only (windows api is the
> foundation or will be), so there is no need to use a mixed environment.
>
> What can you recommend,...?
>
>
> Thanks in advance,...
>
> Regards
>
> Kerem
>
This link might help
http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B

--
Wing

==============================================================================
TOPIC: Help: libiomp5md.dll takes 46.22% individual work reported by Visual
Studio Profiler
http://groups.google.com/group/comp.lang.c++/t/08adc6ce31d50518?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Jan 29 2010 3:48 pm
From: red floyd


On Jan 29, 9:30 am, Johnson <gpsab...@yahoo.com> wrote:
[redacted]

May I suggest you check with either your library vendor,
or on an MS forum? There was no C++ language question.

Plus, we're not psychic. We have absolutely no idea what
this lib is supposed to be doing, or how it's coded.


== 2 of 2 ==
Date: Fri, Jan 29 2010 6:12 pm
From: "Eric Pruneau"

"Johnson" <gpsabove@yahoo.com> a �crit dans le message de news:
hjv5vc$qra$1@adenine.netfront.net...
>I am developing a C++ algorithm with Visual Studio 2008 team right now. The
>algorithm requires FFT/IFFT operation and is originally implemented at
>MATLAB, now I have load the IPP library to Visual Studio to do the FFT
>work.
>
> The C++ algorithm program is written following the STL standard. It works
> but I feel it runs very slow, even slower than the MATLAB program. So I
> use the Visual Studio Team Profiling Tools to check the CPU time used by
> each module and function and locate the bottleneck. To my surprise, I find
> libiomp5md.dll itself takes 46.22% individual work (please see attachment
> for summary report of the profiler), so it is very CPU time consuming. I
> don't know if libiomp5md.dll is related to Visual Studio Team Profiling
> Tools, and why it is so time-consuming. Could anybody please help me?

It seems to be an IPP dll.Probably related to Intel's OpenMP, which is not
related to IPP or FFT stuff but to multi threading and compiler stuff.


> BTW, is it a wise choice to use STD C++ instead of ANSI C to implement the
> algorithm in terms of the speed? It is my first time to write an algorithm
> in STD. The main reason behind is to avoid pointers, which are too
> powerful and may cause troubles.

I'm pretty sure you won't notice any differences in speed since your
bottleneck is probably the fft stuff which is handled by IPP. By the way I
can assure you that IPP implementation of the FFT is really fast.


Never forget this:
Premature optimization is the root of all evil (Donald Knuth)

It look like you are trying to use IPP, OpenMp and the Intel compiler in
your quest of performance...
Start with IPP, make thing works (cause IPP itself is not that easy to use),
then move on with the compiler, check out all the optimization options it
has to offer and finally try OpenMP.


Eric Pruneau

==============================================================================
TOPIC: Advice on using templates and vector to improve exception handling
http://groups.google.com/group/comp.lang.c++/t/36f052e700775e41?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Jan 29 2010 4:06 pm
From: jdm


Hi,

I've been trying to improve on my program's exception handling, due to
the amount of code duplication resulting from the following (not to
mention the need to recode when the relevant data required five
variables):

struct three_long_int_misc_exception
{
std::string ident_string;
long int err_number1, err_number2, err_number3;
three_long_int_misc_exception(std::string i="Unknown exception
(three_long_int_misc_exception).", long int x=0, long int y=0, long
int z=0)
{
ident_string = i;
err_number1 = x;
err_number2 = y;
err_number3 = z;
}
};

struct three_unsigned_long_int_misc_exception
{
std::string ident_string;
unsigned long int err_number1, err_number2, err_number3;
three_unsigned_long_int_misc_exception(std::string i="Unknown
exception (three_unsigned_long_int_misc_exception).", unsigned long
int x=0, unsigned long int y=0, unsigned long int z=0)
{
ident_string = i;
err_number1 = x;
err_number2 = y;
err_number3 = z;
}
};

struct four_long_int_misc_exception
{
std::string ident_string;
long int err_number1, err_number2, err_number3, err_number4;
four_long_int_misc_exception(std::string i="Unknown exception
(four_long_int_misc_exception).", long int w=0, long int x=0, long int
y=0, long int z=0)
{
ident_string = i;
err_number1 = w;
err_number2 = x;
err_number3 = y;
err_number4 = z;
}
};

(There were also structs for when the exception data consisted only of
one or two ints.)

Although the following was a bit more complicated to throw, it seemed
a better idea:

template <typename T> struct multiple_integer_misc_exception
{
std::string ident_string;
std::vector<T> error_numbers;

multiple_integer_misc_exception()
{
ident_string = "";
error_numbers = std::vector<T>(1);
error_numbers[0] = 0;
}

multiple_integer_misc_exception(std::vector<T>& v, std::string
s="Unknown exception (multiple_integer_misc_exception).")
{
ident_string = s;
error_numbers = std::vector<T>(v.size());
for (int i=0; i < v.size(); i++)
{
error_numbers[i] = v[i];
}
}
};

However, this doesn't seem to eliminate much of the code duplication
involved in catching the exceptions, as the main() function now needs
to include:

catch (multiple_integer_misc_exception<long int> lmime) //Is there a
better way than these two almost identical catches?
{
std::cout<<'\n'<<lmime.ident_string<<'\t';
for (int i=0; i<lmime.error_numbers.size(); i++)
{
std::cout<<lmime.error_numbers[i]<<' ';
}
std::cout<<std::endl;
return 1;
}
catch (multiple_integer_misc_exception<unsigned long int> ulmime)
{
std::cout<<'\n'<<ulmime.ident_string<<'\t';
for (int i=0; i<ulmime.error_numbers.size(); i++)
{
std::cout<<ulmime.error_numbers[i]<<' ';
}
std::cout<<std::endl;
return 1;
}

Can anyone suggest a better way to do this?

Thanks,

James McLaughlin.


== 2 of 2 ==
Date: Fri, Jan 29 2010 8:20 pm
From: "**Group User**"


On Jan 30, 7:06 am, jdm <james.d.mclaugh...@googlemail.com> wrote:
> Hi,
>
> I've been trying to improve on my program's exception handling, due to
> the amount of code duplication resulting from the following (not to
> mention the need to recode when the relevant data required five
> variables):
>
> struct three_long_int_misc_exception
> {
>         std::string ident_string;
>         long int err_number1, err_number2, err_number3;
>         three_long_int_misc_exception(std::string i="Unknown exception
> (three_long_int_misc_exception).", long int x=0, long int y=0, long
> int z=0)
>         {
>                 ident_string = i;
>                 err_number1 = x;
>                 err_number2 = y;
>                 err_number3 = z;
>         }
>
> };
>
> struct three_unsigned_long_int_misc_exception
> {
>         std::string ident_string;
>         unsigned long int err_number1, err_number2, err_number3;
>         three_unsigned_long_int_misc_exception(std::string i="Unknown
> exception (three_unsigned_long_int_misc_exception).", unsigned long
> int x=0, unsigned long int y=0, unsigned long int z=0)
>         {
>                 ident_string = i;
>                 err_number1 = x;
>                 err_number2 = y;
>                 err_number3 = z;
>         }
>
> };
>
> struct four_long_int_misc_exception
> {
>         std::string ident_string;
>         long int err_number1, err_number2, err_number3, err_number4;
>         four_long_int_misc_exception(std::string i="Unknown exception
> (four_long_int_misc_exception).", long int w=0, long int x=0, long int
> y=0, long int z=0)
>         {
>                 ident_string = i;
>                 err_number1 = w;
>                 err_number2 = x;
>                 err_number3 = y;
>                 err_number4 = z;
>         }
>
> };
>
> (There were also structs for when the exception data consisted only of
> one or two ints.)
>
> Although the following was a bit more complicated to throw, it seemed
> a better idea:
>
> template <typename T> struct multiple_integer_misc_exception
> {
>         std::string ident_string;
>         std::vector<T> error_numbers;
>
>         multiple_integer_misc_exception()
>         {
>                 ident_string = "";
>                 error_numbers = std::vector<T>(1);
>                 error_numbers[0] = 0;
>         }
>
>         multiple_integer_misc_exception(std::vector<T>& v, std::string
> s="Unknown exception (multiple_integer_misc_exception).")
>         {
>                 ident_string = s;
>                 error_numbers = std::vector<T>(v.size());
>                 for (int i=0; i < v.size(); i++)
>                 {
>                         error_numbers[i] = v[i];
>                 }
>         }
>
> };
>
> However, this doesn't seem to eliminate much of the code duplication
> involved in catching the exceptions, as the main() function now needs
> to include:
>
>         catch (multiple_integer_misc_exception<long int> lmime)   //Is there a
> better way than these two almost identical catches?
>         {
>                 std::cout<<'\n'<<lmime.ident_string<<'\t';
>                 for (int i=0; i<lmime.error_numbers.size(); i++)
>                 {
>                         std::cout<<lmime.error_numbers[i]<<' ';
>                 }
>                 std::cout<<std::endl;
>                 return 1;
>         }
>         catch (multiple_integer_misc_exception<unsigned long int> ulmime)
>         {
>                 std::cout<<'\n'<<ulmime.ident_string<<'\t';
>                 for (int i=0; i<ulmime.error_numbers.size(); i++)
>                 {
>                         std::cout<<ulmime.error_numbers[i]<<' ';
>                 }
>                 std::cout<<std::endl;
>                 return 1;
>         }
>
> Can anyone suggest a better way to do this?
>
> Thanks,
>
> James McLaughlin.

Dear Sir, this googlegroups is hosted by Google's Finance Manager
DavidC - a known colored gay male living at present in Vietnam Sir
HIs Vietnamese name mmm if I am wrong is Trung Kien, if you are
accessing from a Vietnamese forums board definitely you will see suc
username, it's the 'man'

==============================================================================
TOPIC: web designer , netobjectsfusion 11 , fusion9 , kaufen artikel , nof
vista , website design services , web page designing , nof europe , webseiten
designer software , pc spiele bestellen ,
http://groups.google.com/group/comp.lang.c++/t/e7156786f895b1f4?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 4:23 pm
From: annelise heinze


web designer , netobjectsfusion 11 , fusion9 , kaufen artikel , nof
vista , website design services , web page designing , nof europe ,
webseiten designer software , pc spiele bestellen ,

WEBSITE DESIGN SOFTWARE +++ WEBSEITEN DESIGN SOFTWARE +++ WEBSEITEN
ERSTELLEN
+
+
+
+
+
http://WWW.NETOBJECTSFUSION.NL/
http://WWW.NETOBJECTSFUSION.NL/
http://WWW.NETOBJECTSFUSION.NL/
http://WWW.NETOBJECTSFUSION.NL/
http://WWW.NETOBJECTSFUSION.NL/
http://WWW.NETOBJECTSFUSION.NL/
+
+
+
+
+

webseite netobjectsfusion 10
flash website design webseiten kostenlos
webseiten versand bestellen
netobjectsfusion 11 webseite erstellen
nof 8.0 german nof
pc spiele bestellen simple website design software
netobjects fusion kaufen homepage erstellung
nof update nof 3
netobjects fusion download ecommerce website design software
software for website design netobjectsfusion 8
nof 3 best nof
website design services netobjectsfusion 8
website designs software simple website design software
website design software for linux nof homepage
website design templates web page designers

==============================================================================
TOPIC: DavidC - Trung Kien - Brian
http://groups.google.com/group/comp.lang.c++/t/248b5df63ba9c39f?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, Jan 29 2010 8:29 pm
From: "**Group User**"


What is the diference among them ? I need clearification over who is
the Gay male operating/hosting physicsforums.com

Thank you Sir very much :-D


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

No comments: