syzygy wrote:bob wrote:syzygy wrote:bob wrote:I'd bet performance IS important for MOST of us in computer chess.
In so far as it was a factor in Lucas' question, the answer is that the use of volatiles in Senpai only slows down the engine. (I've tested and #define'ing volatile away gave a very slight speedup, just 0.5%.)
Hence my comment.
The one where you argued that the compiler won't reload non-volatiles after a pthread_mutex_lock()? Right...
Correct. If you include the pthread_mutex_lock source into the compiled program, it will optimize right across it, because it can see all the side effects (or the lack thereof). And it is not JUST pthread_mutex_lock() where this is a problem.
Yes, if you want to mess things up you can always mess things up.
You claim the compiler has specific knowledge about that procedure.
I never claimed that. I claimed: POSIX guarantees that it works. And indeed, it works.
That it works because posix_mutex_lock() is a function call to code that the compiler knows nothing about is irrelevant. That is merely how the standard is implemented. Users of a POSIX compliant system do not have to look under the hood of the system but can simply rely on the standard.
Again, to appreciate this requires an ability of abstraction that some are sorely lacking. This is the strcpy() story all over again.
Just factual. Want me to show you the volatile ints in the kernel source for spin locks?
Sure.
Maybe you can also explain why the kernel does not use volatile for shared variables? How come it does not need to do that to force reloading from memory etc.?
I specifically mentioned spin locks. As far as the kernel, why don't you log on to a linux box, cd to /usr/src/kernels/-whatever-, and start recursively using grep to search for volatile?
A sample from 3.13.6 on fedora 20:
include/linux/pagemap.h: volatile char c;
include/linux/pagemap.h: volatile char c;
include/linux/parport.h: volatile long int timeout;
include/linux/parport.h: volatile enum ieee1284_phase phase;
include/linux/spinlock_types_up.h: volatile unsigned int slick;
include/net/ip_vs.h: volatile __u32 flags; /* status flags */
include/net/ip_vs.h: volatile unsigned long timeout; /* timeout */
include/net/ip_vs.h: volatile __u16 state; /* state info */
include/net/ip_vs.h: volatile __u16 old_state; /* old state, to be used for
include/net/ip_vs.h: volatile unsigned int flags; /* dest status flags */
include/net/ip_vs.h: volatile int sync_state;
include/net/ip_vs.h: volatile int master_syncid;
include/net/ip_vs.h: volatile int backup_syncid;
include/net/sock.h: volatile unsigned char skc_state;
include/scsi/scsi_cmnd.h: volatile int Status;
include/scsi/scsi_cmnd.h: volatile int Message;
include/scsi/scsi_cmnd.h: volatile int have_data_in;
include/scsi/scsi_cmnd.h: volatile int sent_command;
include/scsi/scsi_cmnd.h: volatile int phase;
include/video/gbe.h: volatile uint32_t ctrlstat; /* general control */
include/video/gbe.h: volatile uint32_t dotclock; /* dot clock PLL control */
include/video/gbe.h: volatile uint32_t i2c; /* crt I2C control */
include/video/gbe.h: volatile uint32_t sysclk; /* system clock PLL control */
include/video/gbe.h: volatile uint32_t i2cfp; /* flat panel I2C control */
include/video/gbe.h: volatile uint32_t id; /* device id/chip revision */
include/video/gbe.h: volatile uint32_t config; /* power on configuration [1] */
include/video/gbe.h: volatile uint32_t bist; /* internal bist status [1] */
include/video/gbe.h: volatile uint32_t vt_xy; /* current dot coords */
include/video/gbe.h: volatile uint32_t vt_xymax; /* maximum dot coords */
include/video/gbe.h: volatile uint32_t vt_vsync; /* vsync on/off */
include/video/gbe.h: volatile uint32_t vt_hsync; /* hsync on/off */
include/video/gbe.h: volatile uint32_t vt_vblank; /* vblank on/off */
include/video/gbe.h: volatile uint32_t vt_hblank; /* hblank on/off */
include/video/gbe.h: volatile uint32_t vt_flags; /* polarity of vt signal
include/video/gbe.h: volatile uint32_t vt_intr01; /* intr 0,1 y coords */
include/video/gbe.h: volatile uint32_t vt_intr23; /* intr 2,3 y coords */
include/video/gbe.h: volatile uint32_t fp_hdrv; /* flat panel hdrv on/off */
include/video/gbe.h: volatile uint32_t fp_vdrv; /* flat panel vdrv on/off */
include/video/gbe.h: volatile uint32_t fp_de; /* flat panel de on/off */
include/video/gbe.h: volatile uint32_t vt_hpixen; /* intrnl horiz pixel on/off */
include/video/gbe.h: volatile uint32_t vt_vpixen; /* intrnl vert pixel on/off */
include/video/gbe.h: volatile uint32_t vt_hcmap; /* cmap write (horiz) */
include/video/gbe.h: volatile uint32_t vt_vcmap; /* cmap write (vert) */
include/video/gbe.h: volatile uint32_t did_start_xy; /* eol/f did/xy reset val */
include/video/gbe.h: volatile uint32_t crs_start_xy; /* eol/f crs/xy reset val */
include/video/gbe.h: volatile uint32_t vc_start_xy; /* eol/f vc/xy reset val */
include/video/gbe.h: volatile uint32_t ovr_width_tile;/*overlay plane ctrl 0 */
include/video/gbe.h: volatile uint32_t ovr_inhwctrl; /* overlay plane ctrl 1 */
include/video/gbe.h: volatile uint32_t ovr_control; /* overlay plane ctrl 1 */
include/video/gbe.h: volatile uint32_t frm_size_tile;/* normal plane ctrl 0 */
include/video/gbe.h: volatile uint32_t frm_size_pixel;/*normal plane ctrl 1 *
include/asm-generic/io.h:static inline unsigned long virt_to_phys(volatile void *address)
include/asm-generic/io.h:static inline unsigned long virt_to_bus(volatile void *address)
include/drm/drmP.h: __volatile__ int waiting; /**< On kernel DMA queue */
include/drm/drmP.h: __volatile__ int pending; /**< On hardware DMA queue */
That's just a few, selectively picked out because the lines were short.
No volatiles? I found almost a thousand with a quick search. I didn't check 10 levels deep either...
Other questions?