由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Any possibility to make this expression faster?
相关主题
新手请教:C++ decrement loopa C++ question
why vb code faster than csharp???Really Stupid Question: How to run VC++ 2008 Express (转载)
狠偷懒狠偷懒的一个测试which Regular Expression lib in C++ do you prefer?
how to calculate the result of an expression given by a string?问个c++的弱问题
[合集] C++ programming--break 2-loops outside[合集] 统计,Regular Expression
用C++的说说, 工作中用C++面向对象的部分多少C++ question
有没有大牛说说C里边for循环的坏处auto 很爽
问个C++算法《新C++标准:C++0x 概述》英文文字版[PDF]
相关话题的讨论汇总
话题: any话题: faster话题: extract话题: expression
进入Programming版参与讨论
1 (共1页)
w****i
发帖数: 964
1
My program need to exec the following code many many times
D = A&B[C]^C;
where A, B, C, D are unsigned int, (pre-calculated table is too big to fit
in memory)
is it possible to find a faster way to calculate D?
Any comment is appreciated.
h*******e
发帖数: 225
2
pls post the real code snippet esp the loops.

【在 w****i 的大作中提到】
: My program need to exec the following code many many times
: D = A&B[C]^C;
: where A, B, C, D are unsigned int, (pre-calculated table is too big to fit
: in memory)
: is it possible to find a faster way to calculate D?
: Any comment is appreciated.

w****i
发帖数: 964
3
here is a simplified version. (real code is too long and messy)
like this:
for (A=0; A<0x10000; A++)
for (C=0; C<0x10000; C++)
D = A&B[C]^C;
B is a random array.
thanks
r*******y
发帖数: 290
4
at least you can optimize B[C]^C
switch the two for loops

【在 w****i 的大作中提到】
: here is a simplified version. (real code is too long and messy)
: like this:
: for (A=0; A<0x10000; A++)
: for (C=0; C<0x10000; C++)
: D = A&B[C]^C;
: B is a random array.
: thanks

w****i
发帖数: 964
5
but (A&B[C])^C != A&(B[C]^C), you can't extract B[C]^C
l***8
发帖数: 149
6
what exactly is each D used for? do you need to calculate every D?
and, does the order matter?
I hope you don't need to dump every one of the total 4 billion numbers...
d****d
发帖数: 699
7
Not much space for improvement. You can take a look at the assembly
generated by the compiler, also watch out cache locality, the major overhead
of your code is probably memory read.
f*****e
发帖数: 57
8
You can still switch the loop, and pre-calculate B[C], and you don't need to
derefernce the B array every time.
l*****c
发帖数: 1153
9
Yeah. How do you use D? And what is the actual optimization target?

【在 l***8 的大作中提到】
: what exactly is each D used for? do you need to calculate every D?
: and, does the order matter?
: I hope you don't need to dump every one of the total 4 billion numbers...

b***i
发帖数: 3043
10
do you perform this calcualtion multiple times?

【在 w****i 的大作中提到】
: here is a simplified version. (real code is too long and messy)
: like this:
: for (A=0; A<0x10000; A++)
: for (C=0; C<0x10000; C++)
: D = A&B[C]^C;
: B is a random array.
: thanks

1 (共1页)
进入Programming版参与讨论
相关主题
《新C++标准:C++0x 概述》英文文字版[PDF][合集] C++ programming--break 2-loops outside
Microsoft Visual C++ 2010 Express用C++的说说, 工作中用C++面向对象的部分多少
开始学python,要被它打败了有没有大牛说说C里边for循环的坏处
感觉JVM上的FP语言都有个大问题问个C++算法
新手请教:C++ decrement loopa C++ question
why vb code faster than csharp???Really Stupid Question: How to run VC++ 2008 Express (转载)
狠偷懒狠偷懒的一个测试which Regular Expression lib in C++ do you prefer?
how to calculate the result of an expression given by a string?问个c++的弱问题
相关话题的讨论汇总
话题: any话题: faster话题: extract话题: expression