![]() |
![]() |
|
|
|||||||
| News & Branchengeflüster aktuelle News von Lesern, sowie Tratsch und Insiderinformationen aus der Computerbranche |
![]() |
|
|
Themen-Optionen | Ansicht |
|
|
#1 | |||||
|
Inventar
![]() Registriert seit: 24.01.2001
Beiträge: 5.631
|
Microwulf: Breaking the $100/GFLOP Barrier
Zitat:
Zitat:
Zitat:
Zitat:
Zitat:
|
|||||
|
|
|
|
|
#2 |
|
Inventar
![]() Registriert seit: 24.01.2001
Beiträge: 5.631
|
Microwulf: A Personal, Portable Beowulf Cluster
![]() MPI Homework Project 1: Getting Started With MPI Threads Homework Project 1: Threads in C Code:
/* pi.c - parallel C code to demonstrate Linux thread interface * Original Source: www.tldp.org/HOWTP/Parallel_processing-HOWTO * Since PI == 4 * arctan(1), and arctan(x) is the * integral from 0 to x of (1/(1+x*x), * the for loop below approximates that integration. * Generalized by: Joel Adams * Usage: ./a.out <numIntervals> <numThreads> */ #include <stdio.h> #include <stdlib.h> #include <pthread.h> /* global variables (shared by all threads */ volatile long double pi = 0.0; /* the approximation, to 31 sigfigs */ pthread_mutex_t piLock; /* how we synchronize writes to 'pi' */ long double intervals; /* how finely we chop the integration */ int numThreads; /* how many threads we use */ /* the function a thread executes * Parameters: arg, a void* storing the address of the thread ID. */ void *computePI(void *id) { long double x, width, localSum = 0; int i, threadID = *((int*)id); width = 1.0 / intervals; for(i = threadID ; i < intervals; i += numThreads) { x = (i+0.5) * width; localSum += 4.0 / (1.0 + x*x); } localSum *= width; pthread_mutex_lock(&piLock); pi += localSum; pthread_mutex_unlock(&piLock); return NULL; } int main(int argc, char **argv) { pthread_t *threads; /* dynarray of threads */ void *retval; /* unused; required for join() */ int *threadID; /* dynarray of thread id #s */ int i; /* loop control variable */ if (argc == 3) { intervals = atoi(argv[1]); numThreads = atoi(argv[2]); threads = malloc(numThreads*sizeof(pthread_t)); threadID = malloc(numThreads*sizeof(int)); pthread_mutex_init(&piLock, NULL); for (i = 0; i < numThreads; i++) { threadID[i] = i; pthread_create(&threads[i], NULL, computePI, threadID+i); } for (i = 0; i < numThreads; i++) { pthread_join(threads[i], &retval); } printf("Estimation of pi is %32.30Lf \n", pi); printf("(actual pi value is 3.141592653589793238462643383279...)\n"); } else { printf("Usage: ./a.out <numIntervals> <numThreads>"); } return 0; } |
|
|
|
|
|
#3 |
|
Inventar
![]() Registriert seit: 29.12.2000
Alter: 51
Beiträge: 1.671
|
No servas - da kikakater ist wieder da
![]()
____________________________________
\"Which side are we on? We\'re on the side of the demons, Chief. We are evil men in the gardens of paradise, sent by the forces of death to spread devastation and destruction where ever we go. I\'m surprised you didn\'t know that.\" Colonel Soul Tigh - Battlestar Galactica |
|
|
|
|
|
#4 |
|
Der Unvergleichliche
![]() |
Gibts das bitte auch in deutsch -ich täts auch gerne vestehen-schaut ja beeindruckend aus --aber
![]() |
|
|
|
![]() |
| Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|