如何避免状态D的程序 [英] How to avoid programs in status D
问题描述
我的程序效率低下吗?
或者我的硬盘有问题?
如何处理它?</ p>
如果使用ifort,则必须明确使用缓冲的I / O。标记为 如果你使用的是gfortran,这是默认的,那么肯定还有其他一些问题。 编辑 我可以根据您的读写方式数据,大部分时间都可以解析,即解码ASCII等字符,并将基数从10变为2,直到它是机器可读的数据;写时则相反。如果你这样构造你的代码,就是这种情况: 如果您改为执行以下操作,速度会更快: 现在,您只需在程序中抽取ascii,而不必知道其数字或ääåö (=)& %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%注意,大多数驱动器中都有一个写入缓存,它比磁盘的读写速度快,这意味着你可能首先受到读取速度的限制,并且在填充写入缓存之后,被写速度,通常低于读取速度。 I wrote a program that are reading/writing data (open one infile and one outfile, read part of infile, then process, then write to outfile, and that cycle repeats), with I/O value about 200M/s in total. However, most of the running time, they are in status D, which means waiting for I/O (As shown in the figure)1. I used Are my programs inefficient?
Or my harddisk have problems?
How can I deal with it? If using ifort, you must explicitly use buffered I/O. Flag with If you are using gfortran this is the default, so then there must be some other problem. Edit I can add that depending on how you read and write the data, most time can be spent parsing it, i.e. decoding ascii characters 123 etc and changing the basis from 10 to 2 until it is machine readable data; then doing the opposite when writing. This is the case if you construct your code like this: If you instead do the following, it will be much faster: Now you are just pumping ascii through the program without even knowing if its digits or maybe "ääåö(=)&/&%/(¤%/&Rhgksbks---31". With these modifications I think you should reach the max of your disk speed. Notice also that there is a write cache in most drives, which is faster than the disk read/write speeds, meaning that you might first be throttled by the read speed, and after filling up the write cache, be throttled by the write speed, which is usually lower than the read speed. 这篇关于如何避免状态D的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! -assume buffered_io
编译或设置 buffered ='yes'在
中打开
语句。
real :: vector1(10)
read(5,*)vector1!line有10个值
write(6,*)vector1
enddo
字符(1000):: line1! (5,'(A)')line1
write(6,'(A)')line1 $ b $使用足够的字符,所以整行符合
read b enddo
dd
check write speed in my system, that is about 1.8G/s. -assume buffered_io
when compiling or set buffered='yes'
in the open
statement.real :: vector1(10)
do
read(5,*) vector1 !line has 10 values
write(6,*) vector1
enddo
character(1000) :: line1 ! use enough characters so the whole line fits
do
read(5,'(A)') line1
write(6,'(A)') line1
enddo