8/26/2009

早上去买狗粮,发现晚上有活动Hike With Your Hound,于是下午回家带上胖子就去了Columbia Park,注册完毕正在给胖子戴三角巾,一个摄影师跑过来说“投拍”了我们,于是征得我们同意得到我们的姓名,回家就看到了在jconline,特此纪念一下!
活动挺不错,很多赞助商,petsmart也加入了,所以胖子得到了很多treat还有玩具。下次可能就要等明年,那时候不知道还在不在这呢!
8/20/2009
UPDATE: I still have problems for step i), executable file produced, and can be run normally.
Only problem now is debug step. I need some advices!
a) Start Eclipse and set the workspace to the SDK install folder/projects
b) Create a new C or C++ Makefile Project
New>File>C++ Project; then choose ("Makefile project" in the "Project types" selection window)
In the "Toolchain" selection window select "Linux GCC",set a name and click Finish. Let's say the project name is CUDA_test
c) Add a new Source File with the extension eg. "CUDA_test.cu" and click Finish
File>New>Source File
d) Add a new File called "Makefile" (File>New>File) and click ok
e) Edit the Makefile
Copy these lines to the makefile:
#################################################
# Build script for project
#################################################
EXECUTABLE := CUDA_test
# cu files
CUFILES := CUDA_test.cu
# c/c++
CCFILES :=
CUDA_INSTALL_PATH := /usr/local/cuda
PROJECT_PATH := .
NV_ROOT_PATH := /home/username/NVIDIA_GPU_Computing_SDK/C
ifeq ($(emu), 1)
LIB := -lcufftemu
else
LIB := -lcufft
endif
# Basic directory setup for SDK
# (override directories only if they are not already defined)
#SRCDIR ?= $(PROJECT_PATH)/Source
#ROOTDIR ?= $(PROJECT_PATH)
#ROOTBINDIR ?= $(PROJECT_PATH)/bin
#BINDIR ?= $(ROOTBINDIR)/linux
#ROOTOBJDIR ?= $(ROOTBINDIR)/obj
#LIBDIR := $(NV_ROOT_PATH)/lib
#COMMONDIR := $(NV_ROOT_PATH)/common
include ../../common/common.mk
#######################################################
f) now edit the CUDA_test.cu file
##############################################################################
/*
* Copyright 1993-2008 NVIDIA Corporation. All rights reserved.
*
* NOTICE TO USER:
*
* This source code is subject to NVIDIA ownership rights under U.S. and
* international Copyright laws. Users and possessors of this source code
* are hereby granted a nonexclusive, royalty-free license to use this code
* in individual and commercial software.
*
* NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
* CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR
* IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
* OR PERFORMANCE OF THIS SOURCE CODE.
*
* U.S. Government End Users. This source code is a "commercial item" as
* that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of
* "commercial computer software" and "commercial computer software
* documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995)
* and is provided to the U.S. Government only as a commercial end item.
* Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through
* 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the
* source code with only those rights set forth herein.
*
* Any use of this source code in individual and commercial software must
* include, in the user documentation and internal comments to the code,
* the above Disclaimer and U.S. Government End Users Notice.
*/
// includes, system
#include <stdio.h>
#include <assert.h>
// Simple utility function to check for CUDA runtime errors
void checkCUDAError(const char* msg);
// Part 1 of 1: implement the kernel
__global__ void reverseArrayBlock(int* d_B, int* d_A )
{
int tx = threadIdx.x;
d_B[blockDim.x-tx-1] = d_A[tx];
}
////////////////////////////////////////////////////////////////////////////////
// Program main
////////////////////////////////////////////////////////////////////////////////
int main( int argc, char** argv)
{
// pointer for host memory and size
int *h_a;
int dimA = 256;
// pointer for device memory
int *d_b, *d_a;
// define grid and block size
int numBlocks = 1;
int numThreadsPerBlock = dimA;
// allocate host and device memory
size_t memSize = numBlocks * numThreadsPerBlock * sizeof(int);
h_a = (int *) malloc(memSize);
cudaMalloc( (void **) &d_a, memSize );
cudaMalloc( (void **) &d_b, memSize );
// Initialize input array on host
for (int i = 0; i < dimA; ++i)
{
h_a[i] = i;
}
// Copy host array to device array
cudaMemcpy( d_a, h_a, memSize, cudaMemcpyHostToDevice );
// launch kernel
dim3 dimGrid(numBlocks);
dim3 dimBlock(numThreadsPerBlock);
reverseArrayBlock<<< dimGrid, dimBlock >>>( d_b, d_a );
// block until the device has completed
cudaThreadSynchronize();
// check if kernel execution generated an error
// Check for any CUDA errors
checkCUDAError("kernel invocation");
// device to host copy
cudaMemcpy( h_a, d_b, memSize, cudaMemcpyDeviceToHost );
// Check for any CUDA errors
checkCUDAError("memcpy");
// verify the data returned to the host is correct
for (int i = 0; i < dimA; i++)
{
assert(h_a[i] == dimA - 1 - i );
}
// free device memory
cudaFree(d_a);
cudaFree(d_b);
// free host memory
free(h_a);
// If the program makes it this far, then the results are correct and
// there are no run-time errors. Good work!
printf("Correct!\n");
return 0;
}
void checkCUDAError(const char *msg)
{
cudaError_t err = cudaGetLastError();
if( cudaSuccess != err)
{
fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString( err) );
exit(EXIT_FAILURE);
}
}
#######################################################
g) now you have to change the Project properties.
Right click the project and select properties.
g.1) Select C/C++ Build options.
Deselect the option "Use default build command".
Then, on the Build command input field enter:
For release mode let the field with "make" unchanged.
For debug mode enter "make dbg=1" (Use customarily this option)
For debug emulation mode enter "make dbg=1 emu=1"
(this enables the user to acces GPU functions when debugging
Notice that that the used compiler for GPU functions is not nvcc but gcc)
For emulation mode enter "make emu=1".
g.2) Still in the C/C++ Build options,
Switch to tab "Behaviour"
Empty the textboxes next to Build (Incremental build) and Clean [delete "all" and "clean"]
(located at the bottom of :Workbench Build Type" area)
Select the line "Discovery options" under the menu C/C++ Build
set the Discovery profile to "GCC per project scanner info profile"
g.3) At C/C++ General
Select the line "Paths and symbols" under the menu and
switch to the tab "Library Paths". Click on Add and enter "$LD_LIBRARY_PATH".
Select the box "Add to all configurations"
At last click ok to close this tab, and again to close the "Paths and symbols window"
g.4) Ctrl + b to Build Project
h) Now create a debug profile for this project (assuming the executable could be produced).
h.1) Right click the Project option and select "Debug As..">"Open Debug Dialog...".
Double left-click on C/C++ Local Application to add a new debug configuration
h.2) Select the new configuration and then in the line "C/C++ Application:"
click "Browse..." and select the executable from your filesystem.
[it should be here "/home/username/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/"]
h.3) Now switch to the tab common and select in the box "Display in favorites menu" the
checkbox for Debug. Press Apply and close the window.
i) Press F11 to start the program or select the start configuration from the "bug" button
in the shortcut menu.
Then you have the following options:
RUN dialog give the different opportunities
F8 from break point to break point (or end)
F6 execute stepwise
F5 step into function
Thanks bin04017 @ gmail.com for his/her instructions from nvidia forum.
8/18/2009
My steps are:
1. install the 2.6.28.11 server;
2. without install gnome, "sudo apt-get install build-essential linux-headers-`uname -r`"
3. wget the cuda 2.3 driver for ubuntu 9.04
4. at this moment, since no gnome installed, no X-server is on, "sudo sh NVIDIA_LONG_NAME_64_BIT_DRIVER.run"
5. It asked me if I would like to install 32 bit compatible OPEN GL library, i said yes
6. Installed Nvidia driver sucessfully
7. install gnome
8. reboot
9. in gnome, run "sudo nvidia-xconfig"
After done with above, go to System -> Preferences -> Display,
it would say something about some feature is not there, it asks whether
you want to use alternative driver from your graphics card. Choose "YES", then you can see the Nvidia X driver Utilities Panel
ONE MORE THING: after changing all the display settings, you would like to save that xorg.config, but the system would tell you it could not remove/create xorg.config.backup. What I did was, clicked on the preview settings, and copied the whole thing, manually changed xorg.config by editor.
And now you can reboot, and you will see the display setting is still there!
Add /usr/local/cuda/bin to $PATH, /usr/local/cuda/lib64 to $LD_LIBRARY_PATH, ~/NVIDIA_GPU_Computing_SDK/C to $NVSDKCUDA_ROOT.You should put them into ~/.bashrc to make it permernant!
Added some lib such as
libglut3, libxi and libmu to make the "make" under SDK run)
Then CUDA SDK samples all worked on my system!
It's time to get some my own test code running!
8/11/2009
才知道是第一条!一定要转
2009年08月11日 15:07:32
来源:新华网
|

1952年7月1日,成渝铁路全线通车。图为由成都驶往重庆的第一列火车出站。
中国地大物博,铁路作为国家重要基础设施,国民经济的大动脉、大众化的交通工具,在经济社会发展中发挥着巨大作用。而在纵横交错的铁路线中,有一个令新中
国铁路建设者们振奋且永远不能忘怀的名字,它在中国铁路发展史上具有极其重要的意义,因为它是新中国自行修建的第一条铁路——成渝铁路。这是中国自行设计
施工,完全采用国产材料修建的第一条铁路,是中国铁路史上的一个创举。
成渝铁路线西起成都,东抵重庆,全长505公里,作为中国西南地区第一条铁路干线,是连接川西、川东的经济、交通大动脉。新华社发

1952年7月1日由重庆开出的第一列火车,在2日上午11时5分到达成都车站,受到川西区和成都市各界人民5万余人的热烈欢迎。 新华社发