ppc_altivec_util.h

来自「最著名最快的分子模拟软件」· C头文件 代码 · 共 1,756 行 · 第 1/5 页

H
1,756
字号
	c2c                 = vec_ld( 16, address3 ); 	c3c                 = vec_ld( 32, address3 ); 	if(((unsigned int)address3) & 0xf) { 		/*  Load extra data and rotate if not aligned */		tmp4              = vec_ld( 48, address3 );		perm              = vec_lvsl( 0, address3 ); 		c1c               = vec_perm(c1c,c2c,perm);     /*  Oxc  Oyc  Ozc H1xc */		c2c               = vec_perm(c2c,c3c,perm);     /* H1yc H1zc H2xc H2yc */		c3c               = vec_perm(c3c,tmp4,perm);    /* H2zc  Mxc  Myc  Mzc */	}	c1d                 = vec_ld(  0, address4 ); 	c2d                 = vec_ld( 16, address4 ); 	c3d                 = vec_ld( 32, address4 ); 	if(((unsigned int)address4) & 0xf) { 		/*  Load extra data and rotate if not aligned */		tmp4              = vec_ld( 48, address4 );		perm              = vec_lvsl( 0, address4 ); 		c1d               = vec_perm(c1d,c2d,perm);      /*  Oxd  Oyd  Ozd H1xd */		c2d               = vec_perm(c2d,c3d,perm);      /* H1yd H1zd H2xd H2yd */		c3d               = vec_perm(c3d,tmp4,perm);     /* H2zd  Mxd  Myd  Mzd */	}	/* permute things */	tmp1              = vec_mergeh(c1a,c1c);          /*  Oxa  Oxc  Oya  Oyc */	c1a               = vec_mergel(c1a,c1c);          /*  Oza  Ozc H1xa H1xc */	c1c               = vec_mergeh(c1b,c1d);          /*  Oxb  Oxd  Oyb  Oyd */	c1b               = vec_mergel(c1b,c1d);          /*  Ozb  Ozd H1xb H1xd */	c1d               = vec_mergeh(c2a,c2c);          /* H1ya H1yc H1za H1zc */	c2a               = vec_mergel(c2a,c2c);          /* H2xa H2xc H2ya H2yc */	c2c               = vec_mergeh(c2b,c2d);          /* H1yb H1yd H1zb H1zd */	c2b               = vec_mergel(c2b,c2d);          /* H2xb H2xd H2yb H2yd */	tmp2              = vec_mergeh(c3a,c3c);          /* H2za H2zc  Mxa  Mxc */	c3a               = vec_mergel(c3a,c3c);          /*  Mya  Myc  Mza  Mzc */	c3c               = vec_mergeh(c3b,c3d);          /* H2zb H2zd  Mxb  Mxd */	c3b               = vec_mergel(c3b,c3d);          /*  Myb  Myd  Mzb  Mzd */  	*Ox               = vec_mergeh(tmp1,c1c);         /*  Oxa  Oxb  Oxc  Oxd */	*Oy               = vec_mergel(tmp1,c1c);         /*  Oya  Oyb  Oyc  Oyd */	*Oz               = vec_mergeh(c1a,c1b);          /*  Oza  Ozb  Ozc  Ozd */	*H1x              = vec_mergel(c1a,c1b);          /* H1xa H1xb H1xc H1xd */	*H1y              = vec_mergeh(c1d,c2c);          /* H1ya H1yb H1yc H1yd */	*H1z              = vec_mergel(c1d,c2c);          /* H1za H1zb H1zc H1zd */	*H2x              = vec_mergeh(c2a,c2b);          /* H2xa H2xb H2xc H2xd */	*H2y              = vec_mergel(c2a,c2b);          /* H2ya H2yb H2yc H2yd */	*H2z              = vec_mergeh(tmp2,c3c);          /* H2za H2zb H2zc H2zd */	*Mx               = vec_mergel(tmp2,c3c);          /*  Mxa  Mxb  Mxc  Mxd */	*My               = vec_mergeh(c3a,c3b);           /*  Mya  Myb  Myc  Myd */	*Mz               = vec_mergel(c3a,c3b);           /*  Mza  Mzb  Mzc  Mzd */}/** Load coords of 3 3-atom waters (3*9 floats) to SIMD vectors.** We use our knowledge about water to improve the loading performance.* The allocated memory is always 8-byte aligned, so with nine atoms* we can always read 3 16-byte chunks (rounded down by vec_ld)* without going outside the current page (which might incur a page fault). * The extra elements before and after the water dont matter as long as we dont* try to write to them.** @param address1   Address of first coord in first water (oxygen x).* @param address2   Address of first coord in second water (oxygen x).* @param address3   Address of first coord in third water (oxygen x).* @param Ox         Output: Oxygen x coordinates.* @param Oy         Output: Oxygen y coordinates.* @param Oz         Output: Oxygen z coordinates.* @param H1x        Output: First hydrogen x coordinates.* @param H1y        Output: First hydrogen y coordinates.* @param H1z        Output: First hydrogen z coordinates.* @param H2x        Output: Second hydrogen x coordinates.* @param H2y        Output: Second hydrogen y coordinates.* @param H2z        Output: Second hydrogen z coordinates.*/static inline void load_3_3atoms(float *address1,              float *address2,              float *address3,              vector float *Ox,              vector float *Oy,              vector float *Oz,              vector float *H1x,              vector float *H1y,              vector float *H1z,              vector float *H2x,              vector float *H2y,              vector float *H2z){	vector unsigned char perm;	vector float tmp1,tmp2,tmp3;	vector float c1a,c2a,c3a;	vector float c1b,c2b,c3b;	vector float c1c,c2c,c3c;  	/* load the coordinates */	perm              = vec_lvsl( 0, (int *) address1 ); 	tmp1              = vec_ld(  0, address1 ); 	tmp2              = vec_ld( 16, address1 ); 	tmp3              = vec_ld( 32, address1 ); 	c1a               = vec_perm(tmp1,tmp2,perm);     /*  Oxa  Oya  Oza H1xa */	c2a               = vec_perm(tmp2,tmp3,perm);     /* H1ya H1za H2xa H2ya */	c3a               = vec_perm(tmp3,tmp3,perm);     /* H2za   -   -   - */	perm              = vec_lvsl( 0, (int *) address3 ); 	tmp1              = vec_ld(  0, address3 ); 	tmp2              = vec_ld( 16, address3 ); 	tmp3              = vec_ld( 32, address3 ); 	c1c               = vec_perm(tmp1,tmp2,perm);     /*  Oxc  Oyc  Ozc H1xc */	c2c               = vec_perm(tmp2,tmp3,perm);     /* H1yc H1zc H2xc H2yc */	c3c               = vec_perm(tmp3,tmp3,perm);     /* H2zc   -   -   - */	perm              = vec_lvsl( 0, (int *) address2 ); 	tmp1              = vec_ld(  0, address2 ); 	tmp2              = vec_ld( 16, address2 ); 	tmp3              = vec_ld( 32, address2 );  	c1b               = vec_perm(tmp1,tmp2,perm);     /*  Oxb  Oyb  Ozb H1xb */	c2b               = vec_perm(tmp2,tmp3,perm);     /* H1yb H1zb H2xb H2yb */	c3b               = vec_perm(tmp3,tmp3,perm);     /* H2zb   -   -   - */	/* permute things */	tmp1              = vec_mergeh(c1a,c1c);          /*  Oxa  Oxc  Oya  Oyc */	c1a               = vec_mergel(c1a,c1c);          /*  Oza  Ozc H1xa H1xc */	c1c               = vec_mergeh(c1b,c1b);          /*  Oxb   -   Oyb   -  */	c1b               = vec_mergel(c1b,c1b);          /*  Ozb   -  H1xb   -  */	tmp2              = vec_mergeh(c2a,c2c);          /* H1ya H1yc H1za H1zc */	c2a               = vec_mergel(c2a,c2c);          /* H2xa H2xc H2ya H2yc */	c2c               = vec_mergeh(c2b,c2b);          /* H1yb   -  H1zb   -  */	c2b               = vec_mergel(c2b,c2b);          /* H2xb   -  H2yb   -  */	c3a               = vec_mergeh(c3a,c3c);          /* H2za H2zc   -    -  */  	*Ox               = vec_mergeh(tmp1,c1c);         /*  Oxa  Oxb  Oxc   -  */	*Oy               = vec_mergel(tmp1,c1c);         /*  Oya  Oyb  Oyc   -  */	*Oz               = vec_mergeh(c1a,c1b);          /*  Oza  Ozb  Ozc   -  */	*H1x              = vec_mergel(c1a,c1b);          /* H1xa H1xb H1xc   -  */	*H1y              = vec_mergeh(tmp2,c2c);         /* H1ya H1yb H1yc   -  */	*H1z              = vec_mergel(tmp2,c2c);         /* H1za H1zb H1zc   -  */	*H2x              = vec_mergeh(c2a,c2b);          /* H2xa H2xb H2xc   -  */	*H2y              = vec_mergel(c2a,c2b);          /* H2ya H2yb H2yc   -  */	*H2z              = vec_mergeh(c3a,c3b);          /* H2za H2zb H2zc   -  */}/** Load coords of 3 4-atom waters (3*12 floats) to SIMD vectors.** We use our knowledge about water to improve the loading performance.* The allocated memory is always 8-byte aligned, so with 12 atoms* we can always read 4 16-byte chunks (rounded down by vec_ld)* without going outside the current page (which might incur a page fault). * The extra elements before and after the water dont matter as long as we dont* try to write to them.** @param address1   Address of first coord in first water (oxygen x).* @param address2   Address of first coord in second water (oxygen x).* @param address3   Address of first coord in third water (oxygen x).* @param Ox         Output: Oxygen x coordinates.* @param Oy         Output: Oxygen y coordinates.* @param Oz         Output: Oxygen z coordinates.* @param H1x        Output: First hydrogen x coordinates.* @param H1y        Output: First hydrogen y coordinates.* @param H1z        Output: First hydrogen z coordinates.* @param H2x        Output: Second hydrogen x coordinates.* @param H2y        Output: Second hydrogen y coordinates.* @param H2z        Output: Second hydrogen z coordinates.* @param Mx         Output: Virtual site x coordinates.* @param My         Output: Virtual site y coordinates.* @param Mz         Output: Virtual site z coordinates.*/static inline void load_3_4atoms(float *address1,              float *address2,              float *address3,              vector float *Ox,              vector float *Oy,              vector float *Oz,              vector float *H1x,              vector float *H1y,              vector float *H1z,              vector float *H2x,              vector float *H2y,              vector float *H2z,              vector float *Mx,              vector float *My,              vector float *Mz){	vector unsigned char perm;	vector float tmp1,tmp2,tmp3,tmp4;	vector float c1a,c2a,c3a;	vector float c1b,c2b,c3b;	vector float c1c,c2c,c3c;  	/* load the coordinates */	c1a                 = vec_ld(  0, address1 ); 	c2a                 = vec_ld( 16, address1 ); 	c3a                 = vec_ld( 32, address1 ); 	if(((unsigned int)address1) & 0xf) { 		/*  Load extra data and rotate if not aligned */		tmp4              = vec_ld( 48, address1 );		perm              = vec_lvsl( 0, address1 ); 		c1a               = vec_perm(c1a,c2a,perm);      /*  Oxa  Oya  Oza H1xa */		c2a               = vec_perm(c2a,c3a,perm);      /* H1ya H1za H2xa H2ya */		c3a               = vec_perm(c3a,tmp4,perm);     /* H2za  Mxa  Mya  Mza */	}	c1b                 = vec_ld(  0, address2 ); 	c2b                 = vec_ld( 16, address2 ); 	c3b                 = vec_ld( 32, address2 ); 	if(((unsigned int)address2) & 0xf) { 		/*  Load extra data and rotate if not aligned */		tmp4              = vec_ld( 48, address2 );		perm              = vec_lvsl( 0, address2 ); 		c1b               = vec_perm(c1b,c2b,perm);      /*  Oxb  Oyb  Ozb H1xb */		c2b               = vec_perm(c2b,c3b,perm);      /* H1yb H1zb H2xb H2yb */		c3b               = vec_perm(c3b,tmp4,perm);     /* H2zb  Mxb  Myb  Mzb */	}	c1c                 = vec_ld(  0, address3 ); 	c2c                 = vec_ld( 16, address3 ); 	c3c                 = vec_ld( 32, address3 ); 	if(((unsigned int)address3) & 0xf) { 		/*  Load extra data and rotate if not aligned */		tmp4              = vec_ld( 48, address3 );		perm              = vec_lvsl( 0, address3 ); 		c1c               = vec_perm(c1c,c2c,perm);     /*  Oxc  Oyc  Ozc H1xc */		c2c               = vec_perm(c2c,c3c,perm);     /* H1yc H1zc H2xc H2yc */		c3c               = vec_perm(c3c,tmp4,perm);    /* H2zc  Mxc  Myc  Mzc */	}	/* permute things */	tmp1              = vec_mergeh(c1a,c1c);          /*  Oxa  Oxc  Oya  Oyc */	c1a               = vec_mergel(c1a,c1c);          /*  Oza  Ozc H1xa H1xc */	c1c               = vec_mergeh(c1b,c1b);          /*  Oxb   -   Oyb   -  */	c1b               = vec_mergel(c1b,c1b);          /*  Ozb   -  H1xb   -  */	tmp2              = vec_mergeh(c2a,c2c);          /* H1ya H1yc H1za H1zc */	c2a               = vec_mergel(c2a,c2c);          /* H2xa H2xc H2ya H2yc */	c2c               = vec_mergeh(c2b,c2b);          /* H1yb   -  H1zb   -  */	c2b               = vec_mergel(c2b,c2b);          /* H2xb   -  H2yb   -  */	tmp3              = vec_mergeh(c3a,c3c);          /* H2za H2zc  Mxa  Mxc */	c3a               = vec_mergel(c3a,c3c);          /*  Mya  Myc  Mza  Mzc */	c3c               = vec_mergeh(c3b,c3b);          /* H2zb   -   Mxb   -  */	c3b               = vec_mergel(c3b,c3b);          /*  Myb   -   Mzb   -  */	*Ox               = vec_mergeh(tmp1,c1c);         /*  Oxa  Oxb  Oxc   -  */	*Oy               = vec_mergel(tmp1,c1c);         /*  Oya  Oyb  Oyc   -  */	*Oz               = vec_mergeh(c1a,c1b);          /*  Oza  Ozb  Ozc   -  */	*H1x              = vec_mergel(c1a,c1b);          /* H1xa H1xb H1xc   -  */	*H1y              = vec_mergeh(tmp2,c2c);         /* H1ya H1yb H1yc   -  */	*H1z              = vec_mergel(tmp2,c2c);         /* H1za H1zb H1zc   -  */	*H2x              = vec_mergeh(c2a,c2b);          /* H2xa H2xb H2xc   -  */	*H2y              = vec_mergel(c2a,c2b);          /* H2ya H2yb H2yc   -  */  	*H2z              = vec_mergeh(tmp3,c3c);         /* H2za H2zb H2zc   -  */	*Mx               = vec_mergel(tmp3,c3c);         /*  Mxa  Mxb  Mxc   -  */	*My               = vec_mergeh(c3a,c3b);          /*  Mya  Myb  Myc   -  */	*Mz               = vec_mergel(c3a,c3b);          /*  Mza  Mzb  Mzc   -  */}/** Load coords of 2 3-atom waters (2*9 floats) to SIMD vectors.** We use our knowledge about water to improve the loading performance.* The allocated memory is always 8-byte aligned, so with nine atoms* we can always read 3 16-byte chunks (rounded down by vec_ld)* without going outside the current page (which might incur a page fault). * The extra elements before and after the water dont matter as long as we dont* try to write to them.** @param address1   Address of first coord in first water (oxygen x).* @param address2   Address of first coord in second water (oxygen x).* @param Ox         Output: Oxygen x coordinates.* @param Oy         Output: Oxygen y coordinates.* @param Oz         Output: Oxygen z coordinates.* @param H1x        Output: First hydrogen x coordinates.* @param H1y        Output: First hydrogen y coordinates.* @param H1z        Output: First hydrogen z coordinates.* @param H2x        Output: Second hydrogen x coordinates.* @param H2y        Output: Second hydrogen y coordinates.* @param H2z        Output: Second hydrogen z coordinates.*/static inline void load_2_3atoms(float *address1,              float *address2,              vector float *Ox,              vector float *Oy,              vector float *Oz,              vector float *H1x,              vector float *H1y,              vector float *H1z,              vector float *H2x,              vector float *H2y,              vector float *H2z){	vector unsigned char perm;	vector float tmp1,tmp2,tmp3;	vector float c1a,c2a,c3a;	vector float c1b,c2b,c3b;  	/* load the coordinates */	perm              = vec_lvsl( 0, (int *) address1 ); 	tmp1              = vec_ld(  0, address1 ); 	tmp2              = vec_ld( 16, address1 ); 	tmp3              = vec_ld( 32, address1 ); 	c1a               = vec_perm(tmp1,tmp2,perm);     /*  Oxa  Oya  Oza H1xa */	c2a               = vec_perm(tmp2,tmp3,perm);     /* H1ya H1za H2xa H2ya */	c3a               = vec_perm(tmp3,tmp3,perm);     /* H2za   -   -   - */	perm              = vec_lvsl( 0, (int *) address2 ); 	tmp1              = vec_ld(  0, address2 ); 	tmp2              = vec_ld( 16, address2 ); 	tmp3              = vec_ld( 32, address2 );  	c1b               = vec_perm(tmp1,tmp2,perm);     /*  Oxb  Oyb  Ozb H1xb */	c2b               = vec_perm(tmp2,tmp3,perm);     /* H1yb H1zb H2xb H2yb */	c3b               = vec_perm(tmp3,tmp3,perm);     /* H2zb   -   -   - */	/* never mind what we get in the two remaining elements */	*Ox               = vec_mergeh(c1a,c1b);          /*  Oxa  Oxb  Oya  Oyb */ 	*H1y              = vec_mergeh(c2a,c2b);          /* H1ya H1yb H1za H1zb */	*H2z              = vec_mergeh(c3a,c3b);          /* H2za H2zb   -    -  */  	*Oz               = vec_mergel(c1a,c1b);          /*  Oza  Ozb H1xa H1xb */ 	*H2x              = vec_mergel(c2a,c2b);          /* H2xa H2xb H2ya H2yb */	*Oy               = vec_sld(*Ox,*Ox,8);	*H1z              = vec_sld(*H1y,*H1y,8); 	*H1x              = vec_sld(*Oz,*Oz,8);	*H2y              = vec_sld(*H2x,*H2x,8);}/** Load coords of 2 4-atom waters (2*12 floats) to SIMD vectors.** We use our knowledge about water to improve the loading performance.* The allocated memory is always 8-byte aligned, so with 12 atoms* we can always read 4 16-byte chunks (rounded down by vec_ld)* without going outside the current page (which might incur a page fault). * The extra elements before and after the water dont matter as long as we dont* try to write to them.** @param address1   Address of first coord in first water (oxygen x).* @param address2   Address of first coord in second water (oxygen x).* @param Ox         Output: Oxygen x coordinate

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?