我想开始编写应用程序(C++),它将利用额外的内核来执行需要执行大量计算并且其计算彼此独立的代码部分.我有以下处理器:x64系列15型号104步进2正常AMD~1900 Mhz在Windows Vista Home premium 32 bit和Opensuse 11.0 64 bit上运行.
在英特尔平台上,我使用了以下API英特尔TBB,OpenMP.他们是否在AMD上工作,AMD是否有类似的API.您的体验是什么?
我正在寻找一些使用 memcache 设置值的示例 C 代码
我有 5 行代码在 PHP 中运行该应用程序,但在 C 中找不到任何我需要移植到的好的内存缓存示例。
在http://www.erlang.org/doc/tutorial/cnode.html提供的教程中
有以下示例:
/* cnode_s.c */
#include
#include
#include
#include
#include "erl_interface.h"
#include "ei.h"
#define BUFSIZE 1000
int main(int argc, char **argv) {
int port; /* Listen port number */
int listen; /* Listen socket */
int fd; /* fd to Erlang node */
ErlConnect conn; /* Connection data */
int loop = 1; /* Loop flag */
int got; /* Result of receive */
unsigned char buf[BUFSIZE]; /* Buffer for incoming message */
ErlMessage emsg; /* Incoming message …Run Code Online (Sandbox Code Playgroud) 我需要打开防火墙端口,以便可以从一个Erlang节点连接到另一个节点.有标准端口吗?
I am trying to have a function that ensures the table I need is already created and if not to create it. Here's the sample:
ensure_table_exists(Table, MnesiaTables, Nodes) ->
case lists:member(Table, MnesiaTables) of
true ->
throw({error, db_might_have_already_been_created});
false ->
mnesia:create_table(Table, [{disc_copies, Nodes},
{attributes, record_info(fields, Table)}]),
ok
end.
Run Code Online (Sandbox Code Playgroud)
The issue is that when compiling I get the error: illegal record info.
It might have to do that record_info is resolved at compile time or that the second argument to record …
我让使用Erlang的HTTP客户端至某些服务器异步请求http:request(get, {Url, []}, [], [{sync, false}, {stream,
self}]),其中Url是服务器的URL.一切正常,数据是handle_info在调用的进程的gen_server中得到的
http:request/4.但是当连接断开并且stream_end没有得到消息时,我应该收到消息.使用超时对我来说是不可用的,因为服务器可以响应很长时间.
是否有可能获得有关断开连接的消息handle_info?如果没有,请建议何时断开连接?
我试图在C中实现正弦函数,但我得到了奇怪的结果.以下是我用来计算正弦的三个函数:
#define PI 3.14159265358979323846
#define DEPTH 16
double sine(long double);
long double pow(long double, unsigned int);
unsigned int fact(unsigned int);
double sine(long double x) {
long double i_x = x *= PI/180;
int n = 3, d = 0, sign = -1;
// fails past 67 degrees
for (; d < DEPTH; n += 2, d++, sign *= -1) {
x += pow(i_x, n) / fact(n) * sign;
}
return x;
}
long double pow(long double base, unsigned int exp) …Run Code Online (Sandbox Code Playgroud) 尝试为subl命令创建符号链接,以便我可以从终端打开Sublime Test 3中的苍蝇.但是,它找不到/ usr/local/bin目录,即使它在我的路径中也是如此.
$ ln -s /D/ProgramsD/SublimeText3/subl /usr/local/bin/subl
ln: failed to create symbolic link '/usr/local/bin/subl': No such file or directory
Run Code Online (Sandbox Code Playgroud) main为什么我不能在基本 asm 内联中使用局部变量?它只允许在扩展汇编中使用,但为什么会这样呢?
(我知道局部变量在返回地址之后位于堆栈上(因此一旦函数返回就不能使用),但这不应成为不使用它们的原因)
以及基本汇编的示例:
int a = 10; //global a
int b = 20; //global b
int result;
int main() {
asm ( "pusha\n\t"
"movl a, %eax\n\t"
"movl b, %ebx\n\t"
"imull %ebx, %eax\n\t"
"movl %eax, result\n\t"
"popa");
printf("the answer is %d\n", result);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
扩展的例子:
int main (void) {
int data1 = 10; //local var - could be used in extended
int data2 = 20;
int result;
asm ( "imull %%edx, %%ecx\n\t"
"movl %%ecx, %%eax"
: "=a"(result) …Run Code Online (Sandbox Code Playgroud)