fuck it we ball
This commit is contained in:
parent
530df5a387
commit
a95776ac11
6 changed files with 293504 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build
|
22
CMakeLists.txt
Normal file
22
CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
project(
|
||||
ift630_sts3
|
||||
VERSION 0.1.0
|
||||
DESCRIPTION "bs project to learn openMPI / openMP"
|
||||
LANGUAGES C
|
||||
)
|
||||
|
||||
set(src
|
||||
src/main.c
|
||||
)
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX d)
|
||||
add_executable(ift630_sts3 ${src})
|
||||
|
||||
find_package(MPI) #make it REQUIRED, if you want
|
||||
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
|
||||
target_link_libraries(ift630_sts3 ${MPI_C_LIBRARIES})
|
||||
|
||||
set_target_properties(ift630_sts3 PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
target_compile_features(ift630_sts3 PRIVATE c_std_99)
|
BIN
src/ift630_sts3
Executable file
BIN
src/ift630_sts3
Executable file
Binary file not shown.
BIN
src/ift630_sts3d
Executable file
BIN
src/ift630_sts3d
Executable file
Binary file not shown.
59
src/main.c
Normal file
59
src/main.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
"Hello World" MPI Test Program
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mpi.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Initialize the MPI environment
|
||||
MPI_Init(NULL, NULL);
|
||||
|
||||
int world_size, world_rank;
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
|
||||
|
||||
// Get the name of the processor
|
||||
char processor_name[MPI_MAX_PROCESSOR_NAME];
|
||||
int name_len;
|
||||
MPI_Get_processor_name(processor_name, &name_len);
|
||||
|
||||
// Print off a hello world message
|
||||
printf("Hello world from processor %s, rank %d out of %d processors\n",
|
||||
processor_name, world_rank, world_size);
|
||||
|
||||
|
||||
|
||||
// We are assuming at least 2 processes for this task
|
||||
if (world_size < 2) {
|
||||
fprintf(stderr, "World size must be greater than 1 for %s\n", argv[0]);
|
||||
MPI_Abort(MPI_COMM_WORLD, 1);
|
||||
}
|
||||
int number;
|
||||
if (world_rank == 0) {
|
||||
// If we are rank 0, set the number to -1 and send it to process 1
|
||||
number = -1;
|
||||
MPI_Send(
|
||||
/* data = */ &number,
|
||||
/* count = */ 1,
|
||||
/* datatype = */ MPI_INT,
|
||||
/* destination = */ 1,
|
||||
/* tag = */ 0,
|
||||
/* communicator = */ MPI_COMM_WORLD);
|
||||
} else if (world_rank == 1) {
|
||||
MPI_Recv(
|
||||
/* data = */ &number,
|
||||
/* count = */ 1,
|
||||
/* datatype = */ MPI_INT,
|
||||
/* source = */ 0,
|
||||
/* tag = */ 0,
|
||||
/* communicator = */ MPI_COMM_WORLD,
|
||||
/* status = */ MPI_STATUS_IGNORE);
|
||||
printf("Process 1 received number %d from process 0\n", number);
|
||||
}
|
||||
|
||||
// Finalize the MPI environment.
|
||||
MPI_Finalize();
|
||||
}
|
||||
|
293422
stop_times.txt
Normal file
293422
stop_times.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue