找回密码
 新注册用户
搜索
楼主: 碧城仙

[已完成翻译] [BOINC 开发文档]Developing a BOINC application 部分

[复制链接]
发表于 2006-5-12 16:49:23 | 显示全部楼层
对不住各位,我前两天一直忙着毕业设计,没能参加讨论。
现在总算搞完了,又可以为论坛做点事情了。
回复

使用道具 举报

发表于 2006-5-22 19:48:14 | 显示全部楼层

Application development tips

翻译页面地址:http://boinc.berkeley.edu/app_dev.php

Application development tips
建立一个新程序的一些建议
-------------------------------------------
Cross-platform functions
不同系统的函数设置:
-------------------------------------------
    Most POSIX calls are supported on Unix and Windows. For areas that are different (e.g. scanning directories) BOINC

supplies some generic functions with implementations for all platforms. Similar code may be available from other open-source

projects.
-------------------------------------------
    大部分的POSIX代码都是UNIX平台和WINDOWS平台通用的,两个平台之间代码不同用的部分是不一样的,例如(scanning directories部分

就不能实现代码的通用)。BONIC提供一些两个平台都通用的基本函数,建议您可以借鉴一些开放源代码的项目,将一些类似部分的代码

添加到你的项目中,或许也可以用。
-------------------------------------------

Windows-specific issues
windows平台的注意事项:
-------------------------------------------
   The set of 'standard' DLL differs somewhat among 9X/NT/2000/XP. To avoid crashing because a DLL is missing, call

::LoadLibrary() and then get function pointers.
   Visual Studio: set 'Create/Use Precompiled Header' to 'Automatically Generate' (/YX) in C/C++ Precompiled Header project

properties.
   Visual Studio: change 'Compile As' to 'Compile as C++ Code (/TP)' in C/C++ 'Compile As' project properties.
-------------------------------------------
   9X/NT/2000/XP系统的"标准"DLL设置稍有区别,为了避免因找不到DLL而发生的错误,请调用LoadLibrary()以取得函数指针.
   Visual Studio:在C或C++中设置Create/Use Precompiled Header为Automatically Generate' (/YX),请预先编辑header项目的性质

(Precompiled Header project properties)
   Visual Studio: 在C或C++的Compile As项目性质中,将Compile As调整为Compile as C++ Code (/TP)' in C/C++
------------------------------------------

Unix-specific issues
Unix平台注意事项:
------------------------------------------
Most important: use gcc-3.0, at least for linking. This should limit the executable to GLIBC-2.2 symbols. Einstein@Home

builds Apps on a Debian Sarge (3.1) system, using the gcc-3.0 from Woody. Take special care of which libs to link statically

and which dynamically if you are using e.g. OpenGL.

For a portable build of the BOINC Core Client I found no better way than to make a clean Debian Woody installation (in a

VMWare machine) from DVD, refusing all online updates (of the GLIBC). However this was quite some time ago, before BOINC

switched to ssl, curl and zlib, I don't know if and how this still works.
------------------------------------------
关键在于使用gcc-3.0(至少作为连接用)这应该会限制GLIBC-2.2代码的执行。Einstein@Home开发了基于Debian Sarge (3.1)的APPS,使用了来自于woody的gcc-3.0。此处特别注意静态联接到哪个库服务程序,(LIBrary Service),还要注意只在程序运行期间建立起来的一些特性,例如OPENGL.,对于用手提式电脑的BOINC核心用户而言,从DVD中将Debian Woody安装到电脑上,并下载最新的补丁,哪怕所谓的“最新版本”也只以一个较早发布的补丁。可我不知道BOINC调整到ssl(加密套接字协议层), curl和zlib之前是否管用。
------------------------------------------

Cross-language issues
两个平台通用的语言:
------------------------------------------
The BOINC API is implemented in C++. Information about using it from C and FORTRAN is here.
------------------------------------------
BOINC的应用程序界面执行的是C++语言,想要了解在C语言或FORTRAN语言的状态下使用它,请点击 这里 。


====================================================
累死我啦~~~

(感谢Youth)
其他地方可能也有点问题,欢迎各位来校对一下..3Q
http://dogcatdog.blogchina.com    @   19:47 2006-5-22完成。
====================================================

评分

参与人数 2基本分 +50 维基拼图 +40 收起 理由
BiscuiT + 50 + 25
霊烏路 空 + 15

查看全部评分

回复

使用道具 举报

发表于 2006-5-22 20:04:39 | 显示全部楼层
call::LoadLibrary() and then get function pointers.

应该是“调用LoadLibrary()以取得函数指针”。
回复

使用道具 举报

发表于 2006-5-24 22:10:08 | 显示全部楼层
引用 碧城仙 在 2006-4-1 13:52 时的帖子:
Developing a BOINC application 部分

待翻译的页面列表见:http://boinc.berkeley.edu/create_project.php
http://boinc.equn.com/dev/create_project.html

Developing a BOINC ...


App development cookbook有人在作吗?
如果没有人,先允许我尝试一下,可以吗
回复

使用道具 举报

发表于 2006-5-25 08:05:00 | 显示全部楼层
翻译页面地址:http://boinc.berkeley.edu/myers.txt

App development cookbook
=======
I'm working with my student, Kim Lefkowitz, on learning how to write
BOINC applications.  We've been doing this both by reading the
examples that come with the distribution and by trying to write our
own simple programs.  As a result, we've come up with the simplest
BOINC program, the "Hello, World!" program of BOINC.  It just opens a
file and writes to it and the file is uploaded to the server.  
我和我的学生Kim Lefkowitz一起,通过阅读发行版中的和我们自己编写的例子,学习如何编写BOINC应用程序。现在,我们已经写出了一个最简单的BOINC程序“Hello,World!”,仅仅打开一个文件,写入,然后上传到服务器。
=======
We'd like to share this with anybody who might have to go through the
whole process of learning to write BOINC apps.   And of course learn
from any suggestions on making it even simpler or the comments clearer.
我们很乐意和任何可能必须经历整个学习过程的人分享程序,当然也很乐意听取使程序更简单清晰的建议。
=======
A copy of the program is attached below (it's short, of course) but
I've also packed it up with example workunit and result files, a
Makefile for Unix and a .dsw for Windows.  These are all in the
hello-boinc tarball at http://noether.vassar.edu/pub/myers/src/
文件的拷贝在下方贴出(当然它很短),但是我还是把它与example workunit、result files、a
Makefile for Unix and a .dsw for Windows一起打包为hello-boinc (tar压缩),放在了http://noether.vassar.edu/pub/myers/src/目录下。
=======
But you don't need the tarball, you can just put the code below in the
file hello.C in the apps directory, and then edit the Makefile to
change "1sec" to "hello" everywhere and it will build.
但是你并不需要压缩包,你可以把下面的代码保存为hello.C放在应用程序目录下,然后编辑Makefile,在需要编译的地方替换“1sec”为“hello”。
=======
[Suggestion: the 1sec app does not work.  We were initially distracted
into trying to get it to run until we figured out that it does not use
the API.  So how about replacing apps/1sec with this?  I see 1sec is
mainly used for the test suite, so if it is to be kept then maybe move
it to the test/ directory.]

     -Eric Myers
[建议:1sec程序不会工作。我们最初分心于试图使之能够运行,直到我们发现它不实用API。如何替换1sec应用程序呢?我发现1sec被检验程序大量使用,所以如果它应该保留,也许可以把它放在test目录下。]

      -Eric Myers
===========================================
/***********************************************************
*  Hello, BOINC World!
*  
* This is the Hello World program for BOINC.  It is the simplest application
* that one can write which uses the BOINC API and writes some output to a
* file (called "out").   See the sample workunit and result templates to
* see how this file is mapped to a real file and how  it is uploaded.
*
* Eric Myers <[email protected]>  - 16 June 2004 (Unix) and 6 July 2004 (Win)
* Department of Physics and Astronomy, Vassar College, Poughkeepsie, New York
* @(#) Version: 3.12
*/


//  Stuff we only need on Windows:
#ifdef _WIN32
  #include "boinc_win.h"
#endif

#include "boinc_api.h"                //
#include "filesys.h"                // boinc_fopen(), etc...
#include "util.h"               // parse_command_line(), boinc_sleep()



int main(int argc, char **argv) {
    int rc;
    char resolved_name[512];
    FILE* f;


    // All BOINC applications must initialize the BOINC interface:

    rc = boinc_init();
    if (rc){
      fprintf(stderr, "APP: boinc_init() failed.\n");
      exit(rc);
    }
        

    // input and output files need to be "resolved" from their logical name
    // for the app to the actual path on the client disk

    rc = boinc_resolve_filename("out", resolved_name, sizeof(resolved_name));
    if (rc){
      fprintf(stderr, "APP: cannot resolve output file name.\n");
      exit(boinc_finish(rc));
    }


    // Then open the file with boinc_fopen() not just fopen()

    f = boinc_fopen(resolved_name, "w");
        

    // Write some output to the file

    fprintf(f, "Hello, BOINC World!\n");


    // Now run up a little credit..

    { int j, num;
      fprintf(f, "Stress test begins...\n");
          for (j=0;j<123456789;j++){ num=rand(); }
      fprintf(f, "Stress test ends...\n");
    }

    fclose(f);

    // All BOINC applications must exit via boinc_finish(rc), not merely exit

    boinc_finish(0);       /* should not return */
    return 47;
}




/* Dummy graphics API entry points */

void app_graphics_init() {}
void app_graphics_resize(int width, int height){}
void app_graphics_render(int xs, int ys, double time_of_day) {}
void app_graphics_reread_prefs() {}
void boinc_app_mouse_move(int x, int y, bool left, bool middle, bool right ){}
void boinc_app_mouse_button(int x, int y, int which, bool is_down){}
void boinc_app_key_press(int, int){}
void boinc_app_key_release(int, int){}



/* Windows entry point WinMain() */

#ifdef _WIN32

/*******************************************************
* Windows:  Unix applications begin with main() while Windows applications
* begin with WinMain, so this just makes WinMain() process the command line
* and then invoke main()
*/

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
                   LPSTR Args, int WinMode)
{
    LPSTR command_line;
    char* argv[100];
    int argc;
   
    command_line = GetCommandLine();
    argc = parse_command_line( command_line, argv );
    return main(argc, argv);
}

