Skip to content

Commit

Permalink
add test for mpi_max_ in fortran
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-juilly committed Jan 19, 2024
1 parent ccddc41 commit eea34b6
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Testing/mpi_max/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,33 @@ file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/info.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/fileview.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_mpi_max_f_tests.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/main.f90
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/info.f90
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/fileview.f90
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_test (NAME mpi_max_simple COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_mpi_max_tests.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test (NAME mpi_max_simple_fortran COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_mpi_max_f_tests.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if (WI4MPI_BATCH_SCHEDULER MATCHES "mpirun")
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_mpi_max_port_tests.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/port-client.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/port-server.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_mpi_max_port_f_tests.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/port-client.f90
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/port-server.f90
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
add_test (NAME mpi_max_port COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_mpi_max_port_tests.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_test (NAME mpi_max_port_fortran COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_mpi_max_port_f_tests.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
21 changes: 21 additions & 0 deletions Testing/mpi_max/fileview.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
program fileview
use mpi
implicit none
integer :: ierr
integer :: testfile;
integer(kind=mpi_offset_kind) :: disp
integer :: etype, ftype
character(len=MPI_MAX_DATAREP_STRING) :: datarep;

call MPI_Init(ierr);

call MPI_File_open(MPI_COMM_WORLD, "test", ior(MPI_MODE_RDWR,MPI_MODE_CREATE), MPI_INFO_NULL, testfile, ierr);
call MPI_File_get_view(testfile, disp, etype, ftype, datarep, ierr);
write(*,*) "get view ", trim(datarep);
call MPI_File_set_view(testfile, disp, etype, ftype, "external32", MPI_INFO_NULL, ierr);
call MPI_File_get_view(testfile, disp, etype, ftype, datarep, ierr);
write(*,*) "get view ", trim(datarep);
call MPI_File_close(testfile, ierr);

call MPI_Finalize(ierr);
end
22 changes: 22 additions & 0 deletions Testing/mpi_max/info.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
program infokey
use mpi
implicit none
integer :: ierr
integer :: info
character(len=249) :: val
character(len=MPI_MAX_INFO_KEY) :: key
integer :: vallen
logical :: flag

call MPI_Init(ierr);
call MPI_Info_create(info, ierr);
call MPI_Info_set(info, " mama ", " mia ", ierr);
call MPI_Info_get_nthkey(info, 0, key, ierr);
write(*,*) "get nth: ", trim(key)
call MPI_Info_get_valuelen(info, " mama ", vallen, flag, ierr);
write(*,*) "get valuelen: ", vallen
call MPI_Info_get(info, " mama ", 249, val, flag, ierr);
write(*,*) "get: ", trim(val)
call MPI_Info_delete(info, " mama ", ierr);
call MPI_Finalize(ierr);
end
56 changes: 56 additions & 0 deletions Testing/mpi_max/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
program main_calls
use mpi
implicit none
integer :: ierr, leng, errcode
integer :: testerrclass, testerrcode
integer :: testcomm
integer :: testtype
integer :: mywin
integer(kind=mpi_address_kind) :: ssize
character(len=MPI_MAX_PROCESSOR_NAME) :: proc_name
character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: lib_ver
character(len=MPI_MAX_ERROR_STRING) :: error_string
character(len=MPI_MAX_OBJECT_NAME) :: comm_string
character(len=MPI_MAX_OBJECT_NAME) :: type_string
character(len=MPI_MAX_OBJECT_NAME) :: win_string

call MPI_Init(ierr)

errcode = MPI_ERR_NAME;


call MPI_Get_processor_name(proc_name, leng, ierr);
write(*,*) "procname: ", leng, trim(proc_name)
call MPI_Get_library_version(lib_ver, leng, ierr);
write(*,*) "libver: ", leng, trim(lib_ver)

call MPI_Error_string(errcode, error_string, leng, ierr);
write(*,*) "error: ", errcode, leng, trim(error_string)
call MPI_Add_error_class(testerrclass, ierr);
call MPI_Add_error_code(testerrclass, testerrcode, ierr);
call MPI_Add_error_string(testerrcode, "mouhaha", ierr);
call MPI_Error_string(testerrcode, error_string, leng, ierr);
write(*,*) "custom error: ", leng, trim(error_string)

call MPI_Comm_dup(MPI_COMM_WORLD, testcomm, ierr);
call MPI_Comm_set_name(testcomm, "my comm", ierr);
call MPI_Comm_get_name(testcomm, comm_string, leng, ierr);
write(*,*) "comm name: ", leng, trim(comm_string)
call MPI_Comm_free(testcomm, ierr);

call MPI_Type_contiguous(3, MPI_INTEGER, testtype, ierr);
call MPI_Type_commit(testtype, ierr);
call MPI_Type_set_name(testtype, "3 integer", ierr);
call MPI_Type_get_name(testtype, type_string, leng, ierr);
write(*,*) "type name: ", leng, trim(type_string)
call MPI_Type_free(testtype, ierr);

ssize = 3
call MPI_Win_create(lib_ver, ssize, 1, MPI_INFO_NULL, MPI_COMM_WORLD, mywin, ierr);
call MPI_Win_set_name(mywin, "test window", ierr);
call MPI_Win_get_name(mywin, win_string, leng, ierr);
write(*,*) "win name: ", leng, trim(win_string)
call MPI_Win_free(mywin, ierr);

call MPI_Finalize(ierr);
end
19 changes: 19 additions & 0 deletions Testing/mpi_max/port-client.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
program port_client
use mpi
implicit none
integer, parameter :: MAX_DATA = 1
integer :: server
double precision:: buf(MAX_DATA)
integer :: ierr
character(len=MPI_MAX_PORT_NAME) :: port_name

buf(1) = 3.14
call MPI_Init(ierr);
write(*,*) "starting client"
call MPI_Barrier(MPI_COMM_WORLD, ierr);
call MPI_Lookup_name("wii", MPI_INFO_NULL, port_name, ierr);
call MPI_Comm_connect(port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF, server, ierr);
call MPI_Send(buf, 1, MPI_DOUBLE_PRECISION, 0, 1, server, ierr);
call MPI_Comm_disconnect(server, ierr);
call MPI_Finalize(ierr);
end
23 changes: 23 additions & 0 deletions Testing/mpi_max/port-server.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
program port_server
use mpi
implicit none
integer, parameter :: MAX_DATA = 1
integer :: client
double precision:: buf(MAX_DATA)
integer :: ierr
character(len=MPI_MAX_PORT_NAME) :: port_name
integer :: statuss(mpi_status_size);

call MPI_Init(ierr);
call MPI_Open_port(MPI_INFO_NULL, port_name, ierr);
write(*,*) "server available at ", trim(port_name)
call MPI_Publish_name("wii", MPI_INFO_NULL, port_name, ierr);
call MPI_Barrier(MPI_COMM_WORLD, ierr);
call MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF, client, ierr);
call MPI_Recv(buf, MAX_DATA, MPI_DOUBLE_PRECISION, MPI_ANY_SOURCE, MPI_ANY_TAG, client, statuss, ierr);
write(*,*) "server received ", buf(1)
call MPI_Comm_disconnect(client, ierr);
call MPI_Unpublish_name("wii", MPI_INFO_NULL, port_name, ierr);
call MPI_Close_port(port_name, ierr);
call MPI_Finalize(ierr);
end
11 changes: 11 additions & 0 deletions Testing/mpi_max/run_mpi_max_f_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

source ../etc/mpivars.sh || exit 1


${WI4MPI_ROOT}/bin/mpif90 main.f90 -o main_max_f
${WI4MPI_ROOT}/bin/mpif90 info.f90 -o info_max_f
${WI4MPI_ROOT}/bin/mpif90 fileview.f90 -o fileview_max_f
${WI4MPI_MPRUN} -n 1 ${WI4MPI_NCORE} ${WI4MPI_PARTITION} ${WI4MPI_EXTRA_OPTS} ./main_max_f
${WI4MPI_MPRUN} -n 1 ${WI4MPI_NCORE} ${WI4MPI_PARTITION} ${WI4MPI_EXTRA_OPTS} ./info_max_f
${WI4MPI_MPRUN} -n 1 ${WI4MPI_NCORE} ${WI4MPI_PARTITION} ${WI4MPI_EXTRA_OPTS} ./fileview_max_f
8 changes: 8 additions & 0 deletions Testing/mpi_max/run_mpi_max_port_f_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

source ../etc/mpivars.sh || exit 1


${WI4MPI_ROOT}/bin/mpif90 port-client.f90 -o client_f
${WI4MPI_ROOT}/bin/mpif90 port-server.f90 -o server_f
${TESTMPI_ROOT}/bin/mpirun -n 1 wi4mpi -t openmpi ./server_f : -n 1 wi4mpi -t openmpi ./client_f

0 comments on commit eea34b6

Please sign in to comment.