2010年4月27日 星期二

CUDA programming under Compute-Exclusive Mode

How can I tell my programs to choose the available device automatically

It is very simple to make your program automatically choose the right device: DO NOT use cudaSetDevice().
When you don't explicitly specify to use which device, your CUDA program will first try to set up context on device0. If device0 is not available, it will try device1.

What will happen if I choose a device which is being used by another program.

Since all GPU devices have been configured as compute-exclusive mode, the second thread which tries to contact with GPU device will be denied. If you insist using this device by using cudaSetDevice() in your code, you will receive an error when running a CUDA API function.

2010年4月19日 星期一

How to Step TAB for SCREEN

#編輯 .screenrc

vi ~/.screenrc
caption always "%{= bK} %{= bG} [%n]%t @ %H %{-} %= %{= bR} %l %{-} | %{= bG} %Y-%m-%d %{-}"
hardstatus alwayslastline " %-Lw%{= BW}%n%f %t%{-}%+Lw %=| %0c:%s "
 
# Ctrl + left  : last page
# Ctrl + right : next page
bindkey "^[[1;5C" next
bindkey "^[O5C" next
bindkey "^[[C" next
bindkey "^[[1;5D" prev
bindkey "^[O5D" prev
bindkey "^[[D" prev


SCREEN 熱鍵

1) Ctrl+a c:建立一個新分頁
2) Ctrl+a a:分頁往返
3) Ctrl+a [1...9]:切換到第 n 分頁
4) Ctrl+a d:Detach 將工作放到背景執行
5) Ctrl+a S:分割上下畫面
6) Ctrl+a [TAB]:在分割畫面中往返

References:
http://en.gentoo-wiki.com/wiki/Screen
http://blog.cwke.net/2008x06/screen
screen
screen 常用教學筆記

2010年4月8日 星期四

strtok 應用

char* strtok(char* str, const char* delimiters)

用途:將字串切割成tokens


用法:

#include <iostream>
#include <string.h>

using namespace std;

int main()

{
    char c[20] ="Hello World!"
    char *s;
    
    s = strtok(c, " ");

    while(s!= NULL){
      cout >> s >> endl;

      s = strtok(NULL, " ");
    }
}

2010年4月7日 星期三

解決ssh 連線登入問題

3.3 - ssh(1) takes a long time to connect or log in

Large delays (more that 10 seconds) are typically caused a problem with name resolution:
  • Some versions of glibc (notably glibc 2.1 shipped with Red Hat 6.1) can take a long time to resolve "IPv6 or IPv4" addresses from domain names. This can be worked around with by specifying AddressFamily inet option in sshd_config.
  • There may be a DNS lookup problem, either at the client or server. You can use the nslookup command to check this on both client and server by looking up the other end's name and IP address. In addition, on the server look up the name returned by the client's IP-name lookup. You can disable most of the server-side lookups by setting UseDNS no in sshd_config.
解決的方法, 修改 /etc/ssh/sshd_conf 裡面
UseDNS no

小於 3.7.1 版之前的請改
VerifyReverseMapping no

更早之前的如 2.9.9p2 
ReverseMappingCheck no
* Replaced sshd(8)'s VerifyReverseMapping with UseDNS option.
  When UseDNS option is on, reverse hostname lookups are always
  performed.