#endif

评分

参与人数 2基本分 +60 维基拼图 +42 收起 理由
BiscuiT + 60 + 30
霊烏路 空 + 12

查看全部评分

回复

使用道具 举报

发表于 2006-5-27 09:39:13 | 显示全部楼层

DEBUG来啦~~

http://boinc.berkeley.edu/app_debug.php


Application debugging
程序中的错误
----------------
Standalone mode
独立运行模式
---------------
When you have built your application and linked it with the BOINC libraries, you can run it

in 'standalone mode' (without a BOINC core client present). To do this, put instances of

all input files in the same directory. (with the proper logical, not physical, names). The

application should run and produce output files (also with their logical names). You can

run the program under a debugger.

当你建立好程序并将它连接到BOINC的库服务器(libraries)后,即可在独立模式状态运行程序(不在

BOINC客户端控制下运行)怎样实现这个:将所有导入的文件放入相同的文件夹。(以适当的逻辑形式,

不要用物理代号,名字[physical,names])运行计算程序,它会产生出一些文件并导出它们的逻辑名

(logical names),你可以在纠错器的控制下运行计算程序。
-----------------

When you run an application in standalone mode, the BOINC API will recognize this and take

it into account. A couple of things to note:

If your application does graphics, it will open a graphics window. Closing this window will

exit your application.
boinc_time_to_checkpoint() will always return false, so your application will never

checkpoint.

当程序在独立模式状态运行时,BOINC将会识别然后记录到你的账目中。有一些事情要注意:
如果你的程序可以显示屏保,那么它会打开屏保,屏保如果关闭屏保可能会退出计算程序
请注意boinc_time to checkpoint()它返回的结果总是逻辑假(false),那么你的计算程序将永远没有

检查点(checkpoint)
-------------------
Using the anonymous platform mechanism
使用匿名操作平台的机器
--------------------

Once your application works in standalone mode you'll want to run it from the BOINC core

client. This will exercise the various forms of interaction with the core client.
To get this process started, create a test project, add an application version and some

