OS X文件名中的变音器(perl)(Umlauts in OS X file names (perl))
我在OS X的文件名中遇到了元音变音(ü字符)的麻烦。我使用perl脚本创建目录。 从概念上讲,我正在做的是:
$NAME = "abcüabc"; $PATH = "/Applications/MyProgram/".$NAME."/"; system('ditto', '--rsrc', $FROMPATH, $PATH . $FILENAME);
这将创建名称为
"/Applications/MyProgram/abs%9Fabc/"
的文件夹。任何人都知道如何解决这个问题,以创建具有正确字符的目录?
I'm having some troubles with umlauts (ü character) in filenames on OS X. I'm creating the directory from a perl script. Conceptually what I'm doing is:
$NAME = "abcüabc"; $PATH = "/Applications/MyProgram/".$NAME."/"; system('ditto', '--rsrc', $FROMPATH, $PATH . $FILENAME);
This creates the folder with the name
"/Applications/MyProgram/abs%9Fabc/"
.Anyone know how I can fix this to create the directory with the correct characters?
原文:https://stackoverflow.com/questions/5793548
最满意答案
尽管您尝试与屏障同步,但您在
working_threads
上确实存在竞争条件,这很容易导致迭代次数不等:thread 0 | thread 1 ... | ... while (working_threads > 0) [==true] | ... if (my_num == 1) [==true] | ... working_threads = 0 | ... | while (working_threads > 0) [==false] [hangs waiting for barrier] | [hangs trying to exit from parallel]
要修复特定代码,您还必须在while-condition-check和
working_threads = 0
之间添加一个屏障。#pragma omp parallel { int my_num=omp_get_thread_num()+1; int idle=false; while(working_threads>0) { #pragma omp barrier if(my_num==1) working_threads=0; #pragma omp barrier } }
请注意,代码并不是最惯用或最优雅的解决方案。 根据您的具体工作共享问题,可能有更好的方法。 此外,您必须确保
worker_threads
仅由单个线程编写 - 或在写入时使用atomics。Despite your attempt to synchronize with the barrier, you do have a race condition on
working_threads
that can easily lead to unequal amount of iterations:thread 0 | thread 1 ... | ... while (working_threads > 0) [==true] | ... if (my_num == 1) [==true] | ... working_threads = 0 | ... | while (working_threads > 0) [==false] [hangs waiting for barrier] | [hangs trying to exit from parallel]
To fix your specific code, you would have to also add a barrier between the while-condition-check and
working_threads = 0
.#pragma omp parallel { int my_num=omp_get_thread_num()+1; int idle=false; while(working_threads>0) { #pragma omp barrier if(my_num==1) working_threads=0; #pragma omp barrier } }
Note that the code is not exactly the most idiomatic or elegant solution. Depending on your specific work-sharing problem, there may be a better approach. Also you must ensure that
worker_threads
is written only by a single thread - or use atomics when writing.
相关问答
更多-
如果使用32位浮点数并算术运算84.26539和84.26538之间的84.26539 ,即最低有效位数之差为1 ,则可以通过并行浮点算法的非确定性完全解释。 请记住,32位fp编号只能播放大约7位小数。 普通浮点运算不是严格关联的。 对于真实的(在数学而非Fortran意义上)数字(a+b)+c==a+(b+c)但是对于浮点数没有这样的规则。 维基百科关于浮点运算的文章很好地解释了这一点 。 产生非确定性的原因是,在使用OpenMP时,您将对操作顺序的控制放弃到运行时。 线程之间的值的总和(例如+上的减少 ...
-
尽管您尝试与屏障同步,但您在working_threads上确实存在竞争条件,这很容易导致迭代次数不等: thread 0 | thread 1 ... | ... while (working_threads > 0) [==true] | ... if (my_num == 1) [==true] | ... working_threads = ...
-
该错误实际上是由src / Makevars.win文件中的UTF-8 BOM引起的,删除了BOM为我修复了它。 The error is actually caused by UTF-8 BOM in the src/Makevars.win file, removing BOM fixed it for me.
-
如果您查看OpenMP V3.0规范,2.5工作共享构造,请说明: 以下限制适用于工作共享构造: 每个工作共享区域必须由团队中的所有线程遇到或根本不遇到。 对于团队中的每个线程,遇到的工作共享区域和障碍区域的顺序必须相同。 通过在if中使用工作共享,您违反了这两个限制,使您的程序不符合要求。 根据规范,不合格的OpenMP程序具有“未指定的”行为。 至于将使用哪些线程来执行for循环,使用调度类型“static,1”,第一个工作块 - 在这种情况下count = 0 - 将被分配给线程0.下一个块(coun ...
-
好的我已经得到了答案,但我很生气...... 这是一种竞争条件,因为rho是共享的,你可以在并行区域内初始化它,如rho = 0.0; 要么将其初始化到并行区域之外,要么在之前使用#pragma omp single来修复代码...... OK I've got the answer, but I sweat to get it... This is a race condition due to the fact that rho is shared and that you initialise it ...
-
不要乱用一个OpenGL上下文和多线程,或者通过一个关键部分保护OpenGL的每次使用(这不会给你带来性能上的任何好处)。 您可以做的是使用顶点数组/缓冲区(无论如何都会更快)并使用多个线程填充数据,然后再在单个线程中绘制它们。 如果一个线程设置当前颜色并在绘制顶点之前取消预定,会发生什么? 但肯定会发生的是,驱动程序在某些操作过程中被中断,其内部数据完全混乱。 OpenGL绝对不是线程安全的。 Don't mess with a single OpenGL context and multithreadi ...
-
您可以尝试在single构造中添加nowait子句: 编辑 :回应第一条评论 如果为OpenMP启用嵌套并行性,则可以通过实现两个并行级别来实现所需。 在顶层,您有两个并发的并行部分,一个用于MPI通信,另一个用于本地计算。 最后一节本身可以并行化,这为您提供了第二级并行化。 只有执行此级别的线程才会受到其中的障碍的影响。 #include
#include int main() { int kill = 0; #pragma omp parallel secti ... -
您的程序不是有效的OpenMP代码。 sections是一个工作共享构造,因此团队中的所有线程都必须遇到它们,即使没有足够的部分来提供所有线程( OpenMP规范 ,第2.7节): 除非为最内层的并行区域请求取消,否则每个工作共享区域必须由团队中的所有线程遇到或者根本不遇到。 将它放在if运算符的一个分支中意味着某些线程不会遇到它。 实际上,这会导致在sections结构末尾的隐式屏障处挂起。 我不确定你到底想要实现什么,但代码必须以某种方式重组。 Your program is not a valid O ...
-
OpenMP over Summation(OpenMP over Summation)[2023-04-23]
我认为你对reduction条款的含义有误解...... REDUCTION(+:index) 意味着,你最终会得到正确的和index 。 在迭代的每个步骤中,每个胎面将具有不同的版本,具有不同的值! 因此,减少不适合在并行部分期间管理数组索引。 让我试着说明一下...... 以下循环 !$OMP PARALLEL DO PRIVATE(iy) REDUCTION(+:index) do iy = 1, number(2) index = index + 1 end do !$OMP END PARA ... -
CUDA结合OpenMP(CUDA combined with OpenMP)[2022-05-25]
当我做了以下事情时,我发现它有效。 nvcc 标志 -Xcompiler -fopenmp -fgomp 文件的东西 感谢都铎王朝 I found out that it worked when I did the following. nvcc flags -Xcompiler -fopenmp -fgomp file stuffs Thanks to Tudor