首页 \ 问答 \ OS X文件名中的变音器(perl)(Umlauts in OS X file names (perl))

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
更新时间:2023-06-07 12:06

最满意答案

尽管您尝试与屏障同步,但您在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 ...
  • 我认为你对reduction条款的含义有误解...... REDUCTION(+:index) 意味着,你最终会得到正确的和index 。 在迭代的每个步骤中,每个胎面将具有不同的版本,具有不同的值! 因此,减少不适合在并行部分期间管理数组索引。 让我试着说明一下...... 以下循环 !$OMP PARALLEL DO PRIVATE(iy) REDUCTION(+:index) do iy = 1, number(2) index = index + 1 end do !$OMP END PARA ...
  • 当我做了以下事情时,我发现它有效。 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

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)