work, then run the core client. It will download everything and run your application, which

will possibly crash.

如果计算程序在独立模式运行是你想让它从boinc的客户端运行,这可以测试和客户端合作的各种状况。
想让测试开始,新建一个项目,添加一个应用程序和一些工作,然后运行客户端,它将会下载所有有可

能冲突的工作并尝试运行他们。
--------------------

At this point you'll want to start experimenting with your application. It would be very

tedious to create a new application version for each change. It's far easier to use BOINC's

anonymous platform mechanism. To do this:

Following the directions, create a file 'app_info.xml' in the client's project_* directory,

with the appropriate name and version number of your application.
Each time your build a new version of your application, copy the executable into the

project_* directory, making sure it has the appropriate name. Then restart the core client.

就这一点而言你可能想对你的程序进行测试。但为了改变一些参数而从新创建一个新版本的程序将会很

烦人。与此相比使用BOINC的 匿名平台 程序将会方便许多。怎样实现这个:
按照 指南 ,在程序的project_*文件夹中,新建一个文件'app_info.xml',这应当包括程序名和版本号


每一次你将你的程序改进到新版本后,复制执行的文件到project_*文件夹,请确认它包含了程序名,然

后重起你的客户端。
----------------------
On Unix, it's possible to attach a debugger to a running process. Use 'ps' to find the

process ID of your application, then something like

gdb exec_filename PID

to attach a debugger to it.

在unix平台上,可以实现纠错器和计算程序捆绑在一起,用"ps"找到程序的id号,那么可能会出现类似

于:
gdb exec_filename PID的东西捆绑在纠错器上。
----------------------
Getting and deciphering stack traces
Once your application is working on your own computers, you're ready to test it with

outside computers (alpha testers initially). It may crash on some computers, e.g. because

their software or hardware is different from yours. You'll get some information back in the

stderr_txt field of the results. If your application called boinc_init_diagnostics() with

the BOINC_DIAG_DUMPCALLSTACKENABLED flag set, and you included symbols, hopefully you'll

get symbolic stack traces.

To decipher a Windows stack trace go here.

Otherwise, you should at least get numeric (hex) stack traces. You can decipher these by

running a symbolic debugger with an unstripped version and typing in the hex addresses. See

http://developer.apple.com/techn ... 3.html#SECNOSYMBOLS


得到和了解栈式存储器的跟踪(stack traces)
既然你的程序在自己的电脑上测试够了,你准备去用别人的电脑来测试它(首先是alpha测试者)。在其

他电脑上运行很可能会出错,例如说因为他们的硬件和软件和你的不同。你将会获得返回信息,它包含

在stderr_txt的信息中。如果你的程序调用了包含BOINC_DIAG_DUMPCALLSTACKENABLED和你所用的代码标

志位的boinc_init_diagnostics(),但愿你可以得到栈式存储器的跟踪系统,想理解栈式存储器的跟踪

请点 这里 否则,你至少应该得到一个十六位进制的栈式存储跟踪器,你可以通过运行未定义版本的计

算程序和代码纠错器,然后输入十六进制代码地址来了解它,详见:
http://developer.apple.com/techn ... 3.html#SECNOSYMBOLS

====================================================
累煞我也

文章应该没问题,欢迎各位来校对一下..3Q
http://dogcatdog.blogchina.com

====================================================

[ Last edited by dogcatdog on 2006-5-27 at 09:42 ]

评分

参与人数 2基本分 +60 维基拼图 +40 收起 理由
BiscuiT + 60 + 20
霊烏路 空 + 20

查看全部评分

回复

使用道具 举报

发表于 2006-5-28 15:33:59 | 显示全部楼层

8楼的修改建议

当BOINC的全屏按钮被选中 -> 当在屏保中显示图形时

这些函数产生一个worker线程来运行住程序函数
worker线程直接翻译成"工作线程"? 住程序->主程序

由于Unix/Linux图形算法利用多线程技术,因此Unix/Linux程序使用可以用-D_REENTRANT编译所有文件的图形算法。-> 由于图形需要使用到多线程,因此使用图形的Unix/Linux计算程序应该使用-D_REENTRANT来编译所有文件。

它使任何必须的调用在窗口中初始化图形。 -> 它必须进行任何需要的调用以初始化图形。

该函数当窗口大小变化时被调用。 -> 当窗口大小变化时调用该函数。

帧频率 -> 帧率?

是执行图形算法的CPU时间片的上界 -> 是图形算法所占消耗的CPU使用率的上限

支撑类 -> 辅助类?

评分

参与人数 1维基拼图 +8 收起 理由
霊烏路 空 + 8

查看全部评分

回复

使用道具 举报

发表于 2006-5-29 13:17:54 | 显示全部楼层

17楼的修改意见

建立一个新程序的一些建议 -> 计算程序开发技巧

不同系统的函数设置 -> 跨平台的函数

POSIX代码 -> POSIX调用

大部分的POSIX代码都是UNIX平台和WINDOWS平台通用的,两个平台之间代码不同用的部分是不一样的,例如(scanning directories部分就不能实现代码的通用)。BONIC提供一些两个平台都通用的基本函数,建议您可以借鉴一些开放源代码的项目,将一些类似部分的代码添加到你的项目中,或许也可以用。 -> 大部分的POSIX调用都是UNIX平台和WINDOWS平台通用的,而对于那些不通用的部分,比如目录扫描,BOINC提供了一些可用于所有平台的基本函数。类似的代码也可以从其它一些开源项目得到。

"标准"DLL设置 -> “标准”DLL集 ?

set 'Create/Use Precompiled Header' to 'Automatically Generate' (/YX) in C/C++ Precompiled Header project properties.

在项目属性的C/C++ Precompiled Header部分将'Create/Use Precompiled Header'设置为Automatically Generate' (/YX)。

change 'Compile As' to 'Compile as C++ Code (/TP)' in C/C++ 'Compile As' project properties.

在项目属性的C/C++ Advanced部分将Compile As设置为Compile as C++ Code (/TP)。

// 上面两句,因为我手头没有中文版的vs,不清楚中文版的标准翻译是什么,就直接写英文了。

Einstein@Home开发了基于Debian Sarge (3.1)的APPS,使用了来自于woody的gcc-3.0。 -> Einstein@Home项目在Debian Sarge (3.1)上使用Woody的gcc-3.0构建了他们的计算程序。

此处特别注意静态联接到哪个库服务程序,(LIBrary Service),还要注意只在程序运行期间建立起来的一些特性,例如OPENGL. -> 如果你使用了如OpenGL一类的库,请注意哪些库是要静态链接,哪些库需要动态链接。

For a portable build of the BOINC Core Client I found no better way than to make a clean Debian Woody installation (in a VMWare machine) from DVD, refusing all online updates (of the GLIBC). However this was quite some time ago, before BOINC switched to ssl, curl and zlib, I don't know if and how this still works.

如果要构建一份可移植的BOINC核心客户端,我认为最好是用VMWare虚拟机从Debian Woody的DVD进行一次干净的安装,并且不要进行任何在线更新(和GLIBC相关的)。不过这个方法也有段时间了,现在BOINC已经使用了ssl,curl和zlib,我不清楚这个方法是否仍然有效。

Cross-language issues

跨语言的注意事项

The BOINC API is implemented in C++. Information about using it from C and FORTRAN is here.

BOINC的编程接口(API)是用C++语言实现的。如果要在C和Fortran程序中使用它,请看这里。

评分

参与人数 1维基拼图 +18 收起 理由
霊烏路 空 + 18

查看全部评分

回复

使用道具 举报

发表于 2006-5-31 10:08:16 | 显示全部楼层
楼主,方便了大家,您辛苦了,一个建议:
可否把文挡归整以下?按照英文原版的布局,没有翻译的暂时留为英文?因为我也准备着手这方面的事情,希望能看到一个系统的文档,
您也无偿为大家服务,非常感谢,我仅仅是个建议
回复

使用道具 举报

 楼主| 发表于 2006-5-31 10:49:18 | 显示全部楼层
已有的页面请看 http://boinc.equn.com/dev/create_project.html 里的中文条目链接。其他英文页面请查看 BOINC 官方文档。

暂时只能这样,因为最近工作量比较大,怕是没什么时间。
回复

使用道具 举报

发表于 2006-5-31 12:44:32 | 显示全部楼层
arryang准备着手什么?透露一下?:)

引用 arryang 在 2006-5-31 10:08 AM 时的帖子:
楼主,方便了大家,您辛苦了,一个建议:
可否把文挡归整以下?按照英文原版的布局,没有翻译的暂时留为英文?因为我也准备着手这方面的事情,希望能看到一个系统的文档,
您也无偿为大家服务,非常感谢,我仅仅 ...
回复

使用道具 举报

发表于 2006-5-31 12:57:57 | 显示全部楼层

20楼的修改建议

但是我还是把它与example workunit、result files、a
Makefile for Unix and a .dsw for Windows一起打包为hello-boinc (tar压缩)

-> 但是我还是把它和样例任务包、结果文件、用于Unix的Makefile文件以及用于Windows的.dsw文件一起打包为hello-boinc.tar。

1sec程序不会工作。我们最初分心于试图使之能够运行,直到我们发现它不实用API。如何替换1sec应用程序呢?我发现1sec被检验程序大量使用,所以如果它应该保留,也许可以把它放在test目录下。

-> apps目录下的1sec不能运行。我们刚开始也想运行它,直到我们发现它并没有使用任何API。不如用我们的这个程序来替换掉1sec?我还发现1sec主要是在测试程序中被使用,如果要保留我们这个程序,也许可以把它放在test目录下。

评分

参与人数 1维基拼图 +3 收起 理由
霊烏路 空 + 3

查看全部评分

回复

使用道具 举报

发表于 2006-5-31 13:11:57 | 显示全部楼层

21楼的修改建议

Application debugging -> 计算程序的调试

怎样实现这个:将所有导入的文件放入相同的文件夹。(以适当的逻辑形式,不要用物理代号,名字[physical,names])运行计算程序,它会产生出一些文件并导出它们的逻辑名
(logical names),你可以在纠错器的控制下运行计算程序。

-> 方法是:将所有输入文件放在同一个文件夹(用正确的逻辑名而不是物理名),运行计算程序并生成输出文件(同样也是以逻辑名的形式)。你可以在调试软件中运行计算程序。

当程序在独立模式状态运行时,BOINC将会识别然后记录到你的账目中。有一些事情要注意:
如果你的程序可以显示屏保,那么它会打开屏保,屏保如果关闭屏保可能会退出计算程序
请注意boinc_time to checkpoint()它返回的结果总是逻辑假(false),那么你的计算程序将永远没有检查点(checkpoint)

-> 当程序在独立模式运行时,BOINC的API会知道这个情况,有几件事情要注意:
如果你的计算程序可以显示图形,它将打开一个图形窗口,如果关闭这个窗口,计算程序也将退出。
boinc_time_to_checkpoint将总是返回逻辑假,因此你的计算程序将永远不会进行定期存盘。

Using the anonymous platform mechanism -> 使用匿名平台机制

如果计算程序在独立模式运行是你想让它从boinc的客户端运行,这可以测试和客户端合作的各种状况。
想让测试开始,新建一个项目,添加一个应用程序和一些工作,然后运行客户端,它将会下载所有有可能冲突的工作并尝试运行他们。

-> 如果计算程序在独立模式下运行正常,你将会想要从BOINC的客户端中运行它,这样计算程序将与客户端之间产生各种交互。
要进行这样的测试,新建一个项目,添加一个计算程序版本和一些任务包,然后运行客户端,它将下载所有需要的文件并运行你的计算程序,而程序有可能会出错。

//待续...

评分

参与人数 2基本分 +30 维基拼图 +19 收起 理由
BiscuiT + 30 + 15
霊烏路 空 + 4

查看全部评分

回复

使用道具 举报

发表于 2006-6-4 20:17:18 | 显示全部楼层
学习
回复

使用道具 举报

 楼主| 发表于 2006-6-23 10:52:53 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 新注册用户

本版积分规则

论坛官方淘宝店开业啦~

Archiver|手机版|小黑屋|中国分布式计算总站 ( 沪ICP备05042587号 )

GMT+8, 2025-4-22 04:41

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表