/** * \brief Measures the time to read once from a file. * * Only one process is active. It reads once from a file. * * Remark:<br> * With the <tt>O_DIRECT</tt> flag set, cache effects are minimized, because I/O * is done directly to/from user space buffers. The operation system's page * cache is bypassed. Under Linux 2.6 alignment to 512-byte boundaries is * required for buffer and file offset. Thus the following parameters should be * set in a SKaMPI input file: * - <tt>set_send_buffert_alignment (512)</tt> * - <tt>set_recv_buffert_alignment (512)</tt> * - <tt>switch_buffer_cycling_off ()</tt><br> * * <tt>O_DIRECT</tt> is only relevant if the POSIX-API is used for I/O. * * For more information please refer to the <tt>open ()</tt> man pages. * * \param[in] size size of memory buffer, i.e. number of <tt>MPI_BYTE</tt>s * \param[in] api POSIX-API or MPI-API for I/O accesses * \param[in] directio_flag open file with <tt>O_DIRECT</tt> flag to minimize * cache effects * * \return measured time */ double measure_MPI_IO_read_file_once (int size, char *api, int directio_flag){ double start_time = 1.0, end_time = 0.0; int open_flags; char *error_string; if (get_measurement_rank () == 0){ if (strcmp (api, POSIX_API) == 0){ if (directio_flag != 0) open_flags = O_RDONLY | O_DIRECT; else open_flags = O_RDONLY; printf ("flags %d,%d\n", open_flags, O_DIRECT); errno = 0; if ((io_fd = open (io_filename, open_flags)) < 0){ error_string = strerror (errno); error_with_abort (errno, "\nmeasure_MPI_IO_read_file_once (int %d, char * %s, int %d) failed." "\nCannot open local file (read only mode)." "\nError: %s\n", size, api, directio_flag, error_string); } start_time = start_synchronization (); read (io_fd, get_recv_buffer (), size); end_time = MPI_Wtime (); close (io_fd); } else{ MPI_File_open (MPI_COMM_SELF, io_filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &io_fh); MPI_File_set_view (io_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL); start_time = start_synchronization (); MPI_File_read (io_fh, get_recv_buffer (), size, MPI_BYTE, MPI_STATUS_IGNORE); end_time = stop_synchronization (); MPI_File_close (&io_fh); } } else if (get_measurement_rank () != 0) { start_synchronization (); } stop_synchronization (); if (get_measurement_rank () == 0) return end_time - start_time; else return -1.0; }
/** * \brief Measures the time to read once from a large file. * * Only one process is active. It writes once to a file. * * Since SKaMPI measurement functions are not allowed to use MPI_Offset * parameters, it is impossible to tell an init_-routine to create a file * which is larger than \f$2^{\mbox{\texttt{sizeof(int)}}-1}-1\f$ directly. As * a preliminary solution we use a parameter (<tt>power</tt>) which commits the * power to 2 as an indicator for the file size. * * Remark concerning the <em>HP XC6000</em>:<br> * Measurements showed that there is no significant difference between MPI-API * and POSIX-API I/O accesses, if files are larger than 1MB. Thus there is no * choice between these two modes like in measure_MPI_IO_read_file_once(), * which makes type compatibilty problems much easier. Only MPI-API is * supported. * * \param[in] power size of memory buffer; 2 to the power of `power' <tt>MPI_BYTE</tt>s * * \return measured time */ double measure_MPI_IO_read_large_file_once (int power){ MPI_Offset size; double start_time = 1.0, end_time = 0.0; if (get_measurement_rank () == 0){ size = ((MPI_Offset) 1) << power; MPI_File_open (MPI_COMM_SELF, io_filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &io_fh); MPI_File_set_view (io_fh, (MPI_Offset)0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL); start_time = start_synchronization (); MPI_File_read (io_fh, get_recv_buffer (), size, MPI_BYTE, MPI_STATUS_IGNORE); end_time = stop_synchronization (); MPI_File_close (&io_fh); } else if (get_measurement_rank () != 0) { start_synchronization (); } stop_synchronization (); if (get_measurement_rank () == 0) return end_time - start_time; else return -1.0; }
double measure_delayed_Alltoall(int send_count, MPI_Datatype send_dt, int recv_count, MPI_Datatype recv_dt, double delay, int node) { double start_time, end_time; start_time = start_synchronization(); if( get_measurement_rank() == node ) while( wtime() < start_time + delay ) ; MPI_Alltoall(get_send_buffer(), send_count, send_dt, get_recv_buffer(), recv_count, recv_dt, get_measurement_comm()); end_time = stop_synchronization(); return end_time - start_time; }
int dart_recv(void *ctx, unsigned char *buf, size_t len) { char *recv_buffer = get_recv_buffer(ctx); int read = buffer_read(recv_buffer, buf, len, MBEDTLS_ERR_SSL_WANT_READ); return read; }