|
Hi Sauro,
the i7 the original poster is using can run 8 threads simultaneously. There are 4 cores and each core is hyperthreaded.
Cheers,
Ash
|
|
|
|
|
Ops...
|
|
|
|
|
The HyperThreading performance is not actually double the normal performance though, many parts of the CPU are shared competitively between the two threads running on a single core.
|
|
|
|
|
Yep, and that's why I said that each extra core for hyperthreading is worth somewhere between 0.2 and 0.5 a processor for the style of coding he's doing.
Cheers,
Ash
|
|
|
|
|
Yep, and that's why I said that each extra core for hyperthreading is worth somewhere between 0.2 and 0.5 a processor for the style of coding he's doing.
Cheers,
Ash
PS: No I didn't, should have done! Thanks for pointing that out.
|
|
|
|
|
I wouldn't expect a linear scaling of performance with number of threads but I'd expect a bit better performance than that. When manually scheduling my own threads I can get about 4 times the performance on an i7 with 8 hardware execution units for the same sort of problem.
How does OpenMP interleave the memory accesses? There might be a lot of cache contention going on that's causing the slowdown. With my manually scheduled version it's running out of cache that slows mine down.
Looking at it N is fairly small. What happens when you use 10,000,000?
Cheers,
Ash
PS: Another reason you might not be getting as much speed up when you're running more cores is that the i5 and i7 throttle down when running more threads to keep the thing cool. Or as the advertising goes it overclocks up when running fewer threads and is able to keep its' temperature down. My results were with turbo boost (as the marketroids call it) disabled so that might be why my processor's response was a bit more linear.
|
|
|
|
|
It is N*N loop aready with N=10000 it is 10,000*10,000 = 100,000,000 operations.
That already takes 170 ms to process.
I need to optimize code that performs even less operations.
Чесноков
|
|
|
|
|
Missed that. I need glasses
Ash
|
|
|
|
|
I used RegisterHotKey API to provide hot keys for certain events.
If i dont close my application and if i run another then CTRL + C is not working cause i am using it in my application. What shall i do?
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
I think you are confusing between hotkeys and accelerators: the first one are system-wide key escapes, the second one are limited to the application.
|
|
|
|
|
Oh, so what do we do if we want the key using registerhotkey to be local to the application and not all other applications... or how do we use accelerators like hotkeys... i have not yet experimented accelerators. can you give me an online reference so that i can go through that and use it. thank you.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
Accelerators are quite easy to use; the steps required are the following:
- create a new resource of type accelerator table inside your .rc file, then add the entries that you want to that table using the resource editor
- load the accelerator table using the
LoadAccelerators function - inside the message loop of the window that you want to process the accelerators, use the
TranslateAccelerator function to dispatch them
You can read the documentation about accelerator here[^] on the MSDN.
Note: if you are using MFC and your application is based on the document/view architecture, then the project wizard alerady creates an accelerator table for you, and that table is already loaded and used by your frame window (see Managing Menus, Control Bars, and Accelerators (MFC)[^] on the MSDN). If your application is an MFC dialog based one, you should manually add the code to load the accelerator table (you can call LoadAccelerators in the constructor of your CDialog derived class) and to dispatch the accelerators, by overriding the PreTranslateMessage virtual method and calling TranslateAccelerator .
|
|
|
|
|
Wow, thats a nice explanation.
Thank you.
Let me play with those functions and let me try to accomplish my task.
http://vikku.info/
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
How to get the Selected Item from CListControl
when scrolling through key board arrow keys.
I want to know the selected item no when scrolling through keyboard.
Using mouse click I can able to get the selected item no.
|
|
|
|
|
CListCtrl::GetSelectionMark[^] doesn't work for you?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I know its not correct.
-> But can a pointer, to a class which contains only member functions and absolutely no data members, be used to invoke its member functions?
int func_2(int i, float j)
{
cout << i << j << endl;
return i;
}
class ABC
{
public:
int func_1(int i, float j)
{
return func_2(i, j);
}
};
[1] ABC *pObj;
[2] int i = 10;
[3] float f = 20.50f;
[4] int r = pObj->func_1(i, f);
When the above code is executed using VC++2003(version 7.1) following error occurs at line[4]:
Run-Time Check Failure #3 - The variable 'pObj' is being used without being defined.
but even if the error is ignored\ continued then also every thing work properly.
Please suggest :
->Whether this method of using uninitialized pointer is acceptable in any condition?
->Will this work on different platforms?(could not try this, since I do not have accesses to other platform)
->Any pitfalls?
->Your Valuable suggestions.
Thanks in advance.
|
|
|
|
|
Technically it can be used this way.
But if such a situation arises, you should make the function a static function and call it using the class scope operator.
The error is issued because these things usually tend to become bugs.
|
|
|
|
|
I thought there must be an instance of an object to use a pointer to one. Even with a static member that is not the best syntax to use though. I hesitate to say correct because I am not a language expert.
To use a static method the usual syntax is ClassName::MethodName(); when no instance is referenced.
|
|
|
|
|
Rick York wrote: I thought there must be an instance of an object to use a pointer to one.
If the function which is called do not access any members of the class, then it is "safe". But of cours it is absolutely bad practice.
Rick York wrote: Even with a static member that is not the best syntax to use though.
This, on the other hand is perfectly acceptable.
I should take a coffee before answering questions on CP . This is not that acceptable, since the static function should accessed this way: ClassName::MethodName()
|
|
|
|
|
Cedric Moonen wrote: This, on the other hand is perfectly acceptable.
However, the wise developer would use the classname::method syntax.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I think I was not awake when I replied, I really thought he was talking about accessing the static function using the classname::method syntax. Pff, ok, I'll fetch a coffee now.
|
|
|
|
|
I can barely reach my workstation, without caffein.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
With the risk of being wordy...
This piece of code should illustrate things.
class Z
{
public:
int g;
void out(){printf("addr %p\n", this);}
void outg(){printf("addr %p g=%d\n", this, g);}
};
Z *pz1, *pz2=0, *pz3=(Z*)0xdeadbabe, *pz4, z;
void main()
{
pz1->out();
pz2->out();
pz3->out();
pz4->out();
z.g=100;
pz1=&z;
pz1->outg();
pz2->outg();
pz3->outg();
pz4->outg();
}
As you can see, pz1 to pz4 are either not initialized or are initialized to "wrong" values. However, lines 1 to 4 execute happily, even though you dereferance using these wrong pointers. Thats because you aren't actually touching the member variable at all.
Now, look at what happens next. At line 6, pz1 is initiated to a valid address and hence outg() doesn't complain. Why should it complain you may ask. I'll tell you.
Open the disassembly window and step into the function call at line 8. There you'll find that the control actually steps into the function, even when derefeneced using a wrong pointer! Thats because one line of C/C++ translates into many many lines of assembler. As you step past each assembler instruction, you'll encounter this instruction
mov ecx, dword ptr [eax]
and that is where you get the tantrum.
In this line, the member variable 'g' is attempted to be accessed. EAX really holds the address of the object but because 'g' is the first member, the address coincide. And the complaint is valid as you cannot CANNOT SHOULD NOT access data from uninitialized memory.
EDIT: I forgot to mention that you have to turn off "incremental linking". It doesn't matter much except that if its on you might get confused and/or distracted by the " @ILT+nnn " that you'll encounter. An oh, its MSVC6.0
...byte till it megahertz...
modified on Thursday, August 5, 2010 3:33 AM
|
|
|
|
|
|
ccpptrain wrote: ->Whether this method of using uninitialized pointer is acceptable in any condition?
It is acceptable as long as you are careful, as you promised absolutely no data members. With this condition, you initialize or don't initialize or simply call using 0 (zero) pointer, it is acceptable.
ccpptrain wrote: ->Will this work on different platforms?
It is same for all platforms.
ccpptrain wrote: ->Any pitfalls?
One more promise: don't delete the pObj.
ccpptrain wrote: ->Your Valuable suggestions.
Don't do like this. You never know when you are going to add member variables and access them.
|
|
|
|