Recent changes (master)
The following changes since commit 306fea38fa61c305703d0269b1fc8e7da3b91a1f:
stat: make next log time decision cleaner (2017-04-25 18:14:00 -0600)
are available in the git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to 4bd2c8b9251a2c88f44ad52168252ce2de660bf7:
configure: fix broken test for cuda (2017-04-26 15:24:36 -0600)
----------------------------------------------------------------
Jens Axboe (8):
stat: cleanup iops/bw logging functions
seqlock: add simple user space code for sequence locks Merge branch 'gpudirect' of https://github.com/yufeiren/fio
gpu: ensure that we convert gpu_dev_id options
gpu: kill a lot of useless ifdefs
server: bump protocol version
thread_options: kill two unused pads
configure: fix broken test for cuda
Tomohiro Kusumi (9):
Fix num2str() output when modulo != -1U
Drop the only local variable declaration within a for-loop (C99) Make lib/strntol.c a stand-alone library
Make lib/pattern.c a stand-alone library
Make lib/rand.c a stand-alone library
Make lib/zipf.c a stand-alone library
Make lib/mountcheck.c a stand-alone library
Make oslib/strlcat.c a stand-alone library
Make oslib/linux-dev-lookup.c a stand-alone library
Yufei Ren (1):
GPUDirect RDMA support
HOWTO | 3 + cconv.c | 2 + configure | 24 +++++++- examples/gpudirect-rdmaio-client.fio | 15 +++++ examples/gpudirect-rdmaio-server.fio | 12 ++++ fio.1 | 3 + fio.h | 16 ++++++ init.c | 3 + io_u.c | 5 ++ lib/mountcheck.c | 2 +- lib/num2str.c | 34 ++++++----- lib/pattern.c | 9 ++- lib/rand.c | 2 +- lib/seqlock.h | 48 ++++++++++++++++ lib/strntol.c | 2 +- lib/zipf.c | 1 - memory.c | 76 +++++++++++++++++++++++++ options.c | 18 ++++++ oslib/linux-dev-lookup.c | 3 +- oslib/strlcat.c | 2 +- parse.c | 3 +- server.h | 2 +- stat.c | 107 +++++++++++------------------------ thread_options.h | 7 ++- 24 files changed, 298 insertions(+), 101 deletions(-) create mode 100644 examples/gpudirect-rdmaio-client.fio create mode 100644 examples/gpudirect-rdmaio-server.fio create mode 100644 lib/seqlock.h
---
Diff of recent changes:
HOWTO +3 -0
@@ -1468,6 +1468,9 @@ Buffers and memory **mmapshared** Same as mmap, but use a MMAP_SHARED mapping. + **cudamalloc** + Use GPU memory as the buffers for GPUDirect RDMA benchmark. + The area allocated is a function of the maximum allowed bs size for the job, multiplied by the I/O depth given. Note that for **shmhuge** and **mmaphuge** to work, the system must have free huge pages allocated. This
cconv.c +2 -0
@@ -235,6 +235,7 @@ void convert_thread_options_to_cpu(struct thread_options *o, o->new_group =le32_to_cpu (top->new_group); o->numjobs =le32_to_cpu (top->numjobs); o->cpus_allowed_policy =le32_to_cpu (top->cpus_allowed_policy); + o->gpu_dev_id =le32_to_cpu (top->gpu_dev_id); o->iolog =le32_to_cpu (top->iolog); o->rwmixcycle =le32_to_cpu (top->rwmixcycle); o->nice =le32_to_cpu (top->nice);
@@ -420,6 +421,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->new_group =cpu_to_le32 (o->new_group); top->numjobs =cpu_to_le32 (o->numjobs); top->cpus_allowed_policy =cpu_to_le32 (o->cpus_allowed_policy); + top->gpu_dev_id =cpu_to_le32 (o->gpu_dev_id); top->iolog =cpu_to_le32 (o->iolog); top->rwmixcycle =cpu_to_le32 (o->rwmixcycle); top->nice =cpu_to_le32 (o->nice);
configure +22 -2
@@ -186,6 +186,8 @@ for opt do ;; --disable-pmem) disable_pmem="yes" ;; + --enable-cuda) enable_cuda="yes" + ;; --help) show_help="yes" ;;
@@ -206,7 +208,7 @@ if test "$show_help" = "yes" ; then echo "--esx Configure build options for esx" echo "--enable-gfio Enable building of gtk gfio" echo "--disable-numa Disable libnuma even if found" - echo "--disable-rdma Disable RDMA support even if found" + echo "--disable-rdma Disable RDMA support even if found" echo "--disable-gfapi Disable gfapi" echo "--enable-libhdfs Enable hdfs support" echo "--disable-lex Disable use of lex/yacc for math"
@@ -214,6 +216,7 @@ if test "$show_help" = "yes" ; then echo "--enable-lex Enable use of lex/yacc for math" echo "--disable-shm Disable SHM support" echo "--disable-optimizations Don't enable compiler optimizations" + echo "--enable-cuda Enable GPUDirect RDMA support" exit $exit_val fi
@@ -1990,6 +1993,21 @@ EOF fi echo "march_armv8_a_crc_crypto $march_armv8_a_crc_crypto" +########################################## +# cuda probe +cuda="no" +cat > $TMPC << EOF +#include <cuda.h> +int main(int argc, char **argv) +{ + return cuInit(0); +} +EOF +if test "$enable_cuda" = "yes" && compile_prog "" "-lcuda" "cuda"; then + cuda="yes" + LIBS="-lcuda $LIBS" +fi +echo "cuda $cuda" #############################################################################
@@ -2210,10 +2228,12 @@ fi if test "$disable_opt" = "yes" ; then output_sym "CONFIG_DISABLE_OPTIMIZATIONS" fi - if test "$zlib" = "no" ; then echo "Consider installing zlib-dev (zlib-devel), some fio features depend on it." fi +if test "$cuda" = "yes" ; then + output_sym "CONFIG_CUDA" +fi echo "LIBS+=$LIBS" >> $config_host_mak echo "GFIO_LIBS+=$GFIO_LIBS" >> $config_host_mak
examples/gpudirect-rdmaio-client.fio new file +15 -0
@@ -0,0 +1,15 @@ +# Example gpudirect rdma client job +[global] +ioengine=rdma +hostname=[hostname] +port=[port] +verb=[read/write/send/recv] +mem=cudamalloc +gpu_dev_id=0 +bs=1m +size=100g + +[sender] +rw=write +iodepth=1 +iodepth_batch_complete=1
examples/gpudirect-rdmaio-server.fio new file +12 -0
@@ -0,0 +1,12 @@ +# Example rdma server job +[global] +ioengine=rdma +port=[port] +mem=cudamalloc +gpu_dev_id=0 +bs=1m +size=100g + +[receiver] +rw=read +iodepth=16
fio.1 +3 -0
@@ -1309,6 +1309,9 @@ Same as \fBmmap\fR, but use huge files as backing. .TP .B mmapshared Same as \fBmmap\fR, but use a MMAP_SHARED mapping. +.TP +.B cudamalloc +Use GPU memory as the buffers for GPUDirect RDMA benchmark. The ioengine must be \fBrdma\fR. .RE .P The amount of memory allocated is the maximum allowed \fBblocksize\fR for the
fio.h +16 -0
@@ -59,6 +59,10 @@#define MPOL_LOCAL MPOL_MAX#endif +#ifdef CONFIG_CUDA +#include <cuda.h> +#endif +/* * offset generator types */
@@ -408,6 +412,18 @@ struct thread_data {struct steadystate_data ss;char verror[FIO_VERROR_SIZE ]; + +#ifdef CONFIG_CUDA +/* +* for GPU memory management +*/ +int gpu_dev_cnt; +int gpu_dev_id; +CUdevice cu_dev; +CUcontext cu_ctx; +CUdeviceptr dev_mem_ptr; +#endif + };/*
init.c +3 -0
@@ -1070,6 +1070,9 @@ static void init_flags(struct thread_data *td)if (o->verify_async || o->io_submit_mode ==IO_MODE_OFFLOAD ) td->flags |=TD_F_NEED_LOCK ; + +if (o->mem_type ==MEM_CUDA_MALLOC ) + td->flags &= ~TD_F_SCRAMBLE_BUFFERS ; }static int setup_random_seeds (struct thread_data *td)
io_u.c +5 -0
@@ -1674,8 +1674,10 @@ out:if (!td_io_prep (td, io_u)) {if (!td->o.disable_lat)fio_gettime (&io_u->start_time,NULL ); +if (do_scramble)small_content_scramble (io_u); +return io_u; } err_put:
@@ -2043,6 +2045,9 @@ void fill_io_buffer(struct thread_data *td, void *buf, unsigned int min_write, {struct thread_options *o = &td->o; +if (o->mem_type ==MEM_CUDA_MALLOC ) +return ; +if (o->compress_percentage || o->dedupe_percentage) {unsigned int perc = td->o.compress_percentage;struct frand_state *rs;
lib/mountcheck.c +1 -1
@@ -4,7 +4,7 @@#ifdef CONFIG_GETMNTENT #include <mntent.h> -#include "lib/mountcheck.h" +#include "mountcheck.h" #define MTAB "/etc/mtab"
lib/num2str.c +21 -13
@@ -10,7 +10,7 @@/** * num2str() - Cheesy number->string conversion, complete with carry rounding error. * @num: quantity (e.g., number of blocks, bytes or bits) -* @maxlen: max number of digits in the output string (not counting prefix and units) +* @maxlen: max number of digits in the output string (not counting prefix and units, but counting .) * @base: multiplier for num (e.g., if num represents Ki, use 1024) * @pow2: select unit prefix - 0=power-of-10 decimal SI, nonzero=power-of-2 binary IEC * @units: select units - N2S_* macros defined in num2str.h
@@ -23,9 +23,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)const char **unitprefix;const char *unitstr[] = {"" ,"/s" ,"B" ,"bit" ,"B/s" ,"bit/s" };const unsigned int thousand[] = {1000 ,1024 }; -unsigned int modulo, decimals; +unsigned int modulo;int unit_index =0 , post_index, carry =0 ; -char tmp[32 ]; +char tmp[32 ], fmt[32 ];char *buf;compiletime_assert (sizeof (sistr) ==sizeof (iecstr),"unit prefix arrays must be identical sizes" );
@@ -62,6 +62,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)break ; } +/* +* Divide by K/Ki until string length of num <= maxlen. +*/ modulo =-1U ;while (post_index <sizeof (sistr)) {sprintf (tmp,"%llu" , (unsigned long long ) num);
@@ -74,6 +77,9 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, int units) post_index++; } +/* +* If no modulo, then we're done. +*/ if (modulo ==-1U ) { done:if (post_index >=ARRAY_SIZE (sistr))
@@ -84,23 +90,25 @@ done:return buf; } +/* +* If no room for decimals, then we're done. +*/ sprintf (tmp,"%llu" , (unsigned long long ) num); - decimals = maxlen -strlen (tmp); -if ((int )decimals <=1 ) { +if ((int )(maxlen -strlen (tmp)) <=1 ) {if (carry) num++; goto done; } -do { -sprintf (tmp,"%u" , modulo); -if (strlen (tmp) <= decimals -1 ) -break ; - - modulo = (modulo +9 ) /10 ; - }while (1 ); +/* +* Fill in everything and return the result. +*/ +assert (maxlen -strlen (tmp) -1 >0 ); +assert (modulo < thousand[!!pow2]); +sprintf (fmt,"%%.%df" , (int )(maxlen -strlen (tmp) -1 )); +sprintf (tmp, fmt, (double )modulo / (double )thousand[!!pow2]); -sprintf (buf,"%llu.%u%s%s" , (unsigned long long ) num, modulo, +sprintf (buf,"%llu.%s%s%s" , (unsigned long long ) num, &tmp[2 ], unitprefix[post_index], unitstr[unit_index]);return buf; }
lib/pattern.c +8 -1
@@ -1,6 +1,13 @@ -#include "fio.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <limits.h> +#include <errno.h> +#include <assert.h> +#include "strntol.h" #include "pattern.h" +#include "../minmax.h" #include "../oslib/strcasestr.h" /**
lib/rand.c +1 -1
@@ -36,7 +36,7 @@#include <string.h> #include <assert.h> #include "rand.h" -#include "lib/pattern.h" +#include "pattern.h" #include "../hash.h" int arch_random;
lib/seqlock.h new file +48 -0
48 lines not on this page · raw message
lib/strntol.c +1 -1
@@ -2,7 +2,7 @@#include <stdlib.h> #include <limits.h> -#include "lib/strntol.h" +#include "strntol.h" long strntol (const char *str,size_t sz,char **end,int base) {
lib/zipf.c +0 -1
@@ -6,7 +6,6 @@#include <sys/types.h> #include <fcntl.h> #include "ieee754.h" -#include "../log.h" #include "zipf.h" #include "../minmax.h" #include "../hash.h"
memory.c +76 -0
94 lines not on this page · raw message
options.c +18 -0
@@ -2604,6 +2604,12 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .help = "Like mmap, but use huge pages", },#endif +#ifdef CONFIG_CUDA + { .ival = "cudamalloc", + .oval = MEM_CUDA_MALLOC, + .help = "Allocate GPU device memory for GPUDirect RDMA", + }, +#endif }, }, {
@@ -3563,6 +3569,18 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .help = "Build fio with libnuma-dev(el) to enable this option", },#endif +#ifdef CONFIG_CUDA + { + .name = "gpu_dev_id", + .lname = "GPU device ID", + .type = FIO_OPT_INT, + .off1 = offsetof(struct thread_options, gpu_dev_id), + .help = "Set GPU device ID for GPUDirect RDMA", + .def = "0", + .category = FIO_OPT_C_GENERAL, + .group = FIO_OPT_G_INVALID, + }, +#endif { .name = "end_fsync", .lname = "End fsync",
oslib/linux-dev-lookup.c +1 -2
@@ -5,8 +5,7 @@#include <stdio.h> #include <unistd.h> -#include "../os/os.h" -#include "oslib/linux-dev-lookup.h" +#include "linux-dev-lookup.h" int blktrace_lookup_device (const char *redirect,char *path,unsigned int maj,unsigned int min)
oslib/strlcat.c +1 -1
@@ -1,5 +1,5 @@#include <string.h> -#include "oslib/strlcat.h" +#include "strlcat.h" size_t strlcat (char *dst,const char *src,size_t size) {
parse.c +2 -1
@@ -135,6 +135,7 @@ static unsigned long long get_mult_time(const char *str, int len,const char *p = str;char *c;unsigned long long mult =1 ; +int i;/* * Go forward until we hit a non-digit, or +/- sign
@@ -153,7 +154,7 @@ static unsigned long long get_mult_time(const char *str, int len, } c =strdup (p); -for (int i =0 ; i <strlen (c); i++) +for (i =0 ; i <strlen (c); i++) c[i] =tolower (c[i]);if (!strncmp ("us" , c,2 ) || !strncmp ("usec" , c,4 ))
server.h +1 -1
@@ -49,7 +49,7 @@ struct fio_net_cmd_reply { };enum { -FIO_SERVER_VER =60 , +FIO_SERVER_VER =61 ,FIO_SERVER_MAX_FRAGMENT_PDU =1024 ,FIO_SERVER_MAX_CMD_MB =2048 ,
stat.c +33 -74
155 lines not on this page · raw message
thread_options.h +5 -2
@@ -20,6 +20,7 @@ enum fio_memtype {MEM_MMAP ,/* use anonynomous mmap */ MEM_MMAPHUGE ,/* memory mapped huge file */ MEM_MMAPSHARED ,/* use mmap with shared flag */ + MEM_CUDA_MALLOC,/* use GPU memory */ };#define ERROR_STR_MAX 128
@@ -198,6 +199,8 @@ struct thread_options {unsigned short numa_mem_mode;unsigned int numa_mem_prefer_node;char *numa_memnodes; +unsigned int gpu_dev_id; +unsigned int iolog;unsigned int rwmixcycle;unsigned int rwmix[DDIR_RWDIR_CNT ];
@@ -336,7 +339,6 @@ struct thread_options_pack {uint32_t iodepth_batch;uint32_t iodepth_batch_complete_min;uint32_t iodepth_batch_complete_max; -uint32_t __proper_alignment_for_64b;uint64_t size;uint64_t io_size;
@@ -411,7 +413,6 @@ struct thread_options_pack {uint32_t bs_unaligned;uint32_t fsync_on_close;uint32_t bs_is_seq_rand; -uint32_t pad1;uint32_t random_distribution;uint32_t exitall_error;
@@ -467,6 +468,8 @@ struct thread_options_pack {uint8_t verify_cpumask[FIO_TOP_STR_MAX ];uint8_t log_gz_cpumask[FIO_TOP_STR_MAX ];#endif +uint32_t gpu_dev_id; +uint32_t pad;uint32_t cpus_allowed_policy;uint32_t iolog;uint32_t rwmixcycle;