2012年5月22日火曜日

linux, openmp使用時のCのrealtime timer


openmp使用時のrealtime timerを試す。

1. gettimeofday() --- 安定してほぼ同じ値を返す。しかし"POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of clock_gettime(2) instead."(man gettimeofdayより)

$ time ./a.out
thread=2
thread=3
thread=5
thread=4
thread=7
thread=6
thread=1
thread=0
2.003188


real 0m2.007s
user 0m0.044s
sys 0m0.024s

2.clock_gettime() --- こちらを推奨しているが安定しない。値が変。
$ time ./a.out
thread=2
thread=7
thread=4
thread=5
thread=0
thread=1
thread=6
thread=3
7.540382

real 0m2.009s
user 0m0.084s
sys 0m0.000s

$ time ./a.out
thread=1
thread=5
thread=4
thread=6
thread=7
thread=0
thread=2
thread=3
3.323497

real 0m2.005s
user 0m0.052s
sys 0m0.008s


ソース
#include <stdio.h>
#include <unistd.h>
#ifdef CLOCK
#include <time.h>
#else
#include <sys/time.h>
#endif
#include <omp.h>
double second_() {
 struct timespec res;
#ifdef CLOCK
 clock_gettime(CLOCK_MONOTONIC, &res);
 return (res.tv_sec + res.tv_nsec * 1.0e-6);
#else
   struct timeval tv;
   struct timezone tz;
  gettimeofday(&tv,&tz);
 return ( tv.tv_sec + tv.tv_usec*1.0e-6);
#endif
}

int main() {
 double a,b;
 a=second_();
#pragma omp parallel
 printf("thread=%i\n",omp_get_thread_num());
 sleep(2);
#pragma omp end parallel
 b=second_();
 printf("%lf\n",b-a);
 return 0;
}
コンパイル&リンク
$ cc (-DCLOCK) -fopenmp thisfile.c -lrt
ubuntu 11.10, core i7 (4core,8thread)
参考:

2012年5月19日土曜日

2012年5月18日金曜日

突然evernoteのdrag&dropの添付ができなくなる。

問題発生:Chromeで使っているとevernoteの添付ファイルdrag&dropで突然こんなpopupが

添付ファイルは約300kbyteの絵ですから意味不明です。evernoteでなければweb詐欺かと思います。
始めてなので慌てて、容量オーバーかと思って大きなサイズのファイルを消してしまいました。

しかし、「設定」の方からはまだまだ余裕があるのもわかります。

対処:drag&dropでなく「ファイル添付」の方からは添付可能でした。

evernoteが使いにくくなりました。


追記:
2012-05-29 直っていることを確認

2012年5月1日火曜日

ubuntuのアップデートマネージャーでエラーが起きる場合

ubuntuのアップデートマネージャーでエラーが起きる場合
apt-get autoclean
apt-get update
の後に再びアップデートマネージャーから「アップデートをインストール」

pgp keyのエラーが起きる場合も私はこれでいけた。