由买买提看人间百态

topics

全部话题 - 话题: reordered
首页 上页 1 2 3 4 5 6 (共6页)
e***a
发帖数: 18
1
来自主题: Programming版 - C++: exception: out-of-order execution?
I understand your statement but I want to get to the bottom of it.
I was asked about this during an interview.
They asked me about why mutex perterson implementation will fail in modern
processor.
(check out http://en.wikipedia.org/wiki/Peterson%27s_algorithm).
"Many modern CPUs reorder instruction execution and memory accesses to
improve execution efficiency. Such processors invariably give some way to
force ordering in a stream of memory accesses, typically through a memory
barrier instruction
p***o
发帖数: 1252
2
来自主题: Programming版 - Help on a multithread question
You need to declare the global boolean to be 'volatile' for this to work
with modern compilers on most modern multicore processors. Roughly speaking,
you need to tell the compiler and the processor NOT to reorder the writes
in the background and the read/write in the main thread. Search for the
keyword 'memory barrier', and that's why it's better for him to learn
from some decent books ...

very
,
,
t****t
发帖数: 6806
3
what xentar said is exactly *why* mutex can keep global variable thread-safe
. usually mutex are implemented with opaque functions which compiler has no
knowledge. potentially, compiler thinks mutex function may actually do any c
hange to global functions, and therefore preventing optimizations from happe
ning, such as reordering accessing, caching, etc.
there might exist situations where global variables are accessed without mut
ex protection, such as lock-free concurrent data structures. in th
c*****t
发帖数: 1879
4
I remember that microbe and I argued this "volatile" keyword a few years
ago.
For compilers, they could easily optimize the calling of known library
functions (such as C library functions). These functions would not modify
global variables unknown to the compiler. Also, extern functions could not
access static variables.
1. In these cases, the access of the variables could easily be reordered
around the function calls.
2. The variable might be cached. For the obvious reason, variables could
b
e****d
发帖数: 895
5
来自主题: Programming版 - HELP:这个死锁是怎么发生的?
CPU & compiler optimization could reorder them, but not in this case though.
d******i
发帖数: 7160
6
just check. u r right.
the MSDN's really confusing about the pop_heap:
"
pop_heap
template
void pop_heap(RanIt first, RanIt last);
template
void pop_heap(RanIt first, RanIt last, Pred pr);
The first template function reorders the sequence designated by iterators in
the range [first, last) to form a new heap, ordered by operator< and
designated by iterators in the range [first, last - 1), leaving the original
element at *first subsequently at *(last -... 阅读全帖
W**********r
发帖数: 61
7
you need reorder the matrix A first to minimize fill-in elements. And
perform symbolical LDU factorization for A. Then you can use Newton-Raphson
algorithm to solve. You can use Matlab, Python, C, whaterever u want.
BTW, remember to use subroutines.
c*******h
发帖数: 1096
8
splu应该是最合适的,因为right-hand side实在太多了
内存是肯定耗的,光把X存下来就要24G
X一般不是稀疏的,除非你的问题结构比较特殊
最好搞个cluster,并行地算
一是对矩阵分解做并行,二是对right-hand side做并行
如果scipy解决不了并行的话可以直接上superlu
还可以试一下对A做reordering
最好还是想清楚,要个24G的X来干嘛
a***n
发帖数: 538
9
来自主题: Programming版 - MongoDB力压Cassandra
http://docs.mongodb.org/manual/core/write-operations/
The db.collection.update() method either updates specific fields in the
existing document or replaces the document. See db.collection.update() for
details.
When performing update operations that increase the document size beyond the
allocated space for that document, the update operation relocates the
document on disk and may reorder the document fields depending on the type
of update.
The db.collection.save() method replaces a document and c... 阅读全帖
k****0
发帖数: 7
10
来自主题: Programming版 - 考考你的能力。
challenge accepted!
python, complexity O(N)
def reorder(input_str):
case_queue = list()
letter_stack = list()
output = list()
for i in input_str:
if i in (" ", "."):
while letter_stack:
case = case_queue.pop(0)
letter = letter_stack.pop()
output.append(letter.upper() if case else letter.lower())
output.append(i)
else:
case_queue.append(1 if i.isupper() else 0)
letter_st... 阅读全帖
M**********n
发帖数: 432
11
来自主题: Programming版 - Concurrency of assignment statement in C
Thanks. I am not familiar with memory barrier. Just took a quick look at the
wiki page.
We don't care how compiler or CPU reordering the instructions.
All we care is that when that assignment is executed, the value assigned to
a is the value retrieved from b's actual memory address instead of some temp
register. Can this be guaranteed?
p***o
发帖数: 1252
12
来自主题: Programming版 - Concurrency of assignment statement in C
Sure, why not ...
1 For Thread 2, a=b can be compiled into two instructions.
2 Even if you can make a=b a single instruction, compiler/processor
can reorder the writes to b and reads from a in Thread 1.
Here is the book if you have time to read:
Is Parallel Programming Hard, And, If So, What Can You Do About It?
Otherwise try to find a library instead of writing your own code.
M**********n
发帖数: 432
13
来自主题: Programming版 - Concurrency of assignment statement in C
Thanks.
We have loads/assignments between these instructions that serve as memory
barrier already. If compiler reorder these instructions, it will break
single thread logic.

[发表自未名空间手机版 - m.mitbbs.com]
F****n
发帖数: 3271
14
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
Don't use volatile. Your code is NOT guaranteed to be correct on all
platforms. Unlike in Java, volatile keyword in C++ does NOT enforce memory
barrier, and as a result, the code in your "while(!quit)" loop may be
reordered at the will of the compiler and/or the runtime system.
A rule of thumb in C/C++ is NEVER use volatile.
F****n
发帖数: 3271
15
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
你就不能谦虚一点?这是他的原话
"volatile 就是告诉 CPU 不要优化这个变量 Load/Store 的操作。
每个 memory load/store 都不能省,是有很明确的结果的。
load/store 的优化一般有:
同一个地方load 多次,中间没有写,后面的load和前面一样。
有多个store,前面的 store 可以去掉,最后一个 store 赢。
volatile 保证没有一个 load/store 被省略了。
其他派生出来的就是如何根据这个原理用而以"
你跟我讲讲“不要优化这个变量 Load/Store 的操作。每个 memory load/store 都不
能省”
和C/C++的定义符合的?
恰恰相反,完全错误!
C/C++ volatile周围的load/stores可以随意被reorder优化!因为C/C++不像Java,它
的语言定义不包含内存模型,所谓的load/store这些东西,对C/C++语言本身来说是没
有任何意义的。而volatile是语言定义的一部分,自然也和load/store这些无关。
Memory model在C/C++里是通过at... 阅读全帖
F****n
发帖数: 3271
16
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
那你加volatile的目的是什么?
你也知道cache访问会有问题,
这就是exactly memory barrier, reordering这些讲的东西
你的quit=true只要被调用周围就灰有代码。
b***i
发帖数: 3043
17
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
我觉得cache的问题和memory barrier不是同一个问题。所以我一直认为reordering在
这里不会产生任何问题。
你想啊,我让线程退出,我还能有什么有用的信息告诉线程呢?会有什么错误呢?线程
都要退出了,做什么都不重要了。并不是我要传递几个参数,然后改写一个bool的变量
,然后希望线程读入那几个变量。这里除了quit没有任何其他变量的读写
F****n
发帖数: 3271
18
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
我发现明明我一直在说reorder,你却一直在说省
我建议你再仔细看看我批评的那个帖子的原话,他说的是“优化”。
F****n
发帖数: 3271
19
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
cache access 和 memory barrier 从reorder 优化的角度是一个道理
为什么recorder优化可行?是因为compiler发现你程序某些部分并不互相关联
所以把顺序换换也没关系。但在并行计算的情况下compiler很难通过语义分析(对C/C+
+来说)确定关联性,所以需要额外的memory barrier,它的一个作用就是把一定的顺
序强加在使用不同cache但访问同样内存地址区的并行进程。
为什么决大多数情况下用volatile退出线程不对? 简单的说,因为有数据一致性
要求时volatile不工作,没有数据一致性要求时,你根本不需要volatile。大多数情况
下你总不可能什么都不做就直接quit吧?总要对一些数据进行操作和判断然后决定是否
quit。举个不太恰当的例子:
Connection conn; // assumed to be a db connection;
bool volatile quit;
...
while (!quit) {
conn.doSomething(); // error if conn is closed
... 阅读全帖
a9
发帖数: 21638
20
来自主题: Programming版 - 用volatile退出线程对不对?(C++)
你这是设计有问题。
如果你两个线程都要用数据库连接,那应该各自建一个单独的连接
或者在主线程里建连接,起两个线程,设置quit=true,等两个线程退出,然后断开连接
线程处理本来应该是相对独立的逻辑,你这种处理法用不用线程有什么意义吗

C+
quit
的。
reordering在
线程
变量
b***i
发帖数: 3043
21
来自主题: Programming版 - Bihai,你就用atmoic完事了
UI按钮是让线程优美退出。本来这个while是一直运行的。
具体的例子,比如这个线程是一个lua的bytecode解释程序,那么while的条件就是看看
有没有下一个bytecode了,或者是不是要退出了。如果没有其他的代码了,或者要退出
了,这个解释程序的线程就退出。这个UI的按钮就是告诉线程在还有bytecode的代码的
时候就退出。
void luaInterpreter(...){
while(!quit && hasNextByteCode()){
processNextByteCode();
}
...
}
quit变量和Lua的解释程序的过程没有任何关系。所以我觉得reordering在这个应用里
面是没有关系的。另外bool在一个线程里写其他里读也不用保护。就剩下cache
coherence问题了。好像没有人提出过。
g*****1
发帖数: 54
22
Check in:08/27/11
Check out: 09/01/11
Please email to j***********[email protected]
A hotel has been booked very close to the conference center. We can cancel
it and reorder if necessary.
c*******h
发帖数: 1096
23
来自主题: Computation版 - 大家都用什么解Ax=b啊?
很多学校、实验室、公司都是自己写code的
在bicgstab, gmres, shur complement, AMG, 以及各种reordering和preconditioner
之间根据自己的喜好选择……
l******y
发帖数: 204
24
来自主题: Computation版 - 问个delayed branch的问题
Computer Architecture的一个问题
话说有这么一个Scalar MIPS code for DAXPY (aX + Y):
L.D F0,a ;load scalar a
DADDIU R4,Rx,#392 ;last address to load
Loop: L.D F2,0(Rx) ;load X(i)
MUL.D F2,F2,F0 ;a × X(i)
L.D F4,0(Ry) ;load Y(i)
ADD.D F4,F4,F2 ;a × X(i) + Y(i)
S.D 0(Ry),F4 ;store into Y(i)
DADDIU Rx,Rx,#8 ;increment index to X
DADDIU Ry,Ry,#8 ;increment index to Y
DSUBU R20,R4,Rx ;compute bound
BNEZ R20,Lo... 阅读全帖
d*******n
发帖数: 369
25
我知道他是context adaptive的。有一下两个方面:
1. The number of non-zero coefficients in neighbouring blocks is correlated.
The number of coefficients is encoded using a look-up table; the choice of
look-up table depends on the number of non-zero coefficients in neighbouring
blocks.
2. The level (magnitude) of non-zero coefficients tends to be higher at the
start of the reordered array (near the DC coefficient) and lower towards the
higher frequencies. CAVLC takes advantage of this by adapting the choice of
VL
l******y
发帖数: 204
26
来自主题: EE版 - 问个delayed branch的问题
Computer Architecture的一个问题
话说有这么一个Scalar MIPS code for DAXPY (aX + Y):
L.D F0,a ;load scalar a
DADDIU R4,Rx,#392 ;last address to load
Loop: L.D F2,0(Rx) ;load X(i)
MUL.D F2,F2,F0 ;a × X(i)
L.D F4,0(Ry) ;load Y(i)
ADD.D F4,F4,F2 ;a × X(i) + Y(i)
S.D 0(Ry),F4 ;store into Y(i)
DADDIU Rx,Rx,#8 ;increment index to X
DADDIU Ry,Ry,#8 ;increment index to Y
DSUBU R20,R4,Rx ;compute bound
BNEZ R20,Lo... 阅读全帖
D**u
发帖数: 204
27
来自主题: Mathematics版 - Ordering a sequence (2)
Let x1,...xn,y1,...,yn be 2n distinct real numbers, and xi+xj is not equal
to yk+yl for any i,j,k,l.
Prove that you can properly reordering x1,...,xn to z1,...zn, such that
(zi + zj - yi - yj)*(zi - zj)*(yi - yj) > 0
for all i and j.
s***i
发帖数: 2
28
来自主题: Mathematics版 - 请教一个(非凸)约束优化问题
First, because x_i\le C_i for all index i, then the k-th largest (smallest)
element among x_i is smaller than the corresponding k-th largest (smallest)
element in C_i. Therefore if you reorder x_i into decreasing order (x_n\le x
_{n-1}\le \cdots \le x_1) it does not change the objective function, and the
constraints remains feasible. So you can add extra constraint x_n\le x_{n-1
}\le \cdots \le x_1 to the original problem without changing objective value.
Now by first order condition, it is easy
p**o
发帖数: 3409
29
来自主题: Mathematics版 - 请教一个(非凸)约束优化问题
非常感谢!没想到就这么搞定了。这个reordering的idea真是让人茅塞顿开!

)
)
x
the
-1
value.
solution
mn
发帖数: 46
30
来自主题: PoliticalScience版 - 请推荐一本地缘政治的书
Amazon 上面太多选择了,我又是个工科学生 :(
以下是几本题目看着顺眼的。
Geopolitics: Re-Visioning World Politics (Frontiers of Human Geography)
by John Agnew , UCLA
Reordering the World: Geopolitical Perspectives on the Twenty-First Century
by George J. Demko, William B. Wood
Geopolitical Traditions : Critical Histories of a Century of Political Thought
by Klaus Dodds, David Atkinson
D**u
发帖数: 204
31
来自主题: Quant版 - 来一道题 (转载)
z_1,...z_n is a reordering of x_1,...x_n.
Namely there is a permutation f, such that
z_i = x_f(i).

counter
D**u
发帖数: 204
32
来自主题: Quant版 - Ordering a sequence (2) (转载)
【 以下文字转载自 Mathematics 讨论区 】
发信人: DuGu (火工头陀), 信区: Mathematics
标 题: Ordering a sequence (2)
发信站: BBS 未名空间站 (Wed Dec 16 12:17:39 2009, 美东)
Let x1,...xn,y1,...,yn be 2n distinct real numbers, and xi+xj is not equal
to yk+yl for any i,j,k,l.
Prove that you can properly reordering x1,...,xn to z1,...zn, such that
(zi + zj - yi - yj)*(zi - zj)*(yi - yj) > 0
for all i and j.
a******u
发帖数: 66
33
It has to be the shortest interview that I've ever had, or will have.
tech头说他是被抓来问的,但是他知道我不是programing背景,就问我用什么编程,什
么语言,research用编程么(不
用),知道用script language么(不知道),知道data base么(不知道)。整个过程
很轻松,人很nice。就说要把决定
权给第一轮面我的FE leader。总共过程15分钟不到。
明天hr的人会给我答复,不知道是不是凶多吉少...
Anyway, 借贴问几个最近见到的题目:
1. Reorder a linked list in the order returned by a function. The function
is passed as a function pointer.
(不是很清楚题目的意思。。。)
2。How to change a pair of die so as to create the same probability for
every sum(印象中板上出现过这个题目,... 阅读全帖
w**d
发帖数: 2334
34
来自主题: Science版 - Re: 有限元请教

I use gambit to generate the mesh. You can find some other
software to do this.
The shape of the matrix only depends on the ordering of your elements.
You should reorder the indices of your elements so that you
can get a matrix with smallest band-width. More clearly, you had better
make those neighbor elements have close indices.
Maybe you don't need any algorithm for sparse matrix.
a*****i
发帖数: 4391
35
来自主题: Science版 - [zz] Report from crypo2004
http://www.freedom-to-tinker.com/archives/000664.html
Report from Crypto 2004
Here's the summary of events from last night's work-in-progress session at the
Crypto conference. [See previous entries for backstory.] (I've reordered the
sequence of presentations to simplify the explanation.)
Antoine Joux re-announced the collision he had found in SHA-0.
One of the Chinese authors (Wang, Feng, Lai, and Yu) reported a family of
collisions in MD5 (fixing the previous bug in their analysis), and also
r
y*m
发帖数: 102
36
来自主题: Statistics版 - How to reorder variables in a SAS data set
Have seen many people asking this question over and over again, here is a
solution from SAS support,so I guess it's a legal solution.
http://support.sas.com/kb/8/395.html
Any of the following statements can be used to change the order of
variables in a SAS data set:
ATTRIB, ARRAY, FORMAT, INFORMAT, LENGTH, and RETAIN.
For any of these statements to have the desired effect, they must be
placed prior to a SET/MERGE/UPDATE statement in the DATA step. All of
these statements are declarative state
b**********i
发帖数: 1059
S********a
发帖数: 359
38
Proc factor data=a
simple
method=prin
priors=one
mineigen=1
scree
reorder
rotate=varimax
round
flag=0.4
var aa bb cc dd .....yy;
run;
要做PCA,变量有29个,OBS有92个(我知道不太够),我的code有什么不对或者应该如
何改进。
包子答谢!!!
h***x
发帖数: 586
39
来自主题: Statistics版 - Sample size for clustering analysis
Use Varclus (SAS) and PCA to do variable reduction first before running
clustering. When you only have 10-20 variables, you won't JiuJie to ask the
sampling strategies.
I do not like kmeans. Everytime when I reset the seeds, or even reorder the
dataset, and I will have different results, but the pros is I can get the
results I desire after trying and trying... Not sure if it is kind of
cheating...
Non-parameter clustering (modeclus) is a better choice most of the time. It
can handle the situati... 阅读全帖
w*******y
发帖数: 60932
w*******y
发帖数: 60932
41
This is an amazing price! This is a gift pack that includes a 25 oz. (net
weight) bottle of Agave Nectar and a Cookbook. I've just recently started
using Agave instead of sugar and it's fantastic. It's also great for
diabetics because it's a low glycemic food.
It's on the Deal of the Day on Amazon grocery so this price is only good for
today.
DOTD Price: $16.50 ($0.92 / oz) ($14.03 if you sign up for Subscribe &
Save!!)
Normally: $37.98
You Save: $21.48 (57%)
My favorite recipe in ... 阅读全帖
w*******y
发帖数: 60932
42
http://www.groupon.com/deals/sears-portrait-studios-lubbock?utm_...
A photo session with an unlimited number of subjects (a $14.99 value)
One digitally enhanced 10''x13'' wall portrait of your favorite pose (a $29.
98 value)
One digitally enhanced 16x20 wall portrait of the same or different pose ($
69.98 value)
Bring this Groupon to any Sears location that lovingly houses a Portrait
Studio to receive this bounteous package of beauteous snapshots that can
feature contemporary poses, striking lig... 阅读全帖
w*******y
发帖数: 60932
43
Groupon: for $10, you get five color portrait sheets including one 8''x10'',
two 5''x7'', four 3.5''x5'', and 16 wallet-sized pictures, a photo shoot,
and photo enhancement at Walmart PictureMe Portrait Studios, valid at any
Walmart PictureMe location (a $99 value).
good at any walmart pictureme locations:
http://www.pictureme.com/cpi/en-US/
groupon linky:
http://www.groupon.com/deals/picture-me-studios-fort-worth?c=al
Expires Dec 31, 2011
Limit 1 per person.
Limit 1 per visit.
Limit 1 per sessi... 阅读全帖
w*******y
发帖数: 60932
44
From Shortrun Posters:
http://www.shortrunposters.com/
... I've used them before with great results:
18" x 24" posters now just $2.50!
To celebrate the release of our new website, we've decided to cut the price
of our most popular size, 18" x 24", to just $2.50 through October! This is
a limited time offer, so act fast before it's too late to order your high
quality, full color posters!
About the new site:
Improved uploading system with built-in resolution checker
Image preview and thumbnails du... 阅读全帖
w*******y
发帖数: 60932
45
My first post. I searched and did not find anything of the same. Sorry if
this is a repost. Moderators, if this is not where it should be, please
advise and move as appropriate. Thanks!
Print the attach coupon and bring it with you to your studio session for a
free 16x20 wall portrait. Here's the fine prints.
"A complimentary
Personalized 16x20 Wall Portrait
$84.98 value (includes no session fee)
Additional fee for mounting and framing. Limit one free offer per family,
per visit. Enhancements... 阅读全帖
w*******y
发帖数: 60932
46
Link:
http://itunes.apple.com/app/routes.-planning-your-journeys/id48
, $0.99 now Free
Rated 4 stars


quote



Planning your journeys with Routes. Planning your Journeys is now as
easy as touching a map! Forget using a paper map in a Hotel when you are
going to planning the route for tomorrow! With this app you will save a lot
of time and it will be much more easy!
*** ROUTES. PLANNING YOUR JOURNEYS IS NOW FEATURED BY APPLE IN TRAVEL
CATEGORY (US)! ***
With "R... 阅读全帖
w*******y
发帖数: 60932
47
AppZilla 2 - 120 in 1! [iOS iPhone]
Link:
http://itunes.apple.com/app/appzilla-2-120-in-1!/id400332086?mt
For the first and last time EVER, the full version of AppZilla 2 can be
downloaded for FREE for 24 HOURS ONLY! You've asked for over a year and this
is your chance! After 24 hours the price goes back to 99 cents. ENJOY!
Completely redesigned from the ground up with an ALL-NEW interface, AppZilla
2 contains 120 apps including BRAND-NEW additions like a Barcode Scanner,
Police Scanner, GPS-ba... 阅读全帖
w*******y
发帖数: 60932
48
My 1st Deal Post
Found it as I ordered this morning and notice it went on sale just now
(I cancelled and reordered )
Panasonic KX-TG7644M DECT 6.0 Link-to-Cell via Bluetooth Cordless Phone with
Answering System, Metallic Gray, 4 Handsets
Regularly 109.99
For $89.99
link:
http://iway.org/9571431
more on the phones:
http://iway.org/9571441
h*******s
发帖数: 3932
49
来自主题: _SFparents版 - 粉丝和非粉丝的区别
Its just two meals, or two underwears. We should treat ourselves a little
better..
I decided to use that bumper if necessary.. So reordered it this morning...
g********n
发帖数: 2314
50
来自主题: _GoldenrainClub版 - [合集] goldenrain的观点未免偏颇 (转载)
【 以下文字转载自 SanFrancisco 讨论区 】
发信人: dadabear (bless you), 信区: SanFrancisco
标 题: [合集] goldenrain的观点未免偏颇
发信站: BBS 未名空间站 (Thu Feb 8 16:24:51 2007), 站内
☆─────────────────────────────────────☆
MSJ (Mission San Jose) 于 (Tue Feb 6 00:42:38 2007) 提到:
看完他blog的《现在在哪里买房风险小》,我只能笑着摇摇头。在我眼里,这个列表与
其说是“风险小”列表,不如说是“房子难涨地区列表”。试论证一二:
1. 常言道“强者恒强,弱者恒弱”。NYC, SF地区房价高企不是一年两年了,支撑房价
的不是那个affordability的percentage,而是能afford的人口数和房子总数的比例。
这里看百分比是没有多大意义的。只要还有人能买得起还愿意买,即使affordability
只有15%又如何呢?
2. 正如high tech公司的P/E要远大于... 阅读全帖
首页 上页 1 2 3 4 5 6 (共6页)