mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-30 03:24:33 +00:00 
			
		
		
		
	Compare commits
	
		
			1684 Commits
		
	
	
		
			feature/lu
			...
			feature/su
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 251b904a28 | ||
|  | 5dfd216a34 | ||
|  | 5a112feac3 | ||
|  | c2e8d0aa88 | ||
|  | bf96a4bdbf | ||
|  | 84685c9bc3 | ||
|  | 013ea4e8d1 | ||
|  | 7fbbb31a50 | ||
|  | 0e127b1fc7 | ||
|  | 68c028b0a6 | ||
| a61e0df54b | |||
| f871fb0c6d | |||
|  | 25d1cadd3b | ||
|  | c24d53bbd1 | ||
| 3c7a4106ed | |||
|  | 6eed167f0c | ||
|  | 4ad0df6fde | ||
|  | 68a5079f33 | ||
|  | 8634e19f1b | ||
|  | 9ada378e38 | ||
| bfbf2f1fa0 | |||
|  | 587bfcc0f4 | ||
|  | 8c658de179 | ||
|  | ba37d51ee9 | ||
|  | 4f4181c54a | ||
|  | 4d4ac2517b | ||
|  | e568c24d1d | ||
|  | b458326744 | ||
|  | 6e7d5e2243 | ||
|  | b35169f1dd | ||
|  | 441ad7498d | ||
|  | 6f6c5c549a | ||
|  | 1584e17b54 | ||
|  | 12982a4455 | ||
|  | 172f412102 | ||
|  | a64497265d | ||
|  | c45f24a1b5 | ||
|  | aaf37ee4d7 | ||
|  | 1dddd17e3c | ||
|  | 661f1d3e8e | ||
|  | edcf9b9293 | ||
|  | fe6860b4dd | ||
|  | d6406b13e1 | ||
|  | e369d7306d | ||
|  | 9f8d63e104 | ||
|  | 9b0240d101 | ||
|  | b27f0e5a53 | ||
|  | 75e4483407 | ||
|  | 0734e9ddd4 | ||
|  | 809b1cdd58 | ||
|  | 1be8089604 | ||
|  | 3e0eff6468 | ||
|  | 7ecc47ac89 | ||
|  | e9f1ac09de | ||
|  | fa0d8feff4 | ||
|  | 05b44aef6b | ||
|  | 03e9832efa | ||
|  | 28a375d35d | ||
|  | 3b06381745 | ||
|  | 91a0a3f820 | ||
|  | 8f44c799a6 | ||
|  | 96272f3841 | ||
|  | 5c936d88a0 | ||
|  | 1c64ee926e | ||
|  | 2cbb72a81c | ||
|  | 31d83ee046 | ||
|  | a9e8758a01 | ||
|  | 3e125c5b61 | ||
|  | eac6ec4b5e | ||
|  | 213f8db6a2 | ||
|  | 6358f35b7e | ||
|  | 43f5a0df50 | ||
|  | c897878776 | ||
|  | 2baf193031 | ||
|  | 362ba0443a | ||
|  | 276a2353df | ||
|  | c5b9147b53 | ||
|  | 64ac815fd9 | ||
|  | a1be533329 | ||
| 141da3ae71 | |||
| 94edf9cf8b | |||
| c11a3ca0a7 | |||
|  | 870b1a85ae | ||
|  | b5510427f9 | ||
|  | 26ed65c8f8 | ||
|  | f7f043d8cf | ||
|  | ddcaa6ad29 | ||
| c8d4d184ee | |||
| 1569a374a9 | |||
| eddf023b8a | |||
|  | f089bf5629 | ||
|  | 276f113f28 | ||
| a13c109111 | |||
|  | ab6afd18ac | ||
|  | 5bde64d48b | ||
|  | 2f5add4d5f | ||
| c5a885dcd6 | |||
|  | c9c073eee4 | ||
|  | f290b2e908 | ||
|  | 5f8225461b | ||
| 20e186a1e0 | |||
|  | 6ef4af989b | ||
|  | ccde8b817f | ||
|  | 68168bf72d | ||
|  | e93d0feaa7 | ||
|  | 8f601d9b39 | ||
|  | 5436308e4a | ||
|  | 07fe7d0cbe | ||
|  | 60b57706c4 | ||
|  | 954e38bebe | ||
|  | b1a38bde7a | ||
|  | 2581875edc | ||
|  | 6c6d43eb4e | ||
|  | e1dcfd3553 | ||
|  | 888838473a | ||
|  | 01568b0e62 | ||
|  | d5ce66f6ab | ||
|  | d86936a3de | ||
|  | 0fb84fa34b | ||
|  | 0880747edb | ||
|  | b801e1fcd6 | ||
| 360cface33 | |||
|  | 80302e95a8 | ||
| caf2f6b274 | |||
| c49be8988b | |||
| 971c2379bd | |||
|  | 94b0d66e4c | ||
|  | 5e8af396fd | ||
| a7d19dbb64 | |||
| 90dbe03e17 | |||
| 8b14096990 | |||
|  | b938202081 | ||
| 485c5db0fe | |||
|  | c399c2b44d | ||
|  | af7de7a294 | ||
|  | 1dc86efd26 | ||
| 30391cb2eb | |||
|  | 2e88408f5c | ||
|  | 0f468e2179 | ||
|  | 4790e99817 | ||
|  | 2dd63aa7a4 | ||
|  | 559a501140 | ||
|  | 945684c470 | ||
|  | e30a80a234 | ||
|  | c96483e3bd | ||
|  | ae31a6a760 | ||
|  | dd8f2a64fe | ||
|  | 7b8b2731e7 | ||
|  | 237a8ec918 | ||
|  | 896f3a8002 | ||
|  | f0fcdf75b5 | ||
|  | 53bffb83d4 | ||
|  | cd44e851f1 | ||
|  | fb24e3a7d2 | ||
|  | 655a69259a | ||
|  | 507c4e9efc | ||
|  | f8a5194c70 | ||
|  | cff3bae155 | ||
| 6e3ce7423e | |||
| 15f15a7cfd | |||
| 0e5f626226 | |||
|  | 97b9c6f03d | ||
|  | 63982819c6 | ||
|  | b00d2d2c39 | ||
|  | f1b3e21830 | ||
|  | b7f8c5b823 | ||
|  | 3923683e9b | ||
|  | e199fda9dc | ||
| 7bb405e790 | |||
| ec16eacc6a | |||
|  | cf858deb16 | ||
|  | a3affac963 | ||
| d9d1f43ba2 | |||
| b7cd721308 | |||
| 29f026c375 | |||
| 58c7a13d54 | |||
|  | 24162c9ead | ||
|  | e564d11687 | ||
|  | 0b2162f375 | ||
|  | 5610570182 | ||
|  | 44f65526e0 | ||
|  | 43e48542ab | ||
|  | 0b85f1bfc8 | ||
|  | 9947cfbf14 | ||
|  | 357badce5e | ||
|  | 0091eec23a | ||
|  | 9e9c2962df | ||
|  | bda97212a9 | ||
|  | b91282ad46 | ||
|  | 0a68470f9a | ||
|  | 6ecf280723 | ||
|  | 7eeab7f995 | ||
|  | 9b32d51cd1 | ||
|  | 7b3ed160aa | ||
|  | 1a0163f45c | ||
|  | 9028e278e4 | ||
| dd62f2f371 | |||
| 0d612039ed | |||
| e8ac75055c | |||
| 8b30c5956c | |||
| 185da83454 | |||
| 6718fa8c4f | |||
|  | 4ce63af7d5 | ||
| 67c3fa0f5f | |||
| 65d4f17976 | |||
| e2fe97277b | |||
|  | 84f9c37ed4 | ||
| bcf6f3890c | |||
| 591a38c487 | |||
| 842754bea9 | |||
| 0887566134 | |||
| 61fc50d616 | |||
| a9c8d7dad0 | |||
| 259d504ef0 | |||
| f3a77f4b7f | |||
| 26d7b829a0 | |||
| 64161a8743 | |||
| 2401360784 | |||
|  | 2cfb50cbe5 | ||
| f9aa39e1c4 | |||
| 0fbf445edd | |||
| e78794688a | |||
| 9e31307963 | |||
| 29e2eddea8 | |||
| 0a038ea15a | |||
| 62eb1f0e59 | |||
| 5422251959 | |||
|  | 9579c9c327 | ||
|  | 3729c7a7a6 | ||
|  | c24d4c8d0e | ||
|  | a14038051f | ||
|  | 3e560b9462 | ||
|  | d93c6760ec | ||
|  | ae3b7713a9 | ||
| cbd8fbe771 | |||
| d391f05cb7 | |||
| 3127b52c90 | |||
| 01f00385a4 | |||
| 59aae5f5ec | |||
| 624246409c | |||
| 2a9ebddad5 | |||
| ff7afe6e17 | |||
| 33cb509d4b | |||
| 456c78c233 | |||
| 2fd4989029 | |||
| 2427a21428 | |||
| 514993ed17 | |||
|  | 28ceacec45 | ||
|  | e6a3e375cf | ||
|  | 4987edbd44 | ||
|  | ad140bb6e7 | ||
|  | 1f04e56038 | ||
|  | 4bfc8c85c3 | ||
|  | e55397bc13 | ||
| a3fe874a5b | |||
| f403ab0133 | |||
|  | 94b8fb5686 | ||
|  | 1f1d77b01a | ||
|  | 6a15e2e8ef | ||
| 074d17429f | |||
|  | 25f73018f4 | ||
|  | 1d7ccc6b2c | ||
|  | 59d9ccf70c | ||
|  | 1860b1698c | ||
|  | 9b8d1cc3da | ||
|  | 149c3f9e9c | ||
|  | c519aab19d | ||
|  | 69929f20bb | ||
|  | a493429218 | ||
|  | 915f610da0 | ||
|  | c79606a5dc | ||
|  | 360efd0088 | ||
|  | 7b42ac9982 | ||
|  | c5c647e35e | ||
| a4e5fd1000 | |||
| 682e7d7839 | |||
|  | 8e057721a9 | ||
|  | fa5e4add47 | ||
|  | 27ea2afe86 | ||
|  | 78e8704eac | ||
|  | 67131d82f2 | ||
|  | 615a9448b9 | ||
|  | 00164f5ce5 | ||
|  | a7f72eb994 | ||
|  | 501fa1614a | ||
|  | 5bf42e1e15 | ||
|  | fe4d9b003c | ||
|  | 4a699b4da3 | ||
|  | 689323f4ee | ||
|  | 749189fd72 | ||
|  | f941c4ee18 | ||
|  | 84b441800f | ||
|  | 1ef424b139 | ||
|  | aa66f41c69 | ||
|  | f96c800d25 | ||
|  | 32a52d7583 | ||
|  | fa04b6d3c2 | ||
|  | 7fab183c0e | ||
|  | 9ec9850bdb | ||
|  | 0c4ddaea0b | ||
|  | 00ebc150ad | ||
|  | 0f3e9ae57d | ||
|  | 034de160bf | ||
|  | 76bcf6cd8c | ||
|  | 91b8bf0613 | ||
|  | 14507fd6e4 | ||
|  | 2db05ac214 | ||
|  | 31f99574fa | ||
|  | a34c8a2961 | ||
|  | ccd20df827 | ||
|  | e9be293444 | ||
|  | d577211cc3 | ||
|  | f4336e480a | ||
|  | e4d461cb03 | ||
|  | 3d63b4894e | ||
|  | 08583afaff | ||
|  | b395a312af | ||
|  | 66295b99aa | ||
|  | b8654be0ef | ||
|  | a479325349 | ||
|  | f6c3f6bf2d | ||
|  | d83868fdbb | ||
|  | 303e0b927d | ||
|  | 28ba8a0f48 | ||
|  | f9e28577f3 | ||
|  | e0cae833da | ||
|  | 8a3aae98f6 | ||
|  | 8309f2364b | ||
|  | cac1750078 | ||
|  | e17cd35151 | ||
|  | ccdec7a7ab | ||
|  | 93642d813d | ||
|  | 0bc381f982 | ||
|  | 2986aa76f8 | ||
|  | 657779374b | ||
|  | ec8cd11c1f | ||
|  | cbda4f66e0 | ||
|  | 6579dd30ff | ||
|  | 031c94e02e | ||
|  | 6391b2a1d0 | ||
|  | 2e50b55ae4 | ||
|  | 27936900e6 | ||
|  | cd3e810d25 | ||
|  | 317ddfedee | ||
|  | e325929851 | ||
|  | 47af3565f4 | ||
|  | 4b4d187935 | ||
|  | 9aff354ab5 | ||
|  | cb9ff20249 | ||
|  | 9fe6ac71ea | ||
| 5c392a6ecc | |||
|  | f1fa00b71b | ||
|  | bf58557fb1 | ||
|  | 10cb37f504 | ||
|  | 1374c943d4 | ||
|  | a1d80282ec | ||
|  | 4eb8bbbebe | ||
|  | d1c6288c5f | ||
|  | dd949bc428 | ||
|  | bb7378cfc3 | ||
|  | f0e084a88c | ||
|  | 153672d8ec | ||
|  | 08ca338875 | ||
|  | f7cbf82c04 | ||
|  | 07009c569a | ||
|  | 15d690e9b9 | ||
| 63b2bc1936 | |||
|  | d810e8c8fb | ||
|  | 09f4cdb11e | ||
|  | 1e54882f71 | ||
|  | 27caff92c6 | ||
| d38cee73bf | |||
| 8784f2a88d | |||
| c497864b5d | |||
| 05c1c88440 | |||
|  | d54807b8c0 | ||
|  | f6ba2b95ce | ||
|  | 5625b47c7d | ||
|  | 1edcf902b7 | ||
|  | e5c19e1fd7 | ||
|  | a11d0a33d1 | ||
|  | 4f8b6f26b4 | ||
|  | 073525c5b3 | ||
|  | eb6153080a | ||
|  | f7072d1ac2 | ||
| a021933002 | |||
|  | 56478d63a5 | ||
| df21668f2c | |||
|  | 482368e9de | ||
|  | fddeb29d6b | ||
|  | a9ec5cf564 | ||
|  | 946a8671b9 | ||
|  | a6eeea777b | ||
|  | 771a1b8e79 | ||
|  | bfb68e6f02 | ||
|  | 77f7737ccc | ||
|  | 9a827d0242 | ||
|  | 999c623590 | ||
|  | 18c335198a | ||
|  | f9df685cde | ||
|  | 17c5b0f152 | ||
|  | 5918769f97 | ||
|  | b542d349b8 | ||
|  | 91eaace19d | ||
|  | bbaf1ada91 | ||
|  | 1950ac9294 | ||
|  | 13fa70ac1a | ||
|  | 7cb2b11f26 | ||
|  | 1184ed29ae | ||
|  | 203c7bf6fa | ||
|  | c709883f3f | ||
|  | aed5de4d50 | ||
|  | ba27cc6571 | ||
|  | d856327250 | ||
|  | d75369cb56 | ||
|  | bf973d0d56 | ||
|  | 837bf8a5be | ||
|  | c05b2199f6 | ||
|  | a5fe07c077 | ||
|  | b83b2b1415 | ||
|  | b331be9101 | ||
|  | 49c20a9fa8 | ||
|  | 7359df3501 | ||
|  | 59bd1fe21b | ||
| a56e3b40c4 | |||
|  | 4e907fef2c | ||
|  | 67888b657f | ||
|  | 74af885d4e | ||
|  | d36d2fb40d | ||
|  | 5b9267e88d | ||
|  | 15fd4003ef | ||
|  | 4b4c2a715b | ||
|  | 54a5e6c1d0 | ||
|  | 73aeca7dea | ||
|  | ad89abb018 | ||
|  | 80c5bce5bb | ||
|  | f68b5de9c8 | ||
|  | d0f3d525d5 | ||
|  | f365a83fae | ||
|  | 3a58217405 | ||
|  | c289699d9a | ||
|  | c3b1263e75 | ||
|  | 34a9aeb331 | ||
| 5846566728 | |||
| 102ea9ae66 | |||
| 21b02760c3 | |||
|  | 2bcb704af2 | ||
|  | 5fa386ddc9 | ||
|  | edabb3577f | ||
|  | ce5df177ee | ||
|  | a0bb8e5b46 | ||
|  | 46f88e6d72 | ||
|  | dd8f1ea189 | ||
|  | b61835c1a5 | ||
|  | d9cd4f0273 | ||
|  | 459f70e8d4 | ||
|  | 061e48fd73 | ||
|  | ab50145001 | ||
|  | b49bec0cec | ||
|  | ae56e556c6 | ||
|  | 1cdf999668 | ||
|  | 11062fb686 | ||
|  | 383ca7d392 | ||
|  | a446d95c33 | ||
|  | be66e7dd95 | ||
|  | 6d0d064a6c | ||
|  | bfef525ed2 | ||
|  | 0b0cf62193 | ||
|  | 7d88198387 | ||
|  | 2f619482b8 | ||
|  | d6472eda8d | ||
|  | 9e658de238 | ||
|  | bcefdd7c4e | ||
|  | 9d45fca8bc | ||
|  | ac9e6b63c0 | ||
|  | e140b3f802 | ||
|  | d9d3d30cc7 | ||
|  | 47a12ec7b5 | ||
|  | ec1e2f7a40 | ||
|  | 41f73ec083 | ||
|  | fd367d8bfd | ||
|  | 6d0786ff9d | ||
|  | b7f93aeb4d | ||
|  | 202a7fe900 | ||
|  | 8d168ded4a | ||
|  | 8a3fe60a27 | ||
|  | 44051aecd1 | ||
|  | 06e6f8de00 | ||
|  | dbe4d7850c | ||
|  | 4fe182e5a7 | ||
|  | 75ee6cfc86 | ||
|  | fde71c3c52 | ||
|  | 175f393f9d | ||
|  | 7d867a8134 | ||
|  | 9939b267d2 | ||
|  | 323e9c439a | ||
|  | 28396f1048 | ||
|  | 67b34e5789 | ||
|  | 14d53e1c9e | ||
|  | 8bd869da37 | ||
|  | c7036f6717 | ||
|  | c0485d799d | ||
|  | 7abc5613bd | ||
|  | 237cfd11ab | ||
|  | a4b7dddb67 | ||
|  | 5696781862 | ||
|  | 8f4b3049cd | ||
|  | 2a6e673a91 | ||
|  | 9b6cde173f | ||
|  | 9f280b82c4 | ||
| c3f0889eda | |||
|  | 7a53dc3715 | ||
|  | 0f214ad427 | ||
|  | fe4912880d | ||
|  | 875e1a841f | ||
|  | 0366288b1c | ||
|  | 6293d438cd | ||
|  | 852ade029a | ||
|  | f038c6babe | ||
|  | 169f4b2711 | ||
|  | 2d8aff36fe | ||
|  | 9fa07eecde | ||
|  | 659d7d1a40 | ||
|  | f64fb7bd77 | ||
|  | 2a35449b91 | ||
|  | 184af5bd05 | ||
|  | 097c9637ee | ||
|  | dc6f078246 | ||
|  | 8a4714a4a6 | ||
|  | 40e119c61c | ||
|  | d9593c4b81 | ||
|  | ac740f73ce | ||
|  | 75dc7794b9 | ||
|  | dee68fc728 | ||
|  | a2d3643634 | ||
|  | 57002924bc | ||
|  | 7b0237b081 | ||
|  | b68ad0cc0b | ||
|  | 37263fd9b1 | ||
|  | 3d09e3e9e0 | ||
|  | 1354b46338 | ||
|  | 251a97fe1b | ||
|  | e18929eaa0 | ||
|  | f3b0a92e71 | ||
|  | a0be3f7330 | ||
|  | b5a6e4f1fd | ||
|  | 7a788db3dc | ||
|  | f20eceb6cd | ||
|  | 38325ebbc6 | ||
|  | b73bd151bb | ||
|  | 694b305cab | ||
|  | 2d3737a133 | ||
|  | ac1f1838bc | ||
|  | 09d09d0fe5 | ||
|  | bf630a6821 | ||
|  | 8859a151cc | ||
|  | 688a39cfd9 | ||
|  | 6f5a5cd9b3 | ||
|  | 0933aeefd4 | ||
|  | 322f61acee | ||
|  | 08e04b9676 | ||
| feaa2ac947 | |||
| 07de925127 | |||
|  | a9c816a268 | ||
|  | e43a8b6b8a | ||
|  | bf729766dd | ||
|  | dafb351d38 | ||
| 0b707b861c | |||
| 15e87a4607 | |||
| 7d7220cbd7 | |||
|  | 7d2d5e8d3d | ||
|  | 54e94360ad | ||
| 0af740dc15 | |||
| d2e8372df3 | |||
|  | 869b99ec1e | ||
|  | 4a29ab0d0a | ||
|  | 0165bcb58e | ||
|  | deca1ecc50 | ||
| 4372d04ad4 | |||
|  | 349d75e483 | ||
|  | 56abbdf4c2 | ||
|  | af71c63f4c | ||
|  | e51475703a | ||
|  | 1feddf4ba6 | ||
|  | 600d7ddc2e | ||
|  | e504260f3d | ||
|  | 0440d4ce66 | ||
|  | 08b0e472aa | ||
|  | c11d69787e | ||
|  | dc6b2d30d2 | ||
|  | 7a3bd5c66c | ||
|  | 18211eb5b1 | ||
|  | 863bb2ad10 | ||
|  | 5e4bea8f20 | ||
|  | 6ebf9f15b7 | ||
|  | 1d7aa673a4 | ||
|  | b9104f3072 | ||
| b22eab8c8b | |||
|  | a7d56523ab | ||
|  | 9e56c65730 | ||
|  | ef4f2b8c41 | ||
|  | e8b95bd35b | ||
|  | 7e35286860 | ||
|  | 0486ff8e79 | ||
| 1e8a2e1621 | |||
| 7587df831a | |||
|  | e9cc21900f | ||
|  | 0a8faac271 | ||
|  | abc4de0fd2 | ||
| b672717096 | |||
| 284ee194b1 | |||
|  | cfe3cd76d1 | ||
|  | 3fa5e3109f | ||
|  | 8b7049f737 | ||
|  | c85024683e | ||
|  | 1300b0b04b | ||
|  | e6d984b484 | ||
|  | 1d18d95d4f | ||
|  | ae39ec85a3 | ||
|  | b96daf53a0 | ||
|  | 46879e1658 | ||
|  | ae4de94798 | ||
|  | 0ab555b4f5 | ||
|  | 8e9be9f84f | ||
|  | d572170170 | ||
| 81b18f843a | |||
|  | 1bd311ba9c | ||
|  | 41af8c12d7 | ||
|  | a833f88c32 | ||
|  | 07b2c1b253 | ||
|  | 735cbdb983 | ||
|  | 2ad54c5a02 | ||
|  | 12ccc73cf5 | ||
|  | 3d04dc33c6 | ||
|  | e7564f8330 | ||
|  | 91199a8ea0 | ||
|  | 0494feec98 | ||
|  | a16b1e134e | ||
|  | 5633a2db20 | ||
|  | 2d433ba307 | ||
|  | 769ad578f5 | ||
|  | eaac0044b5 | ||
|  | 56042f002c | ||
|  | 3bfd1f13e6 | ||
|  | 70ab598c96 | ||
|  | 1d0ca65e28 | ||
|  | 2bc4d0a20e | ||
| 2490816297 | |||
| 5f55bca378 | |||
|  | b8e45ae490 | ||
|  | b35fc4e7f9 | ||
|  | 60f11bfd72 | ||
| f6aa82b7f2 | |||
| 22749699a3 | |||
|  | 8d442b502d | ||
|  | e5c8b7369e | ||
| 0503c028be | |||
|  | c504b4dbad | ||
|  | 622a21bec6 | ||
|  | eec79e0a1e | ||
|  | 092dcd4e04 | ||
|  | 4a8c4ccfba | ||
|  | 9b44189d5a | ||
|  | 7da4856e8e | ||
|  | aaf1e33a77 | ||
|  | 094c3d091a | ||
|  | 4b98e524a0 | ||
|  | 1a1f6d55f9 | ||
|  | 21421656ab | ||
|  | 6f687a67cd | ||
|  | b30754e762 | ||
|  | 1e429a0d57 | ||
|  | d38a4de36c | ||
|  | ef1b7db374 | ||
|  | 53a9aeb965 | ||
|  | e30fa9f4b8 | ||
|  | 58e8d0a10d | ||
|  | 62cf9cf638 | ||
|  | 0fb458879d | ||
|  | 725c513d94 | ||
| d8648307ff | |||
| 064315c00b | |||
|  | 7c6cc85df6 | ||
|  | a6691ef87c | ||
|  | 23135aa58a | ||
|  | 8e0ced627a | ||
|  | 0de314870d | ||
|  | ffb91e53d2 | ||
|  | f4e8bf2858 | ||
| a74c34315c | |||
|  | 69470ccc10 | ||
|  | b8b5934193 | ||
|  | 75856f2945 | ||
|  | 3c112a7a25 | ||
|  | ab3596d4d3 | ||
|  | a8c10b1933 | ||
|  | 15e801af3f | ||
|  | 0ffc235741 | ||
|  | 8e19c99c7d | ||
|  | a0bc0ad06f | ||
|  | a8fb2835ca | ||
|  | bc862ce3ab | ||
|  | 08b314fd0f | ||
| 22f4feee7b | |||
| 3f858d6755 | |||
|  | 3267683e22 | ||
|  | f46a67ffb3 | ||
|  | f7b8383ef5 | ||
|  | 10f2872aae | ||
|  | 34332fe393 | ||
|  | c2010f21ab | ||
|  | 98f610ce53 | ||
|  | d44cc204d1 | ||
| 35fa3d1dfd | |||
|  | cd73897b8d | ||
|  | c4435e6beb | ||
|  | 7a8f6af5f8 | ||
|  | 49a5d9bac7 | ||
|  | 2b3fdd4a58 | ||
|  | 34502ec471 | ||
|  | 8a43e88b4f | ||
| d1ece74137 | |||
|  | 238df20370 | ||
|  | 97a32a6145 | ||
|  | 655492a443 | ||
|  | 1cab06f6bd | ||
| 43c817cc67 | |||
|  | f8024c262b | ||
|  | 4cc5f01f4a | ||
|  | 9c12c37aaf | ||
|  | 806eaa0530 | ||
|  | 01d0e54594 | ||
|  | 5aafa335fe | ||
|  | 8ba0494485 | ||
|  | d99d98d9fd | ||
|  | 95a017a4ae | ||
|  | 92f92379e6 | ||
|  | 529e78d43f | ||
|  | 4ec746d262 | ||
|  | 51bf1501fc | ||
|  | 66d819c054 | ||
|  | 3f3686f869 | ||
|  | 26bb829f8c | ||
|  | 67cb04fc66 | ||
|  | a40bd68aed | ||
|  | 36495e0fd2 | ||
|  | 93f6c15772 | ||
|  | cb93eeff21 | ||
|  | c7cc7e6101 | ||
|  | c349aa6511 | ||
|  | 3bae0a2d5c | ||
|  | c1c7566089 | ||
|  | 2439999ec8 | ||
|  | 1d96f662e3 | ||
|  | 41d1889941 | ||
|  | 0c3981e0c3 | ||
|  | c727bd4609 | ||
|  | db23749b67 | ||
|  | 751f2b9703 | ||
|  | 741bc836f6 | ||
|  | 697c0603ce | ||
|  | 14bedebb11 | ||
|  | 8546d01a4c | ||
|  | 47b5c07ffb | ||
|  | da86a2bf54 | ||
|  | c1cb60a0b3 | ||
|  | 5ed5b4bfbf | ||
|  | de84aacdfd | ||
|  | 2888003765 | ||
|  | da06bf5b95 | ||
|  | 20999c1370 | ||
|  | 77e0af9c2e | ||
|  | 33f0ed1a33 | ||
|  | 50be56433b | ||
|  | 43924007db | ||
|  | 78ef10e60f | ||
|  | ca1077c560 | ||
| 679ae98b14 | |||
|  | 90f6bc16bb | ||
|  | 9b5b639546 | ||
|  | 945767c6d8 | ||
|  | 422cdf4979 | ||
|  | 38db174f3b | ||
|  | 92e364a35f | ||
| 58299b8ba2 | |||
| 124bf4d829 | |||
| e8e56b3414 | |||
| 89c430136d | |||
| ea9aef7baa | |||
| c9e9e8061d | |||
|  | 453cf2a1c6 | ||
|  | de7bbfa5f9 | ||
| dda8d77c87 | |||
| aa29f4346a | |||
|  | 86116dbed6 | ||
|  | 7bd31e3f7c | ||
|  | 74f451715f | ||
|  | 655be8ed76 | ||
|  | 4063238943 | ||
|  | 3344788fa1 | ||
|  | 62a64d9108 | ||
|  | 49331a3e72 | ||
|  | 51d84ec057 | ||
|  | db14fb30df | ||
|  | b9356d3866 | ||
|  | 99a73f4287 | ||
|  | f302eea91e | ||
|  | 5553b8d2b8 | ||
|  | a6ccbbe108 | ||
|  | 99220f6531 | ||
|  | d2003f24f4 | ||
|  | 6299dd35f5 | ||
|  | a39daecb62 | ||
|  | 159770e21b | ||
|  | 2a6d093749 | ||
|  | c947947fad | ||
|  | f555b50547 | ||
|  | 738c1a11c2 | ||
|  | f8797e1e3e | ||
|  | fd1eb7de13 | ||
|  | 2ce898efa3 | ||
|  | dc5a6404ea | ||
|  | 44260643f6 | ||
|  | 1425afc72f | ||
|  | ab66bac4e6 | ||
|  | 56277a11c8 | ||
|  | 752048f410 | ||
|  | 916e9e1d3e | ||
|  | 5b55867a7a | ||
|  | 3accb1ef89 | ||
|  | e3d0e31525 | ||
|  | 5812eb8a8c | ||
|  | 4dd3763294 | ||
|  | c429ace748 | ||
|  | ac58565d0a | ||
|  | 3703b718aa | ||
|  | b722889234 | ||
|  | abba44a837 | ||
|  | f301be94ce | ||
|  | 1d1b225497 | ||
|  | 53a785a3dd | ||
|  | 736bf3c866 | ||
|  | b9bbe5d188 | ||
|  | 3844bcf800 | ||
|  | e1a2319d01 | ||
|  | 180c732b4c | ||
|  | 957a706d0b | ||
|  | d2312e9874 | ||
|  | fc4ab9ccd5 | ||
|  | 4a340aa5ca | ||
|  | 3b7de792d5 | ||
|  | 557c3fa109 | ||
|  | ec18e9f7f6 | ||
|  | a839d5bc55 | ||
|  | de41b84c5c | ||
|  | 8e161152e4 | ||
|  | 3141ebac10 | ||
|  | 7ede696126 | ||
|  | bf516c3b81 | ||
|  | 441a52ee5d | ||
|  | a8db024c92 | ||
|  | a9c22d5f43 | ||
|  | 3ca41458a3 | ||
|  | 9e2d29c644 | ||
|  | b694996302 | ||
|  | 951be75292 | ||
|  | b9113ed310 | ||
| 1407418755 | |||
| a6a0da873f | |||
|  | 42fb49d3fd | ||
|  | 2a54c9aaab | ||
|  | 0957378679 | ||
|  | 2ed6c76fc5 | ||
|  | d3b9a7fa14 | ||
|  | 75ea306ce9 | ||
|  | 4226c633c4 | ||
|  | 5a4eafbf7e | ||
|  | eb8e26018b | ||
|  | db5ea001a3 | ||
|  | 2846f079e5 | ||
|  | 1d502e4ed6 | ||
|  | 73cdf0fffe | ||
|  | 1c25773319 | ||
|  | c38400b26f | ||
|  | 9c3065b860 | ||
|  | 94eb829d08 | ||
|  | 68392ddb5b | ||
|  | cb6b81ae82 | ||
|  | c382c351a5 | ||
|  | af2d6ce2e0 | ||
| 90ec6eda0c | |||
|  | ac1253bb76 | ||
| fe8d625694 | |||
| 53e76b41d2 | |||
| 8ef4300412 | |||
| 98a24ebf31 | |||
|  | b12dc89d26 | ||
|  | d80d802f9d | ||
|  | 3d99b09dba | ||
|  | db5f6d3ae3 | ||
|  | 683550f116 | ||
|  | 5e477ec553 | ||
|  | 55d0329624 | ||
|  | 86aaa35294 | ||
|  | 363611ae21 | ||
|  | 172d3dc93a | ||
|  | 3b8a791e28 | ||
|  | 7b03d8d087 | ||
|  | 4b759b8f2a | ||
|  | 8c540333d5 | ||
|  | 6fd82228bf | ||
|  | 5592f7b8c1 | ||
|  | 35da4ece0b | ||
|  | 061b15b9e9 | ||
|  | ca6efc685e | ||
| ff4e54ef80 | |||
|  | 561426f6eb | ||
|  | 83f6fab8fa | ||
|  | 0fade84ab2 | ||
|  | 9dc7ca4c3b | ||
|  | 935d82f5b1 | ||
|  | 9cbcdd65d7 | ||
|  | f18f5ed926 | ||
|  | d1d63a4f2d | ||
|  | 7e5faa0f34 | ||
|  | 6af459cae4 | ||
|  | 1c4bc7ed38 | ||
|  | cd1bd921bd | ||
|  | b8ae787b5e | ||
|  | fbe2c3b5f9 | ||
|  | 1ed69816b9 | ||
|  | fff5751b1a | ||
|  | 2c81696fdd | ||
|  | c9dc22efa1 | ||
|  | 0ab04a000f | ||
|  | 93ea5d9468 | ||
|  | 1ec5d32369 | ||
|  | 9fd23faadf | ||
|  | 10e4fa0dc8 | ||
|  | c4aca1dde4 | ||
|  | b9e8ea3aaa | ||
|  | 077aa728b9 | ||
|  | a8d83d886e | ||
|  | 7fd46eeec4 | ||
|  | e0c4eeb3ec | ||
|  | cb9a297a0a | ||
|  | 2b115929dc | ||
|  | 5c6571dab1 | ||
|  | 417ec56cca | ||
|  | 756bc25008 | ||
|  | 35695ba57a | ||
|  | 81ead48850 | ||
|  | d805867e02 | ||
|  | e55a751e23 | ||
|  | 358eb75995 | ||
|  | 98f9318279 | ||
|  | 4b17e8eba8 | ||
|  | 75112a632a | ||
|  | 18bde08d1b | ||
|  | 3750b9ffee | ||
|  | 5e549ebd8b | ||
|  | fff484eca5 | ||
|  | 5fdc05782b | ||
|  | d45cd7e677 | ||
|  | 4e96679797 | ||
|  | a04eb7df5d | ||
|  | 4c1ea8677e | ||
|  | fc93f0b2ec | ||
|  | 8c8473998d | ||
|  | 120fb59978 | ||
|  | fd56b3ff38 | ||
|  | 0ec6829edc | ||
|  | 18b7845b7b | ||
|  | 3d0fe15374 | ||
|  | 91886068fe | ||
|  | 6d1e9e5f92 | ||
|  | b640230b1e | ||
|  | e7c36771ed | ||
|  | 038b6ee9cd | ||
|  | 38806343a8 | ||
|  | 831ca4e3bf | ||
|  | 8dc57a1e25 | ||
|  | f57bd770b0 | ||
|  | 4ed10a3d06 | ||
|  | dfefc70b57 | ||
|  | 0b61f75c9e | ||
|  | 33edde245d | ||
|  | b64e004555 | ||
|  | 447c5e6cd7 | ||
|  | 8b99d80d8c | ||
|  | b3dede4dd3 | ||
|  | 4e34132f4d | ||
|  | c07cb10247 | ||
|  | d7767a2a62 | ||
|  | ec035983fd | ||
|  | 3901b17ade | ||
|  | af230a1fb8 | ||
|  | 06a132e3f9 | ||
|  | 596dcd85b2 | ||
|  | 96d44d5c55 | ||
|  | 7270c6a150 | ||
|  | 7fe797daf8 | ||
|  | 486a01294a | ||
|  | 586a7c90b7 | ||
|  | e099dcdae7 | ||
|  | 4e7ab3166f | ||
|  | aac80cbb44 | ||
|  | c80948411b | ||
|  | 95625a7bd1 | ||
|  | 0796696733 | ||
|  | f8b9ad7d50 | ||
|  | 04a1959895 | ||
|  | cc773ae70c | ||
|  | d21c51b9be | ||
|  | 597a7b4b3a | ||
|  | 1c30e9a961 | ||
|  | 93cc270016 | ||
|  | 29b60f7e1a | ||
|  | 041884acf0 | ||
|  | 15e668eef1 | ||
|  | bf7e3f20d4 | ||
|  | 902afcfbaf | ||
|  | 3ae92fa2e6 | ||
|  | 3906cd2149 | ||
|  | 5a1fb29db7 | ||
|  | 661fc4d3d1 | ||
|  | 41009cc142 | ||
|  | 37720c4db7 | ||
|  | 1a30455a10 | ||
|  | 97a6b61551 | ||
|  | cd0da81196 | ||
|  | f246fe3304 | ||
|  | 8a29c16bde | ||
|  | d68907fc3e | ||
|  | 5c0adf7bf2 | ||
|  | be3a8249c6 | ||
|  | bd600702cf | ||
|  | f011bdb869 | ||
|  | bafb101e4f | ||
|  | 08fdf05528 | ||
|  | aca7a3ef0a | ||
|  | 9e72a6b22e | ||
|  | 1c12c5612c | ||
|  | a8193c4bcb | ||
|  | c3d7ec65fa | ||
|  | 8b6a6c8236 | ||
|  | e0571c872b | ||
|  | c67f41887b | ||
|  | 84687ccf1f | ||
|  | 3274561cf8 | ||
| e08fbb3771 | |||
|  | d7464aa0fe | ||
|  | 00d29153f0 | ||
| 2ce989f220 | |||
|  | d7a1dc85be | ||
|  | fc19503673 | ||
|  | beba824136 | ||
|  | 6ebf8b12b6 | ||
|  | e5a7ed4362 | ||
|  | b9f7ea47c3 | ||
|  | 06f7ee202e | ||
|  | 2b2fc6453f | ||
|  | bdd2765461 | ||
|  | 2c246551d0 | ||
|  | 71ac2e7940 | ||
|  | 2bf4688e83 | ||
|  | a48ee6f0f2 | ||
|  | 73547cca66 | ||
|  | 123c673db7 | ||
|  | 61f82216e2 | ||
|  | 8e7ca92278 | ||
|  | 485ad6fde0 | ||
|  | 6ea2184e18 | ||
|  | fdc170b8a3 | ||
|  | 060da786e9 | ||
|  | 85c7bc4321 | ||
|  | 0883d6a7ce | ||
|  | 9ff97b4711 | ||
|  | b5e9c900a4 | ||
|  | 4bbdfb434c | ||
|  | 4a45c06dd7 | ||
|  | d6a7d7d1e0 | ||
|  | 1a122a0dd8 | ||
|  | 20e20733e8 | ||
|  | b7cd1a19e3 | ||
|  | f510002a62 | ||
|  | c94133af49 | ||
| eedcaf6470 | |||
| e7d8030a64 | |||
| d775fbb2f9 | |||
| 863855f46f | |||
| 419af7610d | |||
|  | 1e257a1251 | ||
|  | 522f6bf91a | ||
|  | d35d87d2c2 | ||
|  | 74a5cda84b | ||
|  | 5be05d85b8 | ||
|  | 35ac85aea8 | ||
|  | fa237401ff | ||
|  | 97053adcb5 | ||
|  | f8fbe4d7a3 | ||
|  | ef31c012bf | ||
| 7da7d263c4 | |||
| 1140573027 | |||
|  | 9e9f621d5d | ||
|  | 651e1a7cbc | ||
| a0cfbb6e88 | |||
|  | c4d3672720 | ||
| 515a26b3c6 | |||
|  | 16be6d378c | ||
|  | f05d0565aa | ||
| b39f0d1fb6 | |||
| 9f1267dfe6 | |||
| 2e90285232 | |||
| e254de982e | |||
| 28d99b5297 | |||
| c946d3bf3f | |||
| 1c68098780 | |||
|  | 9bf4108d1f | ||
|  | 899e685627 | ||
|  | ee93f0218b | ||
|  | 6929a84c70 | ||
|  | 5c779a789b | ||
| 161ed102a5 | |||
| 3bf993d81a | |||
| fad743fbb1 | |||
|  | e863a948e3 | ||
|  | f65a585236 | ||
|  | 977f34dca6 | ||
|  | 90ad956340 | ||
|  | 7996f06335 | ||
|  | ef8d3831eb | ||
|  | 70ed9fc40c | ||
|  | 7b40a3e3e5 | ||
| 4d3787db65 | |||
|  | 677757cfeb | ||
|  | f7fbbaaca3 | ||
|  | 17629b8d9e | ||
|  | 0baa20d292 | ||
|  | 4571c918a4 | ||
|  | 5251ea4d30 | ||
| 05cb6d318a | |||
| 0432e30256 | |||
| 2c3ebc1e07 | |||
| 068b28af2d | |||
| f7db342f49 | |||
| d65e81518f | |||
|  | 7f456b4173 | ||
| a37e71f362 | |||
|  | ae99e99da2 | ||
|  | c291ef77b5 | ||
|  | 7dd2764bb2 | ||
|  | 244f8fb6dc | ||
|  | 05c1924819 | ||
| f3ca29af6c | |||
| b7da264b0a | |||
| 37988221a8 | |||
| 74ac2aa676 | |||
| 4c75095c61 | |||
| afa095d33d | |||
| 6b5259cc10 | |||
|  | 27dfe816fa | ||
|  | af29be2c90 | ||
|  | f96fac0aee | ||
| 7423a352c5 | |||
| 81e66d6631 | |||
| ade1058e5f | |||
| 6eea9e4da7 | |||
| 2c673666da | |||
| 7a327a3f28 | |||
|  | 07f2ebea1b | ||
| d6401e6d2c | |||
| 24d3d31b01 | |||
|  | 851f2ad8ef | ||
| 5405526424 | |||
| f3f0b6fef9 | |||
| 654e0b0fd0 | |||
| 4be08ebccc | |||
| f599cb5b17 | |||
|  | 23e0561dd6 | ||
| a4a509497a | |||
| 5803933aea | |||
|  | 8ae1a95ec6 | ||
|  | 82b7d4eaf0 | ||
|  | 78774fbdc0 | ||
|  | 924130833e | ||
|  | 7cf833dfe9 | ||
|  | 0157274762 | ||
|  | 87e8aad5a0 | ||
|  | c6f59c2933 | ||
| 91a3534054 | |||
| 16a8e3d0d4 | |||
|  | b7f90aa011 | ||
| 92f8950a56 | |||
| 65987a8a58 | |||
| 889d828bc2 | |||
|  | f22b79da8f | ||
|  | 3855673ebf | ||
|  | 4db82da0db | ||
|  | 0cdc3d2fa5 | ||
| ad98b6193d | |||
| fc760016b3 | |||
| 2da86f7dae | |||
| 41df1db811 | |||
|  | 0dfda4bb90 | ||
|  | 1189ebc8b5 | ||
| 97843e2b58 | |||
| 82b3f54697 | |||
|  | 1bb8578173 | ||
|  | c3b6d573b9 | ||
| 673994b281 | |||
| bbc0eff078 | |||
| 4c60e31070 | |||
| afbf7d4c37 | |||
| 8c3cc32364 | |||
|  | 1e179c903d | ||
|  | 669cfca9b7 | ||
|  | ff2f559a57 | ||
|  | 03c81bd902 | ||
|  | a869addef1 | ||
|  | 1caa3fbc2d | ||
|  | 3d21297bbb | ||
|  | 25efefc5b4 | ||
|  | eabf316ed9 | ||
|  | 04ae7929a3 | ||
|  | caba0d42a5 | ||
|  | 9ae81c06d2 | ||
|  | 0903c48caa | ||
|  | 7dc36628a1 | ||
|  | b8cdb3e90a | ||
|  | 5241245534 | ||
|  | 960316e207 | ||
|  | 5214846341 | ||
| 4c3fd9fa3f | |||
| 17b3a10d46 | |||
| 149a46b92c | |||
| 3215ae6b7e | |||
| 7a85fddc7e | |||
|  | ce1a115e0b | ||
| db9c28a773 | |||
| 9ac3ac41df | |||
| 2af9ab9034 | |||
| 6f1ea96293 | |||
| f8d11ff673 | |||
|  | 3f2d53a994 | ||
|  | 8a337f3070 | ||
|  | a59f5374d7 | ||
|  | 4b220972ac | ||
|  | 629f43e36c | ||
|  | a3172b3455 | ||
|  | 3e6945cd65 | ||
|  | 87be03006a | ||
|  | f17436fec2 | ||
|  | 4d8b01b7ed | ||
|  | fa6acccf55 | ||
|  | 55cb22ad67 | ||
|  | df9108154d | ||
|  | b3e7f600da | ||
|  | d4071daf2a | ||
|  | a2a6329094 | ||
|  | eabc577940 | ||
| 2e3c5890b6 | |||
| bc6678732f | |||
| b10ae00c8a | |||
| 67d72000e7 | |||
| 80cef1c78f | |||
| 91e98b1dd5 | |||
| b791c274b0 | |||
| 596dd570c7 | |||
| cad158e42f | |||
| f63fac0c69 | |||
| ab92de89ab | |||
| 846272b037 | |||
| f3e49e4b73 | |||
| decbb61ec1 | |||
| 7e2482aad1 | |||
| e1653a9f94 | |||
| ea40854e0b | |||
| 34df71e755 | |||
| 3af663e17b | |||
|  | 0cd6b1858c | ||
|  | 0bd296dda4 | ||
|  | af0ccdd8e9 | ||
| c22c3db9ad | |||
| 013e710c7d | |||
| 16693bd69d | |||
| de8f80cf94 | |||
|  | 2fb92dbc6e | ||
|  | 5c74b6028b | ||
|  | e0be2b6e6c | ||
|  | ef72f322d2 | ||
|  | 426197e446 | ||
|  | 99e2c1e666 | ||
|  | 1440565a10 | ||
|  | e9f0c0ea39 | ||
|  | 7bc2065113 | ||
| 4a87486365 | |||
|  | fe187e9ed3 | ||
|  | 0091b50f49 | ||
|  | fb8d4b2357 | ||
|  | ff71a8e847 | ||
|  | 83fa038bdf | ||
|  | 7a61feb6d3 | ||
|  | 69ae817d1c | ||
|  | 2bd4233919 | ||
|  | 143c70e29f | ||
| 51322da6f8 | |||
| 49c3eeb378 | |||
| c56707e003 | |||
|  | b812d5e39c | ||
| 5b3edf08a4 | |||
| bd1d1cca34 | |||
| 646b11f5c2 | |||
| a683a0f55a | |||
| e6effcfd95 | |||
| aa016f61b9 | |||
| d42a1b73c4 | |||
| d292657ef7 | |||
| d1f7c6b94e | |||
| 7ae734103e | |||
|  | 01480da0a8 | ||
| 7a1ac45679 | |||
| 320268fe93 | |||
| dd6fb140c5 | |||
| 0b4f680d28 | |||
| a69086ba1f | |||
| 7433eed274 | |||
| ee5b1fe043 | |||
| 1540616b22 | |||
| 8190523e4c | |||
| b5555d85a7 | |||
|  | e27c6b217c | ||
| 9ad3d3453e | |||
|  | f7a6b8e5ed | ||
|  | 6adf35da54 | ||
| d8b716d2cd | |||
|  | cd01c1dbe9 | ||
|  | 6ad73145bc | ||
|  | bd0430b34f | ||
|  | c097fd041a | ||
|  | 77fb25fb29 | ||
|  | 389e0a77bd | ||
|  | 2f92b4860b | ||
|  | 4704f2d009 | ||
|  | ae9688e343 | ||
| 43928846f2 | |||
| fabcd4179d | |||
| a8843c9af6 | |||
| 7a1a7a685e | |||
|  | 1e44fd3094 | ||
|  | d8258f0758 | ||
|  | 6c0cc5676b | ||
| f7293f2ddb | |||
| 11dc0b398b | |||
|  | b18950f776 | ||
|  | 0acbf77bc6 | ||
| 3cdf945d84 | |||
| 5833f247fa | |||
|  | 95f43d27ae | ||
|  | 668ca57702 | ||
| a2cffb0304 | |||
| bafbac6ac4 | |||
| 595f1ce371 | |||
| 6d7cde4eb4 | |||
| 97cddda49e | |||
| 433afd36f5 | |||
| b873504b90 | |||
|  | 62749d05a6 | ||
|  | 3834feb4b7 | ||
|  | 6b8ee7bae0 | ||
|  | 739c2308b5 | ||
|  | 454302414d | ||
| 042ae5b87c | |||
|  | a71b69389b | ||
|  | d49e502f53 | ||
|  | 92ec3404f8 | ||
|  | f4ebea3381 | ||
|  | cf167d0cd1 | ||
|  | 6f8b771a37 | ||
|  | 4e1ffdd17c | ||
| 1aa695cd78 | |||
|  | a783282b8b | ||
|  | 19b85d8486 | ||
|  | 58f4950652 | ||
|  | c363bdd784 | ||
|  | 604f0ea2f6 | ||
|  | 42c912f608 | ||
|  | 33dc1f51b5 | ||
|  | c30d96ea50 | ||
| 13a8997789 | |||
| 9576f0903d | |||
| 34cf702b24 | |||
| 8a5e3a917c | |||
| 65bcf281d0 | |||
| cd0be8cb24 | |||
| 3d2a22a14d | |||
|  | 7ffe17ada1 | ||
| a26adfb090 | |||
| f6e1a5b348 | |||
| c5a025d421 | |||
|  | 50d277d8d9 | ||
|  | 343f3e829f | ||
|  | f85b35314d | ||
|  | 3dc2e05d6e | ||
|  | 0cff8754d1 | ||
|  | afc8d3e524 | ||
|  | 692b44dac1 | ||
|  | 96ba42a297 | ||
| 7df940dc3e | |||
|  | f7b60004f3 | ||
| 8af8b047fd | |||
| 6592078fef | |||
| ad971ca07b | |||
| f2f16eb972 | |||
|  | b7d55f7dfb | ||
|  | 6e548a8ad5 | ||
|  | ee686a7d85 | ||
|  | 1c5b7a6be5 | ||
| a5dd4a9bab | |||
| ec232af851 | |||
| 17e30281e9 | |||
| 2854e601e6 | |||
| aee44dc694 | |||
| 75bbf6a0af | |||
| c65d23935a | |||
| 92cd797636 | |||
|  | 111bfbc6bc | ||
|  | f41a230b32 | ||
|  | c067051d5f | ||
|  | afdeb2b13c | ||
|  | 9e2ec2719b | ||
|  | 757a928f9a | ||
|  | bc248b6948 | ||
|  | ae8561892e | ||
|  | 32375aca65 | ||
|  | bb94ddd0eb | ||
| 330a9b3f4c | |||
| c2d78493c8 | |||
|  | 28ff66a381 | ||
|  | 78c7bcee36 | ||
|  | 7f0fc0eff5 | ||
|  | 164d3691db | ||
|  | 791cb050c8 | ||
| 00a7b95631 | |||
| 94d8321d01 | |||
| d5e95bc350 | |||
| 6efac3a252 | |||
| 7a84906b5f | |||
| 07416e4567 | |||
| 66d832c733 | |||
| e74417ca12 | |||
| 7bd0084b5d | |||
|  | e8c3174ae2 | ||
|  | 9b066e94d0 | ||
|  | ac24cc9f99 | ||
|  | 618abdf302 | ||
|  | e1042aef77 | ||
|  | aa6a839c60 | ||
| ac99a56237 | |||
| b4d2af8c89 | |||
| 434af6aeaa | |||
| e90f8ac841 | |||
| a1705a8d53 | |||
| ca21003f01 | |||
| 14ddf2c234 | |||
|  | 1d666771f9 | ||
|  | d50055cd96 | ||
|  | bca861e112 | ||
|  | 3ab4c8c0bb | ||
| 33d199a0ad | |||
|  | 93896ce59e | ||
|  | b1508e4124 | ||
|  | b820076b91 | ||
|  | 09f66100d3 | ||
|  | d7d92af09d | ||
|  | 460d0753a1 | ||
|  | 8f8058f8a5 | ||
|  | d97a27f483 | ||
|  | 7c3363b91e | ||
|  | b94478fa51 | ||
|  | 47c7159177 | ||
| 13bf0482e3 | |||
| a795b5705e | |||
| 392e064513 | |||
|  | b6a65059a2 | ||
|  | f415db583a | ||
|  | f55c16f984 | ||
|  | ea25a4d9ac | ||
|  | c190221fd3 | ||
|  | df67e013ca | ||
|  | 3e990c9d0a | ||
|  | 4b740fc8fd | ||
|  | 0fcd2e7188 | ||
|  | 910b8dd6a1 | ||
|  | 75ebd3a0d1 | ||
|  | cccd14b09e | ||
|  | e6acffdfc2 | ||
| 26d124283e | |||
| 0d889b7041 | |||
| 7c8f79b147 | |||
|  | 09fd5c43a7 | ||
| ab31ad006a | |||
| 462921e549 | |||
|  | 392130a537 | ||
|  | f22317748f | ||
|  | 6a9eae6b6b | ||
|  | fad96cf250 | ||
|  | f331809c27 | ||
| bd6a228af6 | |||
| 63d219498b | |||
|  | 2c54a53d0a | ||
|  | 306160ad9a | ||
|  | 20a091c3ed | ||
|  | 202078eb1b | ||
|  | a762b1fb71 | ||
|  | deef2673b2 | ||
|  | 5b5925b8e5 | ||
|  | 977b0a6dd9 | ||
|  | 977d844394 | ||
|  | b58adc6a4b | ||
|  | f9d5e95d72 | ||
|  | 4f8e636a43 | ||
|  | 9b39f35ae6 | ||
|  | 5fe2b85cbd | ||
|  | c7cccaaa69 | ||
|  | cbcfea466f | ||
|  | 4955672fc3 | ||
|  | 39f1c880b8 | ||
|  | 8c043da5b7 | ||
|  | 3cbe974eb4 | ||
| 6e4a06e180 | |||
| 997fd882ff | |||
|  | 590675e2ca | ||
|  | 8c65bdf6d3 | ||
|  | 74f1ed3bc5 | ||
|  | 79270ef510 | ||
|  | e250e6b7bb | ||
|  | 261342c15f | ||
|  | a123dcd7e9 | ||
|  | 6b27c42dfe | ||
|  | f7c2aa3ba5 | ||
|  | eda4dd622e | ||
|  | 6e01264bb7 | ||
|  | 6f408256bc | ||
|  | 8d11681aac | ||
|  | 3d5c9a1ee9 | ||
|  | db749f103f | ||
|  | dc389e467c | ||
|  | 3619167d62 | ||
|  | 96f1d1b828 | ||
|  | 657e0a8f4d | ||
|  | 616e7cd83e | ||
|  | 6f26d2e8d4 | ||
|  | c014574504 | ||
|  | d7ce164e6e | ||
|  | c0d5b99016 | ||
|  | 09ca32d678 | ||
|  | 082ae350c6 | ||
|  | c68a2b9637 | ||
|  | 293df6cd20 | ||
|  | 65f61bb3bf | ||
|  | 26b9740d53 | ||
| cb02b7088f | |||
|  | 6eb873dd96 | ||
|  | 11b4c80b27 | ||
|  | c065e454c3 | ||
|  | d9b5fbd374 | ||
|  | cfbc1a26b8 | ||
|  | 257f69f931 | ||
|  | e415260961 | ||
|  | 87acd06990 | ||
|  | 9353b6edfe | ||
|  | 167cc2650e | ||
|  | 34f887ca1c | ||
|  | 7089b6d5a5 | ||
|  | 2ba7d43ddd | ||
|  | 836e929565 | ||
|  | b6713ecb60 | ||
|  | 52a39f0fcd | ||
|  | 81a7a03076 | ||
|  | 16b37b956c | ||
|  | 567b6cf23f | ||
|  | 296396646d | ||
| a034e9901b | |||
|  | 7422953e36 | ||
|  | 8535d433a7 | ||
|  | b573d1f35a | ||
|  | 0c1d7e4daf | ||
|  | 02e983a0cd | ||
|  | d15ab66aae | ||
|  | 9005b82c6d | ||
|  | 3475f45ce7 | ||
|  | 0744f38866 | ||
|  | 62febd2823 | ||
| 17c843700e | |||
| 7b56f63a5c | |||
| b1cfb4d661 | |||
| 7ff7c7d90d | |||
| a2e9430abe | |||
| 2485ef9c9c | |||
|  | 446c768cd3 | ||
| e0b7004f96 | |||
| 75fc295f6e | |||
| 0b731b5d80 | |||
| 8e2078be71 | |||
| 1826ed06a3 | |||
| 3ff96c502b | |||
| 15a0908bfc | |||
| bb2125962b | |||
| 232fda5fe1 | |||
| 2b31bf61ff | |||
| afe5a94745 | |||
| 7ae667c767 | |||
| 07f0b69784 | |||
| 5c06e89d69 | |||
| 3d75e0f0d1 | |||
| 362f255100 | |||
| 3d78ed03ef | |||
| 835003b3c5 | |||
| 328d213c9e | |||
| 56a8d7a5bc | |||
| 78198d1b04 | |||
| 84fa2bdce6 | |||
| 29dfe99e7c | |||
| d604580e5a | |||
| 7dfdc9baa0 | |||
| 9e986654e6 | |||
| df3fbc477e | |||
| bb580ae077 | |||
| 2c226753ab | |||
| ea0cea668e | |||
| 75cd72a421 | |||
| cbe52b0659 | |||
| 3aa6463ede | |||
| 312637e5fb | |||
| 798d8f7340 | |||
| ba878724ce | |||
| b865dd9da8 | |||
| 8b313a35ac | |||
| 02ec23cdad | |||
| 6e83b6a203 | |||
| 48fcc34d72 | |||
| d08d93c44c | |||
| 0ab10cdedb | |||
| 22653edf12 | |||
| 12d2a95846 | |||
| 978cf52f6b | |||
| 63b730de80 | |||
| 7905c5b8e5 | |||
| 5e4b58ac40 | |||
| 468d8dc682 | |||
| beb11fd4ef | |||
| d7662b5175 | |||
| dc5f32e5f0 | |||
| 1869d28429 | |||
| 405b175665 | |||
| e33b0f6ff7 | |||
| 9ee54e0db7 | |||
| feae35d92c | |||
| 3834d81181 | |||
| 179e82b5ca | |||
| f2c59c8730 | |||
| fdd0848593 | |||
| 92f666905f | |||
| 5980fa8640 | |||
| a0d8eb2c24 | |||
| 1e10b4571d | |||
| 02f8b84ac9 | |||
| cfd368596d | |||
| ae682674e0 | |||
| 17c43f49ac | |||
| 30146e977c | |||
| 54eacec261 | |||
| 76c78f04e2 | |||
| 379580cd89 | |||
| 14a80733f9 | |||
| d4db009a58 | |||
| 20ce7e0270 | |||
| bb195607ab | |||
| 6f090e22c0 | |||
| 339e983172 | |||
| 4a7f3d1b7b | |||
| c4e2202550 | |||
| 538b16610b | 
							
								
								
									
										32
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -9,6 +9,7 @@ | ||||
| ################ | ||||
| *~ | ||||
| *# | ||||
| *.sublime-* | ||||
|  | ||||
| # Precompiled Headers # | ||||
| ####################### | ||||
| @@ -47,7 +48,9 @@ Config.h.in | ||||
| config.log | ||||
| config.status | ||||
| .deps | ||||
| *.inc | ||||
| Make.inc | ||||
| eigen.inc | ||||
| Eigen.inc | ||||
|  | ||||
| # http://www.gnu.org/software/autoconf # | ||||
| ######################################## | ||||
| @@ -89,6 +92,8 @@ build*/* | ||||
| ##################### | ||||
| *.xcodeproj/* | ||||
| build.sh | ||||
| .vscode | ||||
| *.code-workspace | ||||
|  | ||||
| # Eigen source # | ||||
| ################ | ||||
| @@ -101,4 +106,27 @@ lib/fftw/* | ||||
| # libtool macros # | ||||
| ################## | ||||
| m4/lt* | ||||
| m4/libtool.m4 | ||||
| m4/libtool.m4 | ||||
|  | ||||
| # github pages # | ||||
| ################ | ||||
| gh-pages/ | ||||
|  | ||||
| # Buck files # | ||||
| ############## | ||||
| .buck* | ||||
| buck-out | ||||
| BUCK | ||||
| make-bin-BUCK.sh | ||||
|  | ||||
| # generated sources # | ||||
| ##################### | ||||
| lib/qcd/spin/gamma-gen/*.h | ||||
| lib/qcd/spin/gamma-gen/*.cc | ||||
| lib/version.h | ||||
|  | ||||
| # vs code editor files # | ||||
| ######################## | ||||
| .vscode/ | ||||
| .vscode/settings.json | ||||
| settings.json | ||||
|   | ||||
							
								
								
									
										92
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										92
									
								
								.travis.yml
									
									
									
									
									
								
							| @@ -7,64 +7,8 @@ cache: | ||||
| matrix: | ||||
|   include: | ||||
|     - os:        osx | ||||
|       osx_image: xcode7.2 | ||||
|       osx_image: xcode8.3 | ||||
|       compiler: clang | ||||
|     - compiler: gcc | ||||
|       addons: | ||||
|         apt: | ||||
|           sources: | ||||
|             - ubuntu-toolchain-r-test | ||||
|           packages: | ||||
|             - g++-4.9 | ||||
|             - libmpfr-dev | ||||
|             - libgmp-dev | ||||
|             - libmpc-dev | ||||
|             - libopenmpi-dev | ||||
|             - openmpi-bin | ||||
|             - binutils-dev | ||||
|       env: VERSION=-4.9 | ||||
|     - compiler: gcc | ||||
|       addons: | ||||
|         apt: | ||||
|           sources: | ||||
|             - ubuntu-toolchain-r-test | ||||
|           packages: | ||||
|             - g++-5 | ||||
|             - libmpfr-dev | ||||
|             - libgmp-dev | ||||
|             - libmpc-dev | ||||
|             - libopenmpi-dev | ||||
|             - openmpi-bin | ||||
|             - binutils-dev | ||||
|       env: VERSION=-5 | ||||
|     - compiler: clang | ||||
|       addons: | ||||
|         apt: | ||||
|           sources: | ||||
|             - ubuntu-toolchain-r-test | ||||
|           packages: | ||||
|             - g++-4.8 | ||||
|             - libmpfr-dev | ||||
|             - libgmp-dev | ||||
|             - libmpc-dev | ||||
|             - libopenmpi-dev | ||||
|             - openmpi-bin | ||||
|             - binutils-dev | ||||
|       env: CLANG_LINK=http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | ||||
|     - compiler: clang | ||||
|       addons: | ||||
|         apt: | ||||
|           sources: | ||||
|             - ubuntu-toolchain-r-test | ||||
|           packages: | ||||
|             - g++-4.8 | ||||
|             - libmpfr-dev | ||||
|             - libgmp-dev | ||||
|             - libmpc-dev | ||||
|             - libopenmpi-dev | ||||
|             - openmpi-bin | ||||
|             - binutils-dev | ||||
|       env: CLANG_LINK=http://llvm.org/releases/3.7.0/clang+llvm-3.7.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | ||||
|        | ||||
| before_install: | ||||
|     - export GRIDDIR=`pwd` | ||||
| @@ -73,13 +17,17 @@ before_install: | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CC" == "clang" ]]; then export LD_LIBRARY_PATH="${GRIDDIR}/clang/lib:${LD_LIBRARY_PATH}"; fi | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libmpc; fi | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openmpi; fi | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc5; fi | ||||
|      | ||||
| install: | ||||
|     - export CWD=`pwd` | ||||
|     - echo $CWD | ||||
|     - export CC=$CC$VERSION | ||||
|     - export CXX=$CXX$VERSION | ||||
|     - echo $PATH | ||||
|     - which autoconf | ||||
|     - autoconf  --version | ||||
|     - which automake | ||||
|     - automake  --version | ||||
|     - which $CC | ||||
|     - $CC  --version | ||||
|     - which $CXX | ||||
| @@ -90,17 +38,23 @@ script: | ||||
|     - ./bootstrap.sh | ||||
|     - mkdir build | ||||
|     - cd build | ||||
|     - ../configure --enable-precision=single --enable-simd=SSE4 --enable-comms=none | ||||
|     - mkdir lime | ||||
|     - cd lime | ||||
|     - mkdir build | ||||
|     - cd build | ||||
|     - wget http://usqcd-software.github.io/downloads/c-lime/lime-1.3.2.tar.gz | ||||
|     - tar xf lime-1.3.2.tar.gz | ||||
|     - cd lime-1.3.2 | ||||
|     - ./configure --prefix=$CWD/build/lime/install | ||||
|     - make -j4 | ||||
|     - make install | ||||
|     - cd $CWD/build | ||||
|     - ../configure --enable-precision=single --enable-simd=SSE4 --enable-comms=none --with-lime=$CWD/build/lime/install | ||||
|     - make -j4  | ||||
|     - ./benchmarks/Benchmark_dwf --threads 1 | ||||
|     - ./benchmarks/Benchmark_dwf --threads 1 --debug-signals | ||||
|     - echo make clean | ||||
|     - ../configure --enable-precision=double --enable-simd=SSE4 --enable-comms=none | ||||
|     - ../configure --enable-precision=double --enable-simd=SSE4 --enable-comms=none --with-lime=$CWD/build/lime/install | ||||
|     - make -j4 | ||||
|     - ./benchmarks/Benchmark_dwf --threads 1 | ||||
|     - echo make clean | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXXFLAGS='-DMPI_UINT32_T=MPI_UNSIGNED -DMPI_UINT64_T=MPI_UNSIGNED_LONG'; fi | ||||
|     - ../configure --enable-precision=single --enable-simd=SSE4 --enable-comms=mpi-auto | ||||
|     - make -j4 | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mpirun.openmpi -n 2 ./benchmarks/Benchmark_dwf --threads 1 --mpi 2.1.1.1; fi | ||||
|     - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mpirun -n 2 ./benchmarks/Benchmark_dwf --threads 1 --mpi 2.1.1.1; fi | ||||
|     - ./benchmarks/Benchmark_dwf --threads 1 --debug-signals | ||||
|     - make check | ||||
|  | ||||
|   | ||||
							
								
								
									
										18
									
								
								Makefile.am
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								Makefile.am
									
									
									
									
									
								
							| @@ -1,5 +1,21 @@ | ||||
| # additional include paths necessary to compile the C++ library | ||||
| SUBDIRS = lib benchmarks tests | ||||
| SUBDIRS = lib benchmarks tests extras | ||||
|  | ||||
| include $(top_srcdir)/doxygen.inc | ||||
|  | ||||
| bin_SCRIPTS=grid-config | ||||
|  | ||||
| BUILT_SOURCES = version.h | ||||
|  | ||||
| version.h: | ||||
| 	echo "`git log -n 1 --format=format:"#define GITHASH \\"%H:%d\\"%n" HEAD`" > $(srcdir)/lib/version.h | ||||
|  | ||||
| .PHONY: bench check tests doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL) | ||||
|  | ||||
| tests-local: all | ||||
| bench-local: all | ||||
| check-local: all | ||||
|  | ||||
| AM_CXXFLAGS += -I$(top_builddir)/include | ||||
|  | ||||
| ACLOCAL_AMFLAGS = -I m4 | ||||
|   | ||||
							
								
								
									
										44
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								README
									
									
									
									
									
								
							| @@ -1,44 +0,0 @@ | ||||
| This library provides data parallel C++ container classes with internal memory layout | ||||
| that is transformed to map efficiently to SIMD architectures. CSHIFT facilities | ||||
| are provided, similar to HPF and cmfortran, and user control is given over the mapping of | ||||
| array indices to both MPI tasks and SIMD processing elements. | ||||
|  | ||||
| * Identically shaped arrays then be processed with perfect data parallelisation. | ||||
| * Such identically shapped arrays are called conformable arrays. | ||||
|  | ||||
| The transformation is based on the observation that Cartesian array processing involves | ||||
| identical processing to be performed on different regions of the Cartesian array. | ||||
|  | ||||
| The library will (eventually) both geometrically decompose into MPI tasks and across SIMD lanes. | ||||
|  | ||||
| Data parallel array operations can then be specified with a SINGLE data parallel paradigm, but | ||||
| optimally use MPI, OpenMP and SIMD parallelism under the hood. This is a significant simplification | ||||
| for most programmers. | ||||
|  | ||||
| The layout transformations are parametrised by the SIMD vector length. This adapts according to the architecture. | ||||
| Presently SSE2 (128 bit) AVX, AVX2 (256 bit) and IMCI and AVX512 (512 bit) targets are supported. | ||||
|  | ||||
| These are presented as  | ||||
|  | ||||
|   vRealF, vRealD, vComplexF, vComplexD  | ||||
|  | ||||
| internal vector data types. These may be useful in themselves for other programmers. | ||||
| The corresponding scalar types are named | ||||
|  | ||||
|   RealF, RealD, ComplexF, ComplexD | ||||
|  | ||||
| MPI parallelism is UNIMPLEMENTED and for now only OpenMP and SIMD parallelism is present in the library. | ||||
|  | ||||
|    You can give `configure' initial values for configuration parameters | ||||
| by setting variables in the command line or in the environment.  Here | ||||
| is are examples: | ||||
|  | ||||
|      ./configure CXX=clang++ CXXFLAGS="-std=c++11 -O3 -msse4" --enable-simd=SSE4 | ||||
|  | ||||
|      ./configure CXX=clang++ CXXFLAGS="-std=c++11 -O3 -mavx" --enable-simd=AVX1 | ||||
|  | ||||
|      ./configure CXX=clang++ CXXFLAGS="-std=c++11 -O3 -mavx2" --enable-simd=AVX2 | ||||
|  | ||||
|      ./configure CXX=icpc CXXFLAGS="-std=c++11 -O3 -mmic" --enable-simd=AVX512 --host=none | ||||
|       | ||||
|       | ||||
							
								
								
									
										367
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										367
									
								
								README.md
									
									
									
									
									
								
							| @@ -1,26 +1,14 @@ | ||||
| # Grid | ||||
| <table> | ||||
| <tr> | ||||
|     <td>Last stable release</td> | ||||
|     <td><a href="https://travis-ci.org/paboyle/Grid"> | ||||
|     <img src="https://travis-ci.org/paboyle/Grid.svg?branch=master"></a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td>Development branch</td> | ||||
|     <td><a href="https://travis-ci.org/paboyle/Grid"> | ||||
|     <img src="https://travis-ci.org/paboyle/Grid.svg?branch=develop"></a> | ||||
|     </td> | ||||
| </tr> | ||||
| </table> | ||||
| # Grid [),branch:name:develop)/statusIcon.svg)](http://ci.cliath.ph.ed.ac.uk/project.html?projectId=Grid&tab=projectOverview) [](https://travis-ci.org/paboyle/Grid) | ||||
|  | ||||
| **Data parallel C++ mathematical object library.** | ||||
|  | ||||
| Please send all pull requests to the `develop` branch. | ||||
|  | ||||
| License: GPL v2. | ||||
|  | ||||
| Last update 2016/08/03. | ||||
| Last update June 2017. | ||||
|  | ||||
| _Please do not send pull requests to the `master` branch which is reserved for releases._ | ||||
|  | ||||
|  | ||||
|  | ||||
| ### Description | ||||
| This library provides data parallel C++ container classes with internal memory layout | ||||
| @@ -29,7 +17,7 @@ are provided, similar to HPF and cmfortran, and user control is given over the m | ||||
| array indices to both MPI tasks and SIMD processing elements. | ||||
|  | ||||
| * Identically shaped arrays then be processed with perfect data parallelisation. | ||||
| * Such identically shapped arrays are called conformable arrays. | ||||
| * Such identically shaped arrays are called conformable arrays. | ||||
|  | ||||
| The transformation is based on the observation that Cartesian array processing involves | ||||
| identical processing to be performed on different regions of the Cartesian array. | ||||
| @@ -42,15 +30,70 @@ optimally use MPI, OpenMP and SIMD parallelism under the hood. This is a signifi | ||||
| for most programmers. | ||||
|  | ||||
| The layout transformations are parametrised by the SIMD vector length. This adapts according to the architecture. | ||||
| Presently SSE4 (128 bit) AVX, AVX2 (256 bit) and IMCI and AVX512 (512 bit) targets are supported (ARM NEON and BG/Q QPX on the way). | ||||
| Presently SSE4, ARM NEON (128 bits) AVX, AVX2, QPX (256 bits), IMCI and AVX512 (512 bits) targets are supported. | ||||
|  | ||||
| These are presented as `vRealF`, `vRealD`, `vComplexF`, and `vComplexD` internal vector data types. These may be useful in themselves for other programmers. | ||||
| These are presented as `vRealF`, `vRealD`, `vComplexF`, and `vComplexD` internal vector data types.  | ||||
| The corresponding scalar types are named `RealF`, `RealD`, `ComplexF` and `ComplexD`. | ||||
|  | ||||
| MPI, OpenMP, and SIMD parallelism are present in the library. | ||||
| Please see https://arxiv.org/abs/1512.03487 for more detail. | ||||
| Please see [this paper](https://arxiv.org/abs/1512.03487) for more detail. | ||||
|  | ||||
| ### Installation | ||||
|  | ||||
| ### Compilers | ||||
|  | ||||
| Intel ICPC v16.0.3 and later | ||||
|  | ||||
| Clang v3.5 and later (need 3.8 and later for OpenMP) | ||||
|  | ||||
| GCC   v4.9.x (recommended) | ||||
|  | ||||
| GCC   v6.3 and later | ||||
|  | ||||
| ### Important:  | ||||
|  | ||||
| Some versions of GCC appear to have a bug under high optimisation (-O2, -O3). | ||||
|  | ||||
| The safety of these compiler versions cannot be guaranteed at this time. Follow Issue 100 for details and updates. | ||||
|  | ||||
| GCC   v5.x | ||||
|  | ||||
| GCC   v6.1, v6.2 | ||||
|  | ||||
| ### Bug report | ||||
|  | ||||
| _To help us tracking and solving more efficiently issues with Grid, please report problems using the issue system of GitHub rather than sending emails to Grid developers._ | ||||
|  | ||||
| When you file an issue, please go though the following checklist: | ||||
|  | ||||
| 1. Check that the code is pointing to the `HEAD` of `develop` or any commit in `master` which is tagged with a version number.  | ||||
| 2. Give a description of the target platform (CPU, network, compiler). Please give the full CPU part description, using for example `cat /proc/cpuinfo | grep 'model name' | uniq` (Linux) or `sysctl machdep.cpu.brand_string` (macOS) and the full output the `--version` option of your compiler. | ||||
| 3. Give the exact `configure` command used. | ||||
| 4. Attach `config.log`. | ||||
| 5. Attach `grid.config.summary`. | ||||
| 6. Attach the output of `make V=1`. | ||||
| 7. Describe the issue and any previous attempt to solve it. If relevant, show how to reproduce the issue using a minimal working example. | ||||
|  | ||||
| ### Required libraries | ||||
| Grid requires: | ||||
|  | ||||
| [GMP](https://gmplib.org/),  | ||||
|  | ||||
| [MPFR](http://www.mpfr.org/)  | ||||
|  | ||||
| Bootstrapping grid downloads and uses for internal dense matrix (non-QCD operations) the Eigen library. | ||||
|  | ||||
| Grid optionally uses: | ||||
|  | ||||
| [HDF5](https://support.hdfgroup.org/HDF5/)   | ||||
|  | ||||
| [LIME](http://usqcd-software.github.io/c-lime/) for ILDG and SciDAC file format support.  | ||||
|  | ||||
| [FFTW](http://www.fftw.org) either generic version or via the Intel MKL library. | ||||
|  | ||||
| LAPACK either generic version or Intel MKL library. | ||||
|  | ||||
|  | ||||
| ### Quick start | ||||
| First, start by cloning the repository: | ||||
|  | ||||
| ``` bash | ||||
| @@ -71,20 +114,18 @@ mkdir build; cd build | ||||
| ../configure --enable-precision=double --enable-simd=AVX --enable-comms=mpi-auto --prefix=<path> | ||||
| ``` | ||||
|  | ||||
| where `--enable-precision=` set the default precision (`single` or `double`), | ||||
| `--enable-simd=` set the SIMD type (see possible values below), `--enable- | ||||
| comms=` set the protocol used for communications (`none`, `mpi`, `mpi-auto` or | ||||
| `shmem`), and `<path>` should be replaced by the prefix path where you want to | ||||
| install Grid. The `mpi-auto` communication option set `configure` to determine | ||||
| automatically how to link to MPI. Other options are available, use `configure | ||||
| where `--enable-precision=` set the default precision, | ||||
| `--enable-simd=` set the SIMD type, `--enable- | ||||
| comms=`, and `<path>` should be replaced by the prefix path where you want to | ||||
| install Grid. Other options are detailed in the next section, you can also use `configure | ||||
| --help` to display them. Like with any other program using GNU autotool, the | ||||
| `CXX`, `CXXFLAGS`, `LDFLAGS`, ... environment variables can be modified to | ||||
| customise the build. | ||||
|  | ||||
| Finally, you can build and install Grid: | ||||
| Finally, you can build, check, and install Grid: | ||||
|  | ||||
| ``` bash | ||||
| make; make install | ||||
| make; make check; make install | ||||
| ``` | ||||
|  | ||||
| To minimise the build time, only the tests at the root of the `tests` directory are built by default. If you want to build tests in the sub-directory `<subdir>` you can execute: | ||||
| @@ -92,25 +133,275 @@ To minimise the build time, only the tests at the root of the `tests` directory | ||||
| ``` bash | ||||
| make -C tests/<subdir> tests | ||||
| ``` | ||||
| If you want to build all the tests at once just use `make tests`. | ||||
|  | ||||
| ### Build configuration options | ||||
|  | ||||
| - `--prefix=<path>`: installation prefix for Grid. | ||||
| - `--with-gmp=<path>`: look for GMP in the UNIX prefix `<path>` | ||||
| - `--with-mpfr=<path>`: look for MPFR in the UNIX prefix `<path>` | ||||
| - `--with-fftw=<path>`: look for FFTW in the UNIX prefix `<path>` | ||||
| - `--enable-lapack[=<path>]`: enable LAPACK support in Lanczos eigensolver. A UNIX prefix containing the library can be specified (optional). | ||||
| - `--enable-mkl[=<path>]`: use Intel MKL for FFT (and LAPACK if enabled) routines. A UNIX prefix containing the library can be specified (optional). | ||||
| - `--enable-numa`: enable NUMA first touch optimisation | ||||
| - `--enable-simd=<code>`: setup Grid for the SIMD target `<code>` (default: `GEN`). A list of possible SIMD targets is detailed in a section below. | ||||
| - `--enable-gen-simd-width=<size>`: select the size (in bytes) of the generic SIMD vector type (default: 32 bytes). | ||||
| - `--enable-precision={single|double}`: set the default precision (default: `double`). | ||||
| - `--enable-precision=<comm>`: Use `<comm>` for message passing (default: `none`). A list of possible SIMD targets is detailed in a section below. | ||||
| - `--enable-rng={sitmo|ranlux48|mt19937}`: choose the RNG (default: `sitmo `). | ||||
| - `--disable-timers`: disable system dependent high-resolution timers. | ||||
| - `--enable-chroma`: enable Chroma regression tests. | ||||
| - `--enable-doxygen-doc`: enable the Doxygen documentation generation (build with `make doxygen-doc`) | ||||
|  | ||||
| ### Possible communication interfaces | ||||
|  | ||||
| The following options can be use with the `--enable-comms=` option to target different communication interfaces: | ||||
|  | ||||
| | `<comm>`       | Description                                                   | | ||||
| | -------------- | ------------------------------------------------------------- | | ||||
| | `none`         | no communications                                             | | ||||
| | `mpi[-auto]`   | MPI communications                                            | | ||||
| | `mpi3[-auto]`  | MPI communications using MPI 3 shared memory                  | | ||||
| | `shmem `       | Cray SHMEM communications                                     | | ||||
|  | ||||
| For the MPI interfaces the optional `-auto` suffix instructs the `configure` scripts to determine all the necessary compilation and linking flags. This is done by extracting the informations from the MPI wrapper specified in the environment variable `MPICXX` (if not specified `configure` will scan though a list of default names). The `-auto` suffix is not supported by the Cray environment wrapper scripts. Use the standard versions instead.   | ||||
|  | ||||
| ### Possible SIMD types | ||||
|  | ||||
| The following options can be use with the `--enable-simd=` option to target different SIMD instruction sets: | ||||
|  | ||||
| | String      | Description                            | | ||||
| | `<code>`    | Description                            | | ||||
| | ----------- | -------------------------------------- | | ||||
| | `GEN`       | generic portable vector code           | | ||||
| | `SSE4`      | SSE 4.2 (128 bit)                      | | ||||
| | `AVX`       | AVX (256 bit)                          | | ||||
| | `AVXFMA4`   | AVX (256 bit) + FMA                    | | ||||
| | `AVXFMA`    | AVX (256 bit) + FMA                    | | ||||
| | `AVXFMA4`   | AVX (256 bit) + FMA4                   | | ||||
| | `AVX2`      | AVX 2 (256 bit)                        | | ||||
| | `AVX512`    | AVX 512 bit                            | | ||||
| | `AVX512MIC` | AVX 512 bit for Intel MIC architecture | | ||||
| | `ICMI`      | Intel ICMI instructions (512 bit)      | | ||||
| | `NEONv8`    | [ARM NEON](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch07s03.html) (128 bit)                     | | ||||
| | `QPX`       | IBM QPX (256 bit)                      | | ||||
|  | ||||
| Alternatively, some CPU codenames can be directly used: | ||||
|  | ||||
| | String      | Description                            | | ||||
| | `<code>`    | Description                            | | ||||
| | ----------- | -------------------------------------- | | ||||
| | `KNC`       | [Intel Knights Corner](http://ark.intel.com/products/codename/57721/Knights-Corner) | | ||||
| | `KNL`       | [Intel Knights Landing](http://ark.intel.com/products/codename/48999/Knights-Landing) | | ||||
| | `KNL`       | [Intel Xeon Phi codename Knights Landing](http://ark.intel.com/products/codename/48999/Knights-Landing) | | ||||
| | `SKL`       | [Intel Skylake with AVX512 extensions](https://ark.intel.com/products/codename/37572/Skylake#@server) | | ||||
| | `BGQ`       | Blue Gene/Q                            | | ||||
|  | ||||
| #### Notes: | ||||
| - We currently support AVX512 for the Intel compiler and GCC (KNL and SKL target). Support for clang will appear in future versions of Grid when the AVX512 support in the compiler will be more advanced. | ||||
| - For BG/Q only [bgclang](http://trac.alcf.anl.gov/projects/llvm-bgq) is supported. We do not presently plan to support more compilers for this platform. | ||||
| - BG/Q performances are currently rather poor. This is being investigated for future versions. | ||||
| - The vector size for the `GEN` target can be specified with the `configure` script option `--enable-gen-simd-width`. | ||||
|  | ||||
| ### Build setup for Intel Knights Landing platform | ||||
|  | ||||
| The following configuration is recommended for the Intel Knights Landing platform: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=KNL        \ | ||||
|              --enable-comms=mpi-auto  \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=icpc MPICXX=mpiicpc | ||||
| ``` | ||||
| The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library. | ||||
|  | ||||
| If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=KNL        \ | ||||
|              --enable-comms=mpi       \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=CC CC=cc | ||||
| ``` | ||||
|  | ||||
| If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed: | ||||
| ``` bash | ||||
|                --with-gmp=<path>        \ | ||||
|                --with-mpfr=<path>       \ | ||||
| ``` | ||||
| where `<path>` is the UNIX prefix where GMP and MPFR are installed.  | ||||
|  | ||||
| Knight's Landing with Intel Omnipath adapters with two adapters per node  | ||||
| presently performs better with use of more than one rank per node, using shared memory  | ||||
| for interior communication. This is the mpi3 communications implementation.  | ||||
| We recommend four ranks per node for best performance, but optimum is local volume dependent. | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=KNL        \ | ||||
|              --enable-comms=mpi3-auto \ | ||||
|              --enable-mkl             \ | ||||
|              CC=icpc MPICXX=mpiicpc  | ||||
| ``` | ||||
|  | ||||
| ### Build setup for Intel Haswell Xeon platform | ||||
|  | ||||
| The following configuration is recommended for the Intel Haswell platform: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=AVX2       \ | ||||
|              --enable-comms=mpi3-auto \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=icpc MPICXX=mpiicpc | ||||
| ``` | ||||
| The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library. | ||||
|  | ||||
| If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed: | ||||
| ``` bash | ||||
|                --with-gmp=<path>        \ | ||||
|                --with-mpfr=<path>       \ | ||||
| ``` | ||||
| where `<path>` is the UNIX prefix where GMP and MPFR are installed.  | ||||
|  | ||||
| If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=AVX2       \ | ||||
|              --enable-comms=mpi3      \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=CC CC=cc | ||||
| ``` | ||||
| Since Dual socket nodes are commonplace, we recommend MPI-3 as the default with the use of  | ||||
| one rank per socket. If using the Intel MPI library, threads should be pinned to NUMA domains using | ||||
| ``` | ||||
|         export I_MPI_PIN=1 | ||||
| ``` | ||||
| This is the default. | ||||
|  | ||||
| ### Build setup for Intel Skylake Xeon platform | ||||
|  | ||||
| The following configuration is recommended for the Intel Skylake platform: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=AVX512     \ | ||||
|              --enable-comms=mpi3      \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=mpiicpc | ||||
| ``` | ||||
| The MKL flag enables use of BLAS and FFTW from the Intel Math Kernels Library. | ||||
|  | ||||
| If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed: | ||||
| ``` bash | ||||
|                --with-gmp=<path>        \ | ||||
|                --with-mpfr=<path>       \ | ||||
| ``` | ||||
| where `<path>` is the UNIX prefix where GMP and MPFR are installed.  | ||||
|  | ||||
| If you are working on a Cray machine that does not use the `mpiicpc` wrapper, please use: | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=AVX512     \ | ||||
|              --enable-comms=mpi3      \ | ||||
|              --enable-mkl             \ | ||||
|              CXX=CC CC=cc | ||||
| ``` | ||||
| Since Dual socket nodes are commonplace, we recommend MPI-3 as the default with the use of  | ||||
| one rank per socket. If using the Intel MPI library, threads should be pinned to NUMA domains using | ||||
| ```  | ||||
|         export I_MPI_PIN=1 | ||||
| ``` | ||||
| This is the default.  | ||||
|  | ||||
| #### Expected Skylake Gold 6148 dual socket (single prec, single node 20+20 cores) performance using NUMA MPI mapping):  | ||||
|  | ||||
| mpirun -n 2 benchmarks/Benchmark_dwf --grid 16.16.16.16 --mpi 2.1.1.1 --cacheblocking 2.2.2.2 --dslash-asm --shm 1024 --threads 18  | ||||
|  | ||||
| TBA | ||||
|  | ||||
|  | ||||
| ### Build setup for AMD EPYC / RYZEN | ||||
|  | ||||
| The AMD EPYC is a multichip module comprising 32 cores spread over four distinct chips each with 8 cores. | ||||
| So, even with a single socket node there is a quad-chip module. Dual socket nodes with 64 cores total | ||||
| are common. Each chip within the module exposes a separate NUMA domain. | ||||
| There are four NUMA domains per socket and we recommend one MPI rank per NUMA domain. | ||||
| MPI-3 is recommended with the use of four ranks per socket, | ||||
| and 8 threads per rank.  | ||||
|  | ||||
| The following configuration is recommended for the AMD EPYC platform. | ||||
|  | ||||
| ``` bash | ||||
| ../configure --enable-precision=double\ | ||||
|              --enable-simd=AVX2       \ | ||||
|              --enable-comms=mpi3 \ | ||||
|              CXX=mpicxx  | ||||
| ``` | ||||
|  | ||||
| If gmp and mpfr are NOT in standard places (/usr/) these flags may be needed: | ||||
| ``` bash | ||||
|                --with-gmp=<path>        \ | ||||
|                --with-mpfr=<path>       \ | ||||
| ``` | ||||
| where `<path>` is the UNIX prefix where GMP and MPFR are installed.  | ||||
|  | ||||
| Using MPICH and g++ v4.9.2, best performance can be obtained using explicit GOMP_CPU_AFFINITY flags for each MPI rank. | ||||
| This can be done by invoking MPI on a wrapper script omp_bind.sh to handle this.  | ||||
|  | ||||
| It is recommended to run 8 MPI ranks on a single dual socket AMD EPYC, with 8 threads per rank using MPI3 and | ||||
| shared memory to communicate within this node: | ||||
|  | ||||
| mpirun -np 8 ./omp_bind.sh ./Benchmark_dwf --mpi 2.2.2.1 --dslash-unroll --threads 8 --grid 16.16.16.16 --cacheblocking 4.4.4.4  | ||||
|  | ||||
| Where omp_bind.sh does the following: | ||||
| ``` | ||||
| #!/bin/bash | ||||
|  | ||||
| numanode=` expr $PMI_RANK % 8 ` | ||||
| basecore=`expr $numanode \* 16` | ||||
| core0=`expr $basecore + 0 ` | ||||
| core1=`expr $basecore + 2 ` | ||||
| core2=`expr $basecore + 4 ` | ||||
| core3=`expr $basecore + 6 ` | ||||
| core4=`expr $basecore + 8 ` | ||||
| core5=`expr $basecore + 10 ` | ||||
| core6=`expr $basecore + 12 ` | ||||
| core7=`expr $basecore + 14 ` | ||||
|  | ||||
| export GOMP_CPU_AFFINITY="$core0 $core1 $core2 $core3 $core4 $core5 $core6 $core7" | ||||
| echo GOMP_CUP_AFFINITY $GOMP_CPU_AFFINITY | ||||
|  | ||||
| $@ | ||||
| ``` | ||||
|  | ||||
| Performance: | ||||
|  | ||||
| #### Expected AMD EPYC 7601 dual socket (single prec, single node 32+32 cores) performance using NUMA MPI mapping):  | ||||
|  | ||||
| mpirun  -np 8 ./omp_bind.sh ./Benchmark_dwf --threads 8 --mpi 2.2.2.1 --dslash-unroll --grid 16.16.16.16 --cacheblocking 4.4.4.4 | ||||
|  | ||||
| TBA | ||||
|  | ||||
| ### Build setup for BlueGene/Q | ||||
|  | ||||
| To be written... | ||||
|  | ||||
| ### Build setup for ARM Neon | ||||
|  | ||||
| To be written... | ||||
|  | ||||
| ### Build setup for laptops, other compilers, non-cluster builds | ||||
|  | ||||
| Many versions of g++ and clang++ work with Grid, and involve merely replacing CXX (and MPICXX), | ||||
| and omit the enable-mkl flag.  | ||||
|  | ||||
| Single node builds are enabled with  | ||||
| ``` | ||||
|             --enable-comms=none | ||||
| ``` | ||||
|  | ||||
| FFTW support that is not in the default search path may then enabled with | ||||
| ``` | ||||
|     --with-fftw=<installpath> | ||||
| ``` | ||||
|  | ||||
| BLAS will not be compiled in by default, and Lanczos will default to Eigen diagonalisation. | ||||
|  | ||||
|   | ||||
							
								
								
									
										86
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										86
									
								
								TODO
									
									
									
									
									
								
							| @@ -1,6 +1,51 @@ | ||||
| TODO: | ||||
| --------------- | ||||
|  | ||||
| Code item work list | ||||
|  | ||||
| a) namespaces & indentation | ||||
|  GRID_BEGIN_NAMESPACE(); | ||||
|  GRID_END_NAMESPACE(); | ||||
| -- delete QCD namespace | ||||
|  | ||||
| b) GPU branch | ||||
| - start branch | ||||
| - Increase Macro use in core library support; prepare for change | ||||
| - Audit volume of "device" code | ||||
| - Virtual function audit | ||||
| - Start port once Nvidia box is up | ||||
| - Cut down volume of code for first port? How? | ||||
|  | ||||
| Physics item work list: | ||||
|  | ||||
| 1)- BG/Q port and check ; Andrew says ok. | ||||
| 2)- Consistent linear solver flop count/rate -- PARTIAL, time but no flop/s yet | ||||
| 3)- Physical propagator interface | ||||
| 4)- Multigrid Wilson and DWF, compare to other Multigrid implementations | ||||
| 5)- HDCR resume | ||||
|  | ||||
| ---------------------------- | ||||
| Recent DONE  | ||||
| -- RNG I/O in ILDG/SciDAC (minor)  | ||||
| -- Precision conversion and sort out localConvert      <-- partial/easy | ||||
| -- Conserved currents (Andrew) | ||||
| -- Split grid | ||||
| -- Christoph's local basis expansion Lanczos | ||||
| -- MultiRHS with spread out extra dim -- Go through filesystem with SciDAC I/O ; <-- DONE ; bmark cori | ||||
| -- Lanczos Remove DenseVector, DenseMatrix; Use Eigen instead. <-- DONE | ||||
| -- GaugeFix into central location                      <-- DONE | ||||
| -- Scidac and Ildg metadata handling                   <-- DONE | ||||
| -- Binary I/O MPI2 IO                                  <-- DONE | ||||
| -- Binary I/O speed up & x-strips                      <-- DONE | ||||
| -- Cut down the exterior overhead                      <-- DONE | ||||
| -- Interior legs from SHM comms                        <-- DONE | ||||
| -- Half-precision comms                                <-- DONE | ||||
| -- Merge high precision reduction into develop         <-- DONE | ||||
| -- BlockCG, BCGrQ                                      <-- DONE | ||||
| -- multiRHS DWF; benchmark on Cori/BNL for comms elimination <-- DONE | ||||
|    -- slice* linalg routines for multiRHS, BlockCG     | ||||
|  | ||||
| ----- | ||||
| * Forces; the UdSdU  term in gauge force term is half of what I think it should | ||||
|   be. This is a consequence of taking ONLY the first term in: | ||||
|  | ||||
| @@ -21,16 +66,8 @@ TODO: | ||||
|   This means we must double the force in the Test_xxx_force routines, and is the origin of the factor of two. | ||||
|   This 2x is applied by hand in the fermion routines and in the Test_rect_force routine. | ||||
|  | ||||
|  | ||||
| Policies: | ||||
|  | ||||
| * Link smearing/boundary conds; Policy class based implementation ; framework more in place | ||||
|  | ||||
| * Support different boundary conditions (finite temp, chem. potential ... ) | ||||
|  | ||||
| * Support different fermion representations?  | ||||
|   - contained entirely within the integrator presently | ||||
|  | ||||
| - Sign of force term. | ||||
|  | ||||
| - Reversibility test. | ||||
| @@ -41,11 +78,6 @@ Policies: | ||||
|  | ||||
| - Audit oIndex usage for cb behaviour | ||||
|  | ||||
| - Rectangle gauge actions. | ||||
|   Iwasaki, | ||||
|   Symanzik, | ||||
|   ... etc... | ||||
|  | ||||
| - Prepare multigrid for HMC. - Alternate setup schemes. | ||||
|  | ||||
| - Support for ILDG --- ugly, not done | ||||
| @@ -55,9 +87,11 @@ Policies: | ||||
| - FFTnD ? | ||||
|  | ||||
| - Gparity; hand opt use template specialisation elegance to enable the optimised paths ? | ||||
|  | ||||
| - Gparity force term; Gparity (R)HMC. | ||||
| - Random number state save restore | ||||
|  | ||||
| - Mobius implementation clean up to rmove #if 0 stale code sequences | ||||
|  | ||||
| - CG -- profile carefully, kernel fusion, whole CG performance measurements. | ||||
|  | ||||
| ================================================================ | ||||
| @@ -90,6 +124,7 @@ Insert/Extract | ||||
| Not sure of status of this -- reverify. Things are working nicely now though. | ||||
|  | ||||
| * Make the Tensor types and Complex etc... play more nicely. | ||||
|  | ||||
|   - TensorRemove is a hack, come up with a long term rationalised approach to Complex vs. Scalar<Scalar<Scalar<Complex > > > | ||||
|     QDP forces use of "toDouble" to get back to non tensor scalar. This role is presently taken TensorRemove, but I | ||||
|     want to introduce a syntax that does not require this. | ||||
| @@ -112,6 +147,8 @@ Not sure of status of this -- reverify. Things are working nicely now though. | ||||
| RECENT | ||||
| --------------- | ||||
|  | ||||
|   - Support different fermion representations? -- DONE | ||||
|   - contained entirely within the integrator presently | ||||
|   - Clean up HMC                                                             -- DONE | ||||
|   - LorentzScalar<GaugeField> gets Gauge link type (cleaner).                -- DONE | ||||
|   - Simplified the integrators a bit.                                        -- DONE | ||||
| @@ -123,6 +160,26 @@ RECENT | ||||
|   - Parallel io improvements                                  -- DONE | ||||
|   - Plaquette and link trace checks into nersc reader from the Grid_nersc_io.cc test. -- DONE | ||||
|  | ||||
|  | ||||
| DONE: | ||||
| - MultiArray -- MultiRHS done | ||||
| - ConjugateGradientMultiShift -- DONE | ||||
| - MCR                         -- DONE | ||||
| - Remez -- Mike or Boost?     -- DONE | ||||
| - Proto (ET)                  -- DONE | ||||
| - uBlas                       -- DONE ; Eigen | ||||
| - Potentially Useful Boost libraries -- DONE ; Eigen | ||||
| - Aligned allocator; memory pool -- DONE | ||||
| - Multiprecision              -- DONE | ||||
| - Serialization               -- DONE | ||||
| - Regex -- Not needed | ||||
| - Tokenize -- Why? | ||||
|  | ||||
| - Random number state save restore -- DONE | ||||
| - Rectangle gauge actions. -- DONE | ||||
|   Iwasaki, | ||||
|   Symanzik, | ||||
|   ... etc... | ||||
| Done: Cayley, Partial , ContFrac force terms. | ||||
|  | ||||
| DONE | ||||
| @@ -207,6 +264,7 @@ Done | ||||
| FUNCTIONALITY: it pleases me to keep track of things I have done (keeps me arguably sane) | ||||
| ====================================================================================================== | ||||
|  | ||||
| * Link smearing/boundary conds; Policy class based implementation ; framework more in place -- DONE | ||||
| * Command line args for geometry, simd, etc. layout. Is it necessary to have -- DONE | ||||
|   user pass these? Is this a QCD specific? | ||||
|  | ||||
|   | ||||
							
								
								
									
										7
									
								
								VERSION
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								VERSION
									
									
									
									
									
								
							| @@ -1,4 +1,5 @@ | ||||
| Version : 0.5.0 | ||||
| Version : 0.8.0 | ||||
|  | ||||
| - AVX512, AVX2, AVX, SSE good | ||||
| - Clang 3.5 and above, ICPC v16 and above, GCC 4.9 and above | ||||
| - Clang 3.5 and above, ICPC v16 and above, GCC 6.3 and above recommended | ||||
| - MPI and MPI3 comms optimisations for KNL and OPA finished | ||||
| - Half precision comms | ||||
|   | ||||
							
								
								
									
										108
									
								
								benchmarks/Benchmark_IO.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								benchmarks/Benchmark_IO.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,108 @@ | ||||
| #include <Grid/Grid.h> | ||||
| #ifdef HAVE_LIME | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| #define MSG cout << GridLogMessage | ||||
| #define SEP \ | ||||
| "=============================================================================" | ||||
| #ifndef BENCH_IO_LMAX | ||||
| #define BENCH_IO_LMAX 40 | ||||
| #endif | ||||
|  | ||||
| typedef function<void(const string, LatticeFermion &)> WriterFn; | ||||
| typedef function<void(LatticeFermion &, const string)> ReaderFn; | ||||
|  | ||||
| string filestem(const int l) | ||||
| { | ||||
|   return "iobench_l" + to_string(l); | ||||
| } | ||||
|  | ||||
| void limeWrite(const string filestem, LatticeFermion &vec) | ||||
| { | ||||
|   emptyUserRecord record; | ||||
|   ScidacWriter    binWriter(vec._grid->IsBoss()); | ||||
|  | ||||
|   binWriter.open(filestem + ".bin"); | ||||
|   binWriter.writeScidacFieldRecord(vec, record); | ||||
|   binWriter.close(); | ||||
| } | ||||
|  | ||||
| void limeRead(LatticeFermion &vec, const string filestem) | ||||
| { | ||||
|   emptyUserRecord record; | ||||
|   ScidacReader    binReader; | ||||
|  | ||||
|   binReader.open(filestem + ".bin"); | ||||
|   binReader.readScidacFieldRecord(vec, record); | ||||
|   binReader.close(); | ||||
| } | ||||
|  | ||||
| void writeBenchmark(const int l, const WriterFn &write) | ||||
| { | ||||
|   auto                      mpi  = GridDefaultMpi(); | ||||
|   auto                      simd = GridDefaultSimd(Nd, vComplex::Nsimd()); | ||||
|   vector<int>               latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; | ||||
|   unique_ptr<GridCartesian> gPt(SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); | ||||
|   GridCartesian             *g = gPt.get(); | ||||
|   GridParallelRNG           rng(g); | ||||
|   LatticeFermion            vec(g); | ||||
|   emptyUserRecord           record; | ||||
|   ScidacWriter              binWriter(g->IsBoss()); | ||||
|  | ||||
|   cout << "-- Local volume " << l << "^4" << endl; | ||||
|   random(rng, vec); | ||||
|   write(filestem(l), vec); | ||||
| } | ||||
|  | ||||
| void readBenchmark(const int l, const ReaderFn &read) | ||||
| { | ||||
|   auto                      mpi  = GridDefaultMpi(); | ||||
|   auto                      simd = GridDefaultSimd(Nd, vComplex::Nsimd()); | ||||
|   vector<int>               latt = {l*mpi[0], l*mpi[1], l*mpi[2], l*mpi[3]}; | ||||
|   unique_ptr<GridCartesian> gPt(SpaceTimeGrid::makeFourDimGrid(latt, simd, mpi)); | ||||
|   GridCartesian             *g = gPt.get(); | ||||
|   LatticeFermion            vec(g); | ||||
|   emptyUserRecord           record; | ||||
|   ScidacReader              binReader; | ||||
|  | ||||
|   cout << "-- Local volume " << l << "^4" << endl; | ||||
|   read(vec, filestem(l)); | ||||
| } | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   auto simd = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||
|   auto mpi  = GridDefaultMpi(); | ||||
|  | ||||
|   int64_t threads = GridThread::GetThreads(); | ||||
|   MSG << "Grid is setup to use " << threads << " threads" << endl; | ||||
|   MSG << SEP << endl; | ||||
|   MSG << "Benchmark Lime write" << endl; | ||||
|   MSG << SEP << endl; | ||||
|   for (int l = 4; l <= BENCH_IO_LMAX; l += 2) | ||||
|   { | ||||
|     writeBenchmark(l, limeWrite); | ||||
|   } | ||||
|  | ||||
|   MSG << "Benchmark Lime read" << endl; | ||||
|   MSG << SEP << endl; | ||||
|   for (int l = 4; l <= BENCH_IO_LMAX; l += 2) | ||||
|   { | ||||
|     readBenchmark(l, limeRead); | ||||
|   } | ||||
|  | ||||
|   Grid_finalize(); | ||||
|  | ||||
|   return EXIT_SUCCESS; | ||||
| } | ||||
| #else | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   return EXIT_SUCCESS; | ||||
| } | ||||
| #endif | ||||
							
								
								
									
										807
									
								
								benchmarks/Benchmark_ITT.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										807
									
								
								benchmarks/Benchmark_ITT.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,807 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_memory_bandwidth.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplR> WilsonFermion5DR; | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplF> WilsonFermion5DF; | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplD> WilsonFermion5DD; | ||||
|  | ||||
|  | ||||
| std::vector<int> L_list; | ||||
| std::vector<int> Ls_list; | ||||
| std::vector<double> mflop_list; | ||||
|  | ||||
| double mflop_ref; | ||||
| double mflop_ref_err; | ||||
|  | ||||
| int NN_global; | ||||
|  | ||||
| struct time_statistics{ | ||||
|   double mean; | ||||
|   double err; | ||||
|   double min; | ||||
|   double max; | ||||
|  | ||||
|   void statistics(std::vector<double> v){ | ||||
|       double sum = std::accumulate(v.begin(), v.end(), 0.0); | ||||
|       mean = sum / v.size(); | ||||
|  | ||||
|       std::vector<double> diff(v.size()); | ||||
|       std::transform(v.begin(), v.end(), diff.begin(), [=](double x) { return x - mean; }); | ||||
|       double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); | ||||
|       err = std::sqrt(sq_sum / (v.size()*(v.size() - 1))); | ||||
|  | ||||
|       auto result = std::minmax_element(v.begin(), v.end()); | ||||
|       min = *result.first; | ||||
|       max = *result.second; | ||||
| } | ||||
| }; | ||||
|  | ||||
| void comms_header(){ | ||||
|   std::cout <<GridLogMessage << " L  "<<"\t"<<" Ls  "<<"\t" | ||||
|             <<std::setw(11)<<"bytes"<<"MB/s uni (err/min/max)"<<"\t\t"<<"MB/s bidi (err/min/max)"<<std::endl; | ||||
| }; | ||||
|  | ||||
| Gamma::Algebra Gmu [] = { | ||||
|   Gamma::Algebra::GammaX, | ||||
|   Gamma::Algebra::GammaY, | ||||
|   Gamma::Algebra::GammaZ, | ||||
|   Gamma::Algebra::GammaT | ||||
| }; | ||||
| struct controls { | ||||
|   int Opt; | ||||
|   int CommsOverlap; | ||||
|   Grid::CartesianCommunicator::CommunicatorPolicy_t CommsAsynch; | ||||
|   //  int HugePages; | ||||
| }; | ||||
|  | ||||
| class Benchmark { | ||||
| public: | ||||
|   static void Decomposition (void ) { | ||||
|  | ||||
|     int threads = GridThread::GetThreads(); | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "= Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"Grid Default Decomposition patterns\n"; | ||||
|     std::cout<<GridLogMessage<<"\tOpenMP threads : "<<GridThread::GetThreads()<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tMPI tasks      : "<<GridCmdVectorIntToString(GridDefaultMpi())<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvReal          : "<<sizeof(vReal )*8    <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vReal::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvRealF         : "<<sizeof(vRealF)*8    <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vRealF::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvRealD         : "<<sizeof(vRealD)*8    <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vRealD::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvComplex       : "<<sizeof(vComplex )*8 <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vComplex::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvComplexF      : "<<sizeof(vComplexF)*8 <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vComplexF::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage<<"\tvComplexD      : "<<sizeof(vComplexD)*8 <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vComplexD::Nsimd()))<<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|   } | ||||
|  | ||||
|   static void Comms(void) | ||||
|   { | ||||
|     int Nloop=200; | ||||
|     int nmu=0; | ||||
|     int maxlat=32; | ||||
|  | ||||
|     std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplexD::Nsimd()); | ||||
|     std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|  | ||||
|     for(int mu=0;mu<Nd;mu++) if (mpi_layout[mu]>1) nmu++; | ||||
|  | ||||
|     std::vector<double> t_time(Nloop); | ||||
|     time_statistics timestat; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "= Benchmarking threaded STENCIL halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|     comms_header(); | ||||
|  | ||||
|     for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|       for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
| 	std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
| 	      lat*mpi_layout[1], | ||||
| 	      lat*mpi_layout[2], | ||||
| 	      lat*mpi_layout[3]}); | ||||
|  | ||||
| 	GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
| 	RealD Nrank = Grid._Nprocessors; | ||||
| 	RealD Nnode = Grid.NodeCount(); | ||||
| 	RealD ppn = Nrank/Nnode; | ||||
|  | ||||
| 	std::vector<HalfSpinColourVectorD *> xbuf(8); | ||||
| 	std::vector<HalfSpinColourVectorD *> rbuf(8); | ||||
| 	Grid.ShmBufferFreeAll(); | ||||
| 	for(int d=0;d<8;d++){ | ||||
| 	  xbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	  rbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	  bzero((void *)xbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	  bzero((void *)rbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	} | ||||
|  | ||||
| 	int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
| 	int ncomm; | ||||
| 	double dbytes; | ||||
| 	std::vector<double> times(Nloop); | ||||
| 	for(int i=0;i<Nloop;i++){ | ||||
|  | ||||
| 	  double start=usecond(); | ||||
|  | ||||
| 	  dbytes=0; | ||||
| 	  ncomm=0; | ||||
| #ifdef GRID_OMP | ||||
| #pragma omp parallel for num_threads(Grid::CartesianCommunicator::nCommThreads) | ||||
| #endif | ||||
| 	  for(int dir=0;dir<8;dir++){ | ||||
|  | ||||
| 	    double tbytes; | ||||
| 	    int mu =dir % 4; | ||||
|  | ||||
| 	    if (mpi_layout[mu]>1 ) { | ||||
| 	         | ||||
| 	      int xmit_to_rank; | ||||
| 	      int recv_from_rank; | ||||
| 	      if ( dir == mu ) {  | ||||
| 		int comm_proc=1; | ||||
| 		Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	      } else {  | ||||
| 		int comm_proc = mpi_layout[mu]-1; | ||||
| 		Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	      } | ||||
| #ifdef GRID_OMP | ||||
| 	int tid = omp_get_thread_num();  | ||||
| #else  | ||||
|         int tid = dir; | ||||
| #endif | ||||
| 	      tbytes= Grid.StencilSendToRecvFrom((void *)&xbuf[dir][0], xmit_to_rank, | ||||
| 						 (void *)&rbuf[dir][0], recv_from_rank, | ||||
| 						 bytes,tid); | ||||
| 	   | ||||
| #ifdef GRID_OMP | ||||
| #pragma omp atomic | ||||
| #endif | ||||
| 	      ncomm++; | ||||
|  | ||||
| #ifdef GRID_OMP | ||||
| #pragma omp atomic | ||||
| #endif | ||||
| 	      dbytes+=tbytes; | ||||
| 	    } | ||||
| 	  } | ||||
| 	  Grid.Barrier(); | ||||
| 	  double stop=usecond(); | ||||
| 	  t_time[i] = stop-start; // microseconds | ||||
| 	} | ||||
|  | ||||
| 	timestat.statistics(t_time); | ||||
| 	//	for(int i=0;i<t_time.size();i++){ | ||||
| 	//	  std::cout << i<<" "<<t_time[i]<<std::endl; | ||||
| 	//	} | ||||
|  | ||||
| 	dbytes=dbytes*ppn; | ||||
| 	double xbytes    = dbytes*0.5; | ||||
| 	double rbytes    = dbytes*0.5; | ||||
| 	double bidibytes = dbytes; | ||||
|  | ||||
| 	std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
| 		 <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
| 		 <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
| 		 <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
| 		 << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
| 		 << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|  | ||||
|   | ||||
| 	 | ||||
| 	    } | ||||
|     }     | ||||
|  | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   static void Memory(void) | ||||
|   { | ||||
|     const int Nvec=8; | ||||
|     typedef Lattice< iVector< vReal,Nvec> > LatticeVec; | ||||
|     typedef iVector<vReal,Nvec> Vec; | ||||
|  | ||||
|     std::vector<int> simd_layout = GridDefaultSimd(Nd,vReal::Nsimd()); | ||||
|     std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|  | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "= Benchmarking a*x + y bandwidth"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s"<<"\t\t"<<"Gflop/s"<<"\t\t seconds"<< "\t\tGB/s / node"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|    | ||||
|     uint64_t NP; | ||||
|     uint64_t NN; | ||||
|  | ||||
|  | ||||
|   uint64_t lmax=48; | ||||
| #define NLOOP (100*lmax*lmax*lmax*lmax/lat/lat/lat/lat) | ||||
|  | ||||
|     GridSerialRNG          sRNG;      sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|     for(int lat=8;lat<=lmax;lat+=4){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int64_t vol= latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|  | ||||
|       NP= Grid.RankCount(); | ||||
|       NN =Grid.NodeCount(); | ||||
|  | ||||
|       Vec rn ; random(sRNG,rn); | ||||
|  | ||||
|       LatticeVec z(&Grid); z=rn; | ||||
|       LatticeVec x(&Grid); x=rn; | ||||
|       LatticeVec y(&Grid); y=rn; | ||||
|       double a=2.0; | ||||
|  | ||||
|       uint64_t Nloop=NLOOP; | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
| 	z=a*x-y; | ||||
|         x._odata[0]=z._odata[0]; // force serial dependency to prevent optimise away | ||||
|         y._odata[4]=z._odata[4]; | ||||
|       } | ||||
|       double stop=usecond(); | ||||
|       double time = (stop-start)/Nloop*1000; | ||||
|       | ||||
|       double flops=vol*Nvec*2;// mul,add | ||||
|       double bytes=3.0*vol*Nvec*sizeof(Real); | ||||
|       std::cout<<GridLogMessage<<std::setprecision(3)  | ||||
| 	       << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t"<<flops/time<<"\t\t"<<(stop-start)/1000./1000. | ||||
| 	       << "\t\t"<< bytes/time/NN <<std::endl; | ||||
|  | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   static double DWF5(int Ls,int L) | ||||
|   { | ||||
|     RealD mass=0.1; | ||||
|     RealD M5  =1.8; | ||||
|  | ||||
|     double mflops; | ||||
|     double mflops_best = 0; | ||||
|     double mflops_worst= 0; | ||||
|     std::vector<double> mflops_all; | ||||
|  | ||||
|     /////////////////////////////////////////////////////// | ||||
|     // Set/Get the layout & grid size | ||||
|     /////////////////////////////////////////////////////// | ||||
|     int threads = GridThread::GetThreads(); | ||||
|     std::vector<int> mpi = GridDefaultMpi(); assert(mpi.size()==4); | ||||
|     std::vector<int> local({L,L,L,L}); | ||||
|  | ||||
|     GridCartesian         * TmpGrid   = SpaceTimeGrid::makeFourDimGrid(std::vector<int>({64,64,64,64}),  | ||||
| 								       GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|     uint64_t NP = TmpGrid->RankCount(); | ||||
|     uint64_t NN = TmpGrid->NodeCount(); | ||||
|     NN_global=NN; | ||||
|     uint64_t SHM=NP/NN; | ||||
|  | ||||
|     std::vector<int> internal; | ||||
|     if      ( SHM == 1 )   internal = std::vector<int>({1,1,1,1}); | ||||
|     else if ( SHM == 2 )   internal = std::vector<int>({2,1,1,1}); | ||||
|     else if ( SHM == 4 )   internal = std::vector<int>({2,2,1,1}); | ||||
|     else if ( SHM == 8 )   internal = std::vector<int>({2,2,2,1}); | ||||
|     else assert(0); | ||||
|  | ||||
|     std::vector<int> nodes({mpi[0]/internal[0],mpi[1]/internal[1],mpi[2]/internal[2],mpi[3]/internal[3]}); | ||||
|     std::vector<int> latt4({local[0]*nodes[0],local[1]*nodes[1],local[2]*nodes[2],local[3]*nodes[3]}); | ||||
|  | ||||
|     ///////// Welcome message //////////// | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "Benchmark DWF Ls vec on "<<L<<"^4 local volume "<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Global volume  : "<<GridCmdVectorIntToString(latt4)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Ls             : "<<Ls<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* MPI ranks      : "<<GridCmdVectorIntToString(mpi)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Intranode      : "<<GridCmdVectorIntToString(internal)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* nodes          : "<<GridCmdVectorIntToString(nodes)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Using "<<threads<<" threads"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|     ///////// Lattice Init //////////// | ||||
|     GridCartesian         * UGrid    = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|     GridRedBlackCartesian * UrbGrid  = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|     GridCartesian         * sUGrid   = SpaceTimeGrid::makeFourDimDWFGrid(latt4,GridDefaultMpi()); | ||||
|     GridRedBlackCartesian * sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid); | ||||
|     GridCartesian         * sFGrid   = SpaceTimeGrid::makeFiveDimDWFGrid(Ls,UGrid); | ||||
|     GridRedBlackCartesian * sFrbGrid = SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|     ///////// RNG Init //////////// | ||||
|     std::vector<int> seeds4({1,2,3,4}); | ||||
|     std::vector<int> seeds5({5,6,7,8}); | ||||
|     GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|     GridParallelRNG          RNG5(sFGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|     std::cout << GridLogMessage << "Initialised RNGs" << std::endl; | ||||
|  | ||||
|     ///////// Source preparation //////////// | ||||
|     LatticeFermion src   (sFGrid); random(RNG5,src); | ||||
|     LatticeFermion tmp   (sFGrid); | ||||
|  | ||||
|     RealD N2 = 1.0/::sqrt(norm2(src)); | ||||
|     src = src*N2; | ||||
|      | ||||
|     LatticeGaugeField Umu(UGrid);  SU3::HotConfiguration(RNG4,Umu);  | ||||
|  | ||||
|     WilsonFermion5DR sDw(Umu,*sFGrid,*sFrbGrid,*sUGrid,*sUrbGrid,M5); | ||||
|     LatticeFermion src_e (sFrbGrid); | ||||
|     LatticeFermion src_o (sFrbGrid); | ||||
|     LatticeFermion r_e   (sFrbGrid); | ||||
|     LatticeFermion r_o   (sFrbGrid); | ||||
|     LatticeFermion r_eo  (sFGrid); | ||||
|     LatticeFermion err   (sFGrid); | ||||
|     { | ||||
|  | ||||
|       pickCheckerboard(Even,src_e,src); | ||||
|       pickCheckerboard(Odd,src_o,src); | ||||
|  | ||||
| #if defined(AVX512)  | ||||
|       const int num_cases = 6; | ||||
|       std::string fmt("A/S ; A/O ; U/S ; U/O ; G/S ; G/O "); | ||||
| #else | ||||
|       const int num_cases = 4; | ||||
|       std::string fmt("U/S ; U/O ; G/S ; G/O "); | ||||
| #endif | ||||
|       controls Cases [] = { | ||||
| #ifdef AVX512 | ||||
| 	{ QCD::WilsonKernelsStatic::OptInlineAsm , QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptInlineAsm , QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| #endif | ||||
| 	{ QCD::WilsonKernelsStatic::OptHandUnroll, QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptHandUnroll, QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptGeneric   , QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptGeneric   , QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  } | ||||
|       };  | ||||
|  | ||||
|       for(int c=0;c<num_cases;c++) { | ||||
|  | ||||
| 	QCD::WilsonKernelsStatic::Comms = Cases[c].CommsOverlap; | ||||
| 	QCD::WilsonKernelsStatic::Opt   = Cases[c].Opt; | ||||
| 	CartesianCommunicator::SetCommunicatorPolicy(Cases[c].CommsAsynch); | ||||
|  | ||||
| 	std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| 	if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
| 	if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| 	std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
| 	int nwarm = 100; | ||||
| 	uint64_t ncall = 1000; | ||||
|  | ||||
| 	double t0=usecond(); | ||||
| 	sFGrid->Barrier(); | ||||
| 	for(int i=0;i<nwarm;i++){ | ||||
| 	  sDw.DhopEO(src_o,r_e,DaggerNo); | ||||
| 	} | ||||
| 	sFGrid->Barrier(); | ||||
| 	double t1=usecond(); | ||||
|  | ||||
| 	sDw.ZeroCounters(); | ||||
| 	time_statistics timestat; | ||||
| 	std::vector<double> t_time(ncall); | ||||
| 	for(uint64_t i=0;i<ncall;i++){ | ||||
| 	  t0=usecond(); | ||||
| 	  sDw.DhopEO(src_o,r_e,DaggerNo); | ||||
| 	  t1=usecond(); | ||||
| 	  t_time[i] = t1-t0; | ||||
| 	} | ||||
| 	sFGrid->Barrier(); | ||||
| 	 | ||||
| 	double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
| 	double flops=(1344.0*volume)/2; | ||||
| 	double mf_hi, mf_lo, mf_err; | ||||
|  | ||||
| 	timestat.statistics(t_time); | ||||
| 	mf_hi = flops/timestat.min; | ||||
| 	mf_lo = flops/timestat.max; | ||||
| 	mf_err= flops/timestat.min * timestat.err/timestat.mean; | ||||
|  | ||||
| 	mflops = flops/timestat.mean; | ||||
| 	mflops_all.push_back(mflops); | ||||
| 	if ( mflops_best == 0   ) mflops_best = mflops; | ||||
| 	if ( mflops_worst== 0   ) mflops_worst= mflops; | ||||
| 	if ( mflops>mflops_best ) mflops_best = mflops; | ||||
| 	if ( mflops<mflops_worst) mflops_worst= mflops; | ||||
|  | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"sDeo mflop/s =   "<< mflops << " ("<<mf_err<<") " << mf_lo<<"-"<<mf_hi <<std::endl; | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"sDeo mflop/s per rank   "<< mflops/NP<<std::endl; | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"sDeo mflop/s per node   "<< mflops/NN<<std::endl; | ||||
|  | ||||
| 	sDw.Report(); | ||||
|  | ||||
|       } | ||||
|       double robust = mflops_worst/mflops_best;; | ||||
|       std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|       std::cout<<GridLogMessage << L<<"^4 x "<<Ls<< " sDeo Best  mflop/s        =   "<< mflops_best << " ; " << mflops_best/NN<<" per node " <<std::endl; | ||||
|       std::cout<<GridLogMessage << L<<"^4 x "<<Ls<< " sDeo Worst mflop/s        =   "<< mflops_worst<< " ; " << mflops_worst/NN<<" per node " <<std::endl; | ||||
|  | ||||
|       std::cout<<GridLogMessage <<std::setprecision(3)<< L<<"^4 x "<<Ls<< " Performance Robustness   =   "<< robust <<std::endl; | ||||
|       std::cout<<GridLogMessage <<fmt << std::endl; | ||||
|       std::cout<<GridLogMessage; | ||||
|  | ||||
|       for(int i=0;i<mflops_all.size();i++){ | ||||
| 	std::cout<<mflops_all[i]/NN<<" ; " ; | ||||
|       } | ||||
|       std::cout<<std::endl; | ||||
|       std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|     } | ||||
|     return mflops_best; | ||||
|   } | ||||
|  | ||||
|   static double DWF(int Ls,int L, double & robust) | ||||
|   { | ||||
|     RealD mass=0.1; | ||||
|     RealD M5  =1.8; | ||||
|  | ||||
|     double mflops; | ||||
|     double mflops_best = 0; | ||||
|     double mflops_worst= 0; | ||||
|     std::vector<double> mflops_all; | ||||
|  | ||||
|     /////////////////////////////////////////////////////// | ||||
|     // Set/Get the layout & grid size | ||||
|     /////////////////////////////////////////////////////// | ||||
|     int threads = GridThread::GetThreads(); | ||||
|     std::vector<int> mpi = GridDefaultMpi(); assert(mpi.size()==4); | ||||
|     std::vector<int> local({L,L,L,L}); | ||||
|  | ||||
|     GridCartesian         * TmpGrid   = SpaceTimeGrid::makeFourDimGrid(std::vector<int>({64,64,64,64}),  | ||||
| 								       GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|     uint64_t NP = TmpGrid->RankCount(); | ||||
|     uint64_t NN = TmpGrid->NodeCount(); | ||||
|     NN_global=NN; | ||||
|     uint64_t SHM=NP/NN; | ||||
|  | ||||
|     std::vector<int> internal; | ||||
|     if      ( SHM == 1 )   internal = std::vector<int>({1,1,1,1}); | ||||
|     else if ( SHM == 2 )   internal = std::vector<int>({2,1,1,1}); | ||||
|     else if ( SHM == 4 )   internal = std::vector<int>({2,2,1,1}); | ||||
|     else if ( SHM == 8 )   internal = std::vector<int>({2,2,2,1}); | ||||
|     else assert(0); | ||||
|  | ||||
|     std::vector<int> nodes({mpi[0]/internal[0],mpi[1]/internal[1],mpi[2]/internal[2],mpi[3]/internal[3]}); | ||||
|     std::vector<int> latt4({local[0]*nodes[0],local[1]*nodes[1],local[2]*nodes[2],local[3]*nodes[3]}); | ||||
|  | ||||
|     ///////// Welcome message //////////// | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << "Benchmark DWF on "<<L<<"^4 local volume "<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Global volume  : "<<GridCmdVectorIntToString(latt4)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Ls             : "<<Ls<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* MPI ranks      : "<<GridCmdVectorIntToString(mpi)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Intranode      : "<<GridCmdVectorIntToString(internal)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* nodes          : "<<GridCmdVectorIntToString(nodes)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "* Using "<<threads<<" threads"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|  | ||||
|     ///////// Lattice Init //////////// | ||||
|     GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|     GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|     GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|     GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|      | ||||
|     ///////// RNG Init //////////// | ||||
|     std::vector<int> seeds4({1,2,3,4}); | ||||
|     std::vector<int> seeds5({5,6,7,8}); | ||||
|     GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|     GridParallelRNG          RNG5(FGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|     std::cout << GridLogMessage << "Initialised RNGs" << std::endl; | ||||
|  | ||||
|     ///////// Source preparation //////////// | ||||
|     LatticeFermion src   (FGrid); random(RNG5,src); | ||||
|     LatticeFermion ref   (FGrid); | ||||
|     LatticeFermion tmp   (FGrid); | ||||
|  | ||||
|     RealD N2 = 1.0/::sqrt(norm2(src)); | ||||
|     src = src*N2; | ||||
|      | ||||
|     LatticeGaugeField Umu(UGrid);  SU3::HotConfiguration(RNG4,Umu);  | ||||
|  | ||||
|     DomainWallFermionR Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|  | ||||
|     //////////////////////////////////// | ||||
|     // Naive wilson implementation | ||||
|     //////////////////////////////////// | ||||
|     { | ||||
|       LatticeGaugeField Umu5d(FGrid);  | ||||
|       std::vector<LatticeColourMatrix> U(4,FGrid); | ||||
|       for(int ss=0;ss<Umu._grid->oSites();ss++){ | ||||
| 	for(int s=0;s<Ls;s++){ | ||||
| 	  Umu5d._odata[Ls*ss+s] = Umu._odata[ss]; | ||||
| 	} | ||||
|       } | ||||
|       ref = zero; | ||||
|       for(int mu=0;mu<Nd;mu++){ | ||||
| 	U[mu] = PeekIndex<LorentzIndex>(Umu5d,mu); | ||||
|       } | ||||
|       for(int mu=0;mu<Nd;mu++){ | ||||
| 	 | ||||
| 	tmp = U[mu]*Cshift(src,mu+1,1); | ||||
| 	ref=ref + tmp - Gamma(Gmu[mu])*tmp; | ||||
| 	 | ||||
| 	tmp =adj(U[mu])*src; | ||||
| 	tmp =Cshift(tmp,mu+1,-1); | ||||
| 	ref=ref + tmp + Gamma(Gmu[mu])*tmp; | ||||
|       } | ||||
|       ref = -0.5*ref; | ||||
|     } | ||||
|  | ||||
|     LatticeFermion src_e (FrbGrid); | ||||
|     LatticeFermion src_o (FrbGrid); | ||||
|     LatticeFermion r_e   (FrbGrid); | ||||
|     LatticeFermion r_o   (FrbGrid); | ||||
|     LatticeFermion r_eo  (FGrid); | ||||
|     LatticeFermion err   (FGrid); | ||||
|     { | ||||
|  | ||||
|       pickCheckerboard(Even,src_e,src); | ||||
|       pickCheckerboard(Odd,src_o,src); | ||||
|  | ||||
| #if defined(AVX512)  | ||||
|       const int num_cases = 6; | ||||
|       std::string fmt("A/S ; A/O ; U/S ; U/O ; G/S ; G/O "); | ||||
| #else | ||||
|       const int num_cases = 4; | ||||
|       std::string fmt("U/S ; U/O ; G/S ; G/O "); | ||||
| #endif | ||||
|       controls Cases [] = { | ||||
| #ifdef AVX512 | ||||
| 	{ QCD::WilsonKernelsStatic::OptInlineAsm , QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptInlineAsm , QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| #endif | ||||
| 	{ QCD::WilsonKernelsStatic::OptHandUnroll, QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptHandUnroll, QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptGeneric   , QCD::WilsonKernelsStatic::CommsThenCompute ,CartesianCommunicator::CommunicatorPolicySequential  }, | ||||
| 	{ QCD::WilsonKernelsStatic::OptGeneric   , QCD::WilsonKernelsStatic::CommsAndCompute  ,CartesianCommunicator::CommunicatorPolicySequential  } | ||||
|       };  | ||||
|  | ||||
|       for(int c=0;c<num_cases;c++) { | ||||
|  | ||||
| 	QCD::WilsonKernelsStatic::Comms = Cases[c].CommsOverlap; | ||||
| 	QCD::WilsonKernelsStatic::Opt   = Cases[c].Opt; | ||||
| 	CartesianCommunicator::SetCommunicatorPolicy(Cases[c].CommsAsynch); | ||||
|  | ||||
| 	std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
| 	if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| 	if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
| 	if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| 	std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
| 	int nwarm = 200; | ||||
| 	double t0=usecond(); | ||||
| 	FGrid->Barrier(); | ||||
| 	for(int i=0;i<nwarm;i++){ | ||||
| 	  Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
| 	} | ||||
| 	FGrid->Barrier(); | ||||
| 	double t1=usecond(); | ||||
| 	//	uint64_t ncall = (uint64_t) 2.5*1000.0*1000.0*nwarm/(t1-t0); | ||||
| 	//	if (ncall < 500) ncall = 500; | ||||
| 	uint64_t ncall = 1000; | ||||
|  | ||||
| 	FGrid->Broadcast(0,&ncall,sizeof(ncall)); | ||||
|  | ||||
| 	//	std::cout << GridLogMessage << " Estimate " << ncall << " calls per second"<<std::endl; | ||||
| 	Dw.ZeroCounters(); | ||||
|  | ||||
| 	time_statistics timestat; | ||||
| 	std::vector<double> t_time(ncall); | ||||
| 	for(uint64_t i=0;i<ncall;i++){ | ||||
| 	  t0=usecond(); | ||||
| 	  Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
| 	  t1=usecond(); | ||||
| 	  t_time[i] = t1-t0; | ||||
| 	} | ||||
| 	FGrid->Barrier(); | ||||
| 	 | ||||
| 	double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
| 	double flops=(1344.0*volume)/2; | ||||
| 	double mf_hi, mf_lo, mf_err; | ||||
|  | ||||
| 	timestat.statistics(t_time); | ||||
| 	mf_hi = flops/timestat.min; | ||||
| 	mf_lo = flops/timestat.max; | ||||
| 	mf_err= flops/timestat.min * timestat.err/timestat.mean; | ||||
|  | ||||
| 	mflops = flops/timestat.mean; | ||||
| 	mflops_all.push_back(mflops); | ||||
| 	if ( mflops_best == 0   ) mflops_best = mflops; | ||||
| 	if ( mflops_worst== 0   ) mflops_worst= mflops; | ||||
| 	if ( mflops>mflops_best ) mflops_best = mflops; | ||||
| 	if ( mflops<mflops_worst) mflops_worst= mflops; | ||||
|  | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"Deo mflop/s =   "<< mflops << " ("<<mf_err<<") " << mf_lo<<"-"<<mf_hi <<std::endl; | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"Deo mflop/s per rank   "<< mflops/NP<<std::endl; | ||||
| 	std::cout<<GridLogMessage << std::fixed << std::setprecision(1)<<"Deo mflop/s per node   "<< mflops/NN<<std::endl; | ||||
|  | ||||
| 	Dw.Report(); | ||||
|  | ||||
| 	Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
| 	Dw.DhopOE(src_e,r_o,DaggerNo); | ||||
| 	setCheckerboard(r_eo,r_o); | ||||
| 	setCheckerboard(r_eo,r_e); | ||||
| 	err = r_eo-ref;  | ||||
| 	std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
| 	assert((norm2(err)<1.0e-4)); | ||||
|  | ||||
|       } | ||||
|       robust = mflops_worst/mflops_best; | ||||
|       std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|       std::cout<<GridLogMessage << L<<"^4 x "<<Ls<< " Deo Best  mflop/s        =   "<< mflops_best << " ; " << mflops_best/NN<<" per node " <<std::endl; | ||||
|       std::cout<<GridLogMessage << L<<"^4 x "<<Ls<< " Deo Worst mflop/s        =   "<< mflops_worst<< " ; " << mflops_worst/NN<<" per node " <<std::endl; | ||||
|       std::cout<<GridLogMessage << std::fixed<<std::setprecision(3)<< L<<"^4 x "<<Ls<< " Performance Robustness   =   "<< robust  <<std::endl; | ||||
|       std::cout<<GridLogMessage <<fmt << std::endl; | ||||
|       std::cout<<GridLogMessage ; | ||||
|  | ||||
|       for(int i=0;i<mflops_all.size();i++){ | ||||
| 	std::cout<<mflops_all[i]/NN<<" ; " ; | ||||
|       } | ||||
|       std::cout<<std::endl; | ||||
|       std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|     } | ||||
|     return mflops_best; | ||||
|   } | ||||
|  | ||||
| }; | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   CartesianCommunicator::SetCommunicatorPolicy(CartesianCommunicator::CommunicatorPolicySequential); | ||||
| #ifdef KNL | ||||
|   LebesgueOrder::Block = std::vector<int>({8,2,2,2}); | ||||
| #else | ||||
|   LebesgueOrder::Block = std::vector<int>({2,2,2,2}); | ||||
| #endif | ||||
|   Benchmark::Decomposition(); | ||||
|  | ||||
|   int do_memory=1; | ||||
|   int do_comms =1; | ||||
|   int do_su3   =0; | ||||
|   int do_wilson=1; | ||||
|   int do_dwf   =1; | ||||
|  | ||||
|   if ( do_su3 ) { | ||||
|     // empty for now | ||||
|   } | ||||
| #if 1 | ||||
|   int sel=2; | ||||
|   std::vector<int> L_list({8,12,16,24}); | ||||
| #else | ||||
|   int sel=1; | ||||
|   std::vector<int> L_list({8,12}); | ||||
| #endif | ||||
|   int selm1=sel-1; | ||||
|   std::vector<double> robust_list; | ||||
|  | ||||
|   std::vector<double> wilson; | ||||
|   std::vector<double> dwf4; | ||||
|   std::vector<double> dwf5; | ||||
|  | ||||
|   if ( do_wilson ) { | ||||
|     int Ls=1; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << " Wilson dslash 4D vectorised" <<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     for(int l=0;l<L_list.size();l++){ | ||||
|       double robust; | ||||
|       wilson.push_back(Benchmark::DWF(1,L_list[l],robust)); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   int Ls=16; | ||||
|   if ( do_dwf ) { | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << " Domain wall dslash 4D vectorised" <<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     for(int l=0;l<L_list.size();l++){ | ||||
|       double robust; | ||||
|       double result = Benchmark::DWF(Ls,L_list[l],robust) ; | ||||
|       dwf4.push_back(result); | ||||
|       robust_list.push_back(robust); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if ( do_dwf ) { | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << " Domain wall dslash 4D vectorised" <<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     for(int l=0;l<L_list.size();l++){ | ||||
|       dwf5.push_back(Benchmark::DWF5(Ls,L_list[l])); | ||||
|     } | ||||
|  | ||||
|   } | ||||
|  | ||||
|   if ( do_dwf ) { | ||||
|  | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << " Summary table Ls="<<Ls <<std::endl; | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "L \t\t Wilson \t DWF4 \t DWF5 " <<std::endl; | ||||
|   for(int l=0;l<L_list.size();l++){ | ||||
|     std::cout<<GridLogMessage << L_list[l] <<" \t\t "<< wilson[l]<<" \t "<<dwf4[l]<<" \t "<<dwf5[l] <<std::endl; | ||||
|   } | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   } | ||||
|  | ||||
|   int NN=NN_global; | ||||
|   if ( do_memory ) { | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << " Memory benchmark " <<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     Benchmark::Memory(); | ||||
|   } | ||||
|  | ||||
|   if ( do_comms && (NN>1) ) { | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     std::cout<<GridLogMessage << " Communications benchmark " <<std::endl; | ||||
|     std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|     Benchmark::Comms(); | ||||
|   } | ||||
|  | ||||
|   if ( do_dwf ) { | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << " Per Node Summary table Ls="<<Ls <<std::endl; | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << " L \t\t Wilson\t\t DWF4  \t\t DWF5 " <<std::endl; | ||||
|   for(int l=0;l<L_list.size();l++){ | ||||
|     std::cout<<GridLogMessage << L_list[l] <<" \t\t "<< wilson[l]/NN<<" \t "<<dwf4[l]/NN<<" \t "<<dwf5[l] /NN<<std::endl; | ||||
|   } | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << " Comparison point     result: "  << 0.5*(dwf4[sel]+dwf4[selm1])/NN << " Mflop/s per node"<<std::endl; | ||||
|   std::cout<<GridLogMessage << " Comparison point is 0.5*("<<dwf4[sel]/NN<<"+"<<dwf4[selm1]/NN << ") "<<std::endl; | ||||
|   std::cout<<std::setprecision(3); | ||||
|   std::cout<<GridLogMessage << " Comparison point robustness: "  << robust_list[sel] <<std::endl; | ||||
|   std::cout<<GridLogMessage << "=================================================================================="<<std::endl; | ||||
|  | ||||
|   } | ||||
|  | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
| @@ -31,6 +31,32 @@ using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| struct time_statistics{ | ||||
|   double mean; | ||||
|   double err; | ||||
|   double min; | ||||
|   double max; | ||||
|  | ||||
|   void statistics(std::vector<double> v){ | ||||
|       double sum = std::accumulate(v.begin(), v.end(), 0.0); | ||||
|       mean = sum / v.size(); | ||||
|  | ||||
|       std::vector<double> diff(v.size()); | ||||
|       std::transform(v.begin(), v.end(), diff.begin(), [=](double x) { return x - mean; }); | ||||
|       double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); | ||||
|       err = std::sqrt(sq_sum / (v.size()*(v.size() - 1))); | ||||
|  | ||||
|       auto result = std::minmax_element(v.begin(), v.end()); | ||||
|       min = *result.first; | ||||
|       max = *result.second; | ||||
| } | ||||
| }; | ||||
|  | ||||
| void header(){ | ||||
|   std::cout <<GridLogMessage << " L  "<<"\t"<<" Ls  "<<"\t" | ||||
|             <<std::setw(11)<<"bytes"<<"MB/s uni (err/min/max)"<<"\t\t"<<"MB/s bidi (err/min/max)"<<std::endl; | ||||
| }; | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
| @@ -40,18 +66,21 @@ int main (int argc, char ** argv) | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   int Nloop=10; | ||||
|   int Nloop=100; | ||||
|   int nmu=0; | ||||
|   for(int mu=0;mu<4;mu++) if (mpi_layout[mu]>1) nmu++; | ||||
|   int maxlat=32; | ||||
|   for(int mu=0;mu<Nd;mu++) if (mpi_layout[mu]>1) nmu++; | ||||
|  | ||||
|   std::cout << GridLogMessage << "Number of iterations to average: "<< Nloop << std::endl; | ||||
|   std::vector<double> t_time(Nloop); | ||||
|   time_statistics timestat; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking concurrent halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<" Ls  "<<"\t\t"<<"bytes"<<"\t\t"<<"MB/s uni"<<"\t\t"<<"MB/s bidi"<<std::endl; | ||||
|  | ||||
|  | ||||
|  | ||||
|   for(int lat=4;lat<=32;lat+=2){ | ||||
|     for(int Ls=1;Ls<=16;Ls*=2){ | ||||
|   header(); | ||||
|   for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|     for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
|       				    lat*mpi_layout[1], | ||||
| @@ -59,17 +88,25 @@ int main (int argc, char ** argv) | ||||
|       				    lat*mpi_layout[3]}); | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       RealD Nrank = Grid._Nprocessors; | ||||
|       RealD Nnode = Grid.NodeCount(); | ||||
|       RealD ppn = Nrank/Nnode; | ||||
|  | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > xbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > rbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|       std::vector<Vector<HalfSpinColourVectorD> > xbuf(8);	 | ||||
|       std::vector<Vector<HalfSpinColourVectorD> > rbuf(8); | ||||
|  | ||||
|       int ncomm; | ||||
|       int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
|       for(int mu=0;mu<8;mu++){ | ||||
| 	xbuf[mu].resize(lat*lat*lat*Ls); | ||||
| 	rbuf[mu].resize(lat*lat*lat*Ls); | ||||
| 	//	std::cout << " buffers " << std::hex << (uint64_t)&xbuf[mu][0] <<" " << (uint64_t)&rbuf[mu][0] <<std::endl; | ||||
|       } | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|       double start=usecond(); | ||||
|  | ||||
| 	std::vector<CartesianCommunicator::CommsRequest_t> requests; | ||||
| 	std::vector<CommsRequest_t> requests; | ||||
|  | ||||
| 	ncomm=0; | ||||
| 	for(int mu=0;mu<4;mu++){ | ||||
| @@ -80,7 +117,6 @@ int main (int argc, char ** argv) | ||||
| 	    int comm_proc=1; | ||||
| 	    int xmit_to_rank; | ||||
| 	    int recv_from_rank; | ||||
| 	     | ||||
| 	    Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    Grid.SendToRecvFromBegin(requests, | ||||
| 				   (void *)&xbuf[mu][0], | ||||
| @@ -103,18 +139,24 @@ int main (int argc, char ** argv) | ||||
| 	} | ||||
| 	Grid.SendToRecvFromComplete(requests); | ||||
| 	Grid.Barrier(); | ||||
|  | ||||
| 	double stop=usecond(); | ||||
| 	t_time[i] = stop-start; // microseconds | ||||
|       } | ||||
|       double stop=usecond(); | ||||
|  | ||||
|       double dbytes    = bytes; | ||||
|       double xbytes    = Nloop*dbytes*2.0*ncomm; | ||||
|       timestat.statistics(t_time); | ||||
|  | ||||
|       double dbytes    = bytes*ppn; | ||||
|       double xbytes    = dbytes*2.0*ncomm; | ||||
|       double rbytes    = xbytes; | ||||
|       double bidibytes = xbytes+rbytes; | ||||
|  | ||||
|       double time = stop-start; // microseconds | ||||
|       std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
|                <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
|                <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
|                <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
|                << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
|                << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|  | ||||
|       std::cout<<GridLogMessage << lat<<"\t\t"<<Ls<<"\t\t"<<bytes<<"\t\t"<<xbytes/time<<"\t\t"<<bidibytes/time<<std::endl; | ||||
|     } | ||||
|   }     | ||||
|  | ||||
| @@ -122,25 +164,36 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking sequential halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<" Ls  "<<"\t\t"<<"bytes"<<"\t\t"<<"MB/s uni"<<"\t\t"<<"MB/s bidi"<<std::endl; | ||||
|   header(); | ||||
|  | ||||
|   for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|     for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
|   for(int lat=4;lat<=32;lat+=2){ | ||||
|     for(int Ls=1;Ls<=16;Ls*=2){ | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
|                                     lat*mpi_layout[1], | ||||
|                                     lat*mpi_layout[2], | ||||
|                                     lat*mpi_layout[3]}); | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat,lat,lat,lat}); | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       RealD Nrank = Grid._Nprocessors; | ||||
|       RealD Nnode = Grid.NodeCount(); | ||||
|       RealD ppn = Nrank/Nnode; | ||||
|  | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > xbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > rbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|       std::vector<Vector<HalfSpinColourVectorD> > xbuf(8); | ||||
|       std::vector<Vector<HalfSpinColourVectorD> > rbuf(8); | ||||
|  | ||||
|       for(int mu=0;mu<8;mu++){ | ||||
| 	xbuf[mu].resize(lat*lat*lat*Ls); | ||||
| 	rbuf[mu].resize(lat*lat*lat*Ls); | ||||
| 	//	std::cout << " buffers " << std::hex << (uint64_t)&xbuf[mu][0] <<" " << (uint64_t)&rbuf[mu][0] <<std::endl; | ||||
|       } | ||||
|  | ||||
|       int ncomm; | ||||
|       int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|       double start=usecond(); | ||||
|      | ||||
| 	ncomm=0; | ||||
| 	for(int mu=0;mu<4;mu++){ | ||||
| @@ -153,7 +206,7 @@ int main (int argc, char ** argv) | ||||
| 	    int recv_from_rank; | ||||
| 	     | ||||
| 	    { | ||||
| 	      std::vector<CartesianCommunicator::CommsRequest_t> requests; | ||||
| 	      std::vector<CommsRequest_t> requests; | ||||
| 	      Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	      Grid.SendToRecvFromBegin(requests, | ||||
| 				       (void *)&xbuf[mu][0], | ||||
| @@ -166,7 +219,7 @@ int main (int argc, char ** argv) | ||||
|  | ||||
| 	    comm_proc = mpi_layout[mu]-1; | ||||
| 	    { | ||||
| 	      std::vector<CartesianCommunicator::CommsRequest_t> requests; | ||||
| 	      std::vector<CommsRequest_t> requests; | ||||
| 	      Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	      Grid.SendToRecvFromBegin(requests, | ||||
| 				       (void *)&xbuf[mu+4][0], | ||||
| @@ -179,143 +232,315 @@ int main (int argc, char ** argv) | ||||
| 	  } | ||||
| 	} | ||||
| 	Grid.Barrier(); | ||||
| 	double stop=usecond(); | ||||
| 	t_time[i] = stop-start; // microseconds | ||||
|  | ||||
|       } | ||||
|  | ||||
|       double stop=usecond(); | ||||
|       timestat.statistics(t_time); | ||||
|        | ||||
|       double dbytes    = bytes; | ||||
|       double xbytes    = Nloop*dbytes*2.0*ncomm; | ||||
|       double dbytes    = bytes*ppn; | ||||
|       double xbytes    = dbytes*2.0*ncomm; | ||||
|       double rbytes    = xbytes; | ||||
|       double bidibytes = xbytes+rbytes; | ||||
|  | ||||
|       double time = stop-start; | ||||
|     std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
|                <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
|                <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
|                <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
|                << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
|                << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|  | ||||
|       std::cout<<GridLogMessage << lat<<"\t\t"<<Ls<<"\t\t"<<bytes<<"\t\t"<<xbytes/time<<"\t\t"<<bidibytes/time<<std::endl; | ||||
|        | ||||
|     } | ||||
|   }   | ||||
|  | ||||
| #if 0 | ||||
|  | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking sequential persistent halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking concurrent STENCIL halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<" Ls  "<<"\t\t"<<"bytes"<<"\t\t"<<"MB/s uni"<<"\t\t"<<"MB/s bidi"<<std::endl; | ||||
|   header(); | ||||
|  | ||||
|   for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|     for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
|   for(int lat=4;lat<=32;lat+=2){ | ||||
|     for(int Ls=1;Ls<=16;Ls*=2){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat,lat,lat,lat}); | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
|       				    lat*mpi_layout[1], | ||||
|       				    lat*mpi_layout[2], | ||||
|       				    lat*mpi_layout[3]}); | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       RealD Nrank = Grid._Nprocessors; | ||||
|       RealD Nnode = Grid.NodeCount(); | ||||
|       RealD ppn = Nrank/Nnode; | ||||
|  | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > xbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|       std::vector<std::vector<HalfSpinColourVectorD> > rbuf(8,std::vector<HalfSpinColourVectorD>(lat*lat*lat*Ls)); | ||||
|  | ||||
|       std::vector<HalfSpinColourVectorD *> xbuf(8); | ||||
|       std::vector<HalfSpinColourVectorD *> rbuf(8); | ||||
|       Grid.ShmBufferFreeAll(); | ||||
|       for(int d=0;d<8;d++){ | ||||
| 	xbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	rbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)xbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)rbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
|       } | ||||
|  | ||||
|       int ncomm; | ||||
|       int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
|  | ||||
|       double dbytes; | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
| 	double start=usecond(); | ||||
|  | ||||
|       std::vector<CartesianCommunicator::CommsRequest_t> empty; | ||||
|       std::vector<std::vector<CartesianCommunicator::CommsRequest_t> > requests_fwd(Nd,empty); | ||||
|       std::vector<std::vector<CartesianCommunicator::CommsRequest_t> > requests_bwd(Nd,empty); | ||||
|  | ||||
|       for(int mu=0;mu<4;mu++){ | ||||
| 	dbytes=0; | ||||
| 	ncomm=0; | ||||
| 	if (mpi_layout[mu]>1 ) { | ||||
| 	  ncomm++; | ||||
|  | ||||
| 	  int comm_proc; | ||||
| 	  int xmit_to_rank; | ||||
| 	  int recv_from_rank; | ||||
| 	std::vector<CommsRequest_t> requests; | ||||
|  | ||||
| 	  comm_proc=1; | ||||
| 	  Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	  Grid.SendToRecvFromInit(requests_fwd[mu], | ||||
| 				  (void *)&xbuf[mu][0], | ||||
| 				  xmit_to_rank, | ||||
| 				  (void *)&rbuf[mu][0], | ||||
| 				  recv_from_rank, | ||||
| 				  bytes); | ||||
| 	for(int mu=0;mu<4;mu++){ | ||||
| 	 | ||||
|  | ||||
| 	  comm_proc = mpi_layout[mu]-1; | ||||
| 	  Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	  Grid.SendToRecvFromInit(requests_bwd[mu], | ||||
| 				  (void *)&xbuf[mu+4][0], | ||||
| 				  xmit_to_rank, | ||||
| 				  (void *)&rbuf[mu+4][0], | ||||
| 				  recv_from_rank, | ||||
| 				  bytes); | ||||
|  | ||||
| 	} | ||||
|       } | ||||
|  | ||||
|       { | ||||
| 	double start=usecond(); | ||||
| 	for(int i=0;i<Nloop;i++){ | ||||
| 	  if (mpi_layout[mu]>1 ) { | ||||
| 	   | ||||
| 	  for(int mu=0;mu<4;mu++){ | ||||
| 	     | ||||
| 	    if (mpi_layout[mu]>1 ) { | ||||
| 	       | ||||
| 	      Grid.SendToRecvFromBegin(requests_fwd[mu]); | ||||
| 	      Grid.SendToRecvFromComplete(requests_fwd[mu]); | ||||
| 	      Grid.SendToRecvFromBegin(requests_bwd[mu]); | ||||
| 	      Grid.SendToRecvFromComplete(requests_bwd[mu]); | ||||
| 	    } | ||||
| 	  } | ||||
| 	  Grid.Barrier(); | ||||
| 	} | ||||
| 	    ncomm++; | ||||
| 	    int comm_proc=1; | ||||
| 	    int xmit_to_rank; | ||||
| 	    int recv_from_rank; | ||||
| 	    Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    dbytes+= | ||||
| 	      Grid.StencilSendToRecvFromBegin(requests, | ||||
| 					      (void *)&xbuf[mu][0], | ||||
| 					      xmit_to_rank, | ||||
| 					      (void *)&rbuf[mu][0], | ||||
| 					      recv_from_rank, | ||||
| 					      bytes,mu); | ||||
| 	 | ||||
| 	double stop=usecond(); | ||||
| 	 | ||||
| 	double dbytes    = bytes; | ||||
| 	double xbytes    = Nloop*dbytes*2.0*ncomm; | ||||
| 	double rbytes    = xbytes; | ||||
| 	double bidibytes = xbytes+rbytes; | ||||
| 	 | ||||
| 	double time = stop-start; | ||||
| 	 | ||||
| 	std::cout<<GridLogMessage << lat<<"\t\t"<<Ls<<"\t\t"<<bytes<<"\t\t"<<xbytes/time<<"\t\t"<<bidibytes/time<<std::endl; | ||||
|  | ||||
|       } | ||||
|  | ||||
|  | ||||
|       { | ||||
| 	double start=usecond(); | ||||
| 	for(int i=0;i<Nloop;i++){ | ||||
| 	    comm_proc = mpi_layout[mu]-1; | ||||
| 	   | ||||
| 	    Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    dbytes+= | ||||
| 	      Grid.StencilSendToRecvFromBegin(requests, | ||||
| 					      (void *)&xbuf[mu+4][0], | ||||
| 					      xmit_to_rank, | ||||
| 					      (void *)&rbuf[mu+4][0], | ||||
| 					      recv_from_rank, | ||||
| 					      bytes,mu+4); | ||||
| 	   | ||||
| 	  for(int mu=0;mu<4;mu++){ | ||||
| 	     | ||||
| 	    if (mpi_layout[mu]>1 ) { | ||||
| 	       | ||||
| 	      Grid.SendToRecvFromBegin(requests_fwd[mu]); | ||||
| 	      Grid.SendToRecvFromBegin(requests_bwd[mu]); | ||||
| 	      Grid.SendToRecvFromComplete(requests_fwd[mu]); | ||||
| 	      Grid.SendToRecvFromComplete(requests_bwd[mu]); | ||||
| 	    } | ||||
| 	  } | ||||
| 	  Grid.Barrier(); | ||||
| 	} | ||||
| 	 | ||||
| 	Grid.StencilSendToRecvFromComplete(requests,0); | ||||
| 	Grid.Barrier(); | ||||
| 	double stop=usecond(); | ||||
| 	t_time[i] = stop-start; // microseconds | ||||
| 	 | ||||
| 	double dbytes    = bytes; | ||||
| 	double xbytes    = Nloop*dbytes*2.0*ncomm; | ||||
| 	double rbytes    = xbytes; | ||||
| 	double bidibytes = xbytes+rbytes; | ||||
| 	 | ||||
| 	double time = stop-start; | ||||
| 	 | ||||
| 	std::cout<<GridLogMessage << lat<<"\t\t"<<Ls<<"\t\t"<<bytes<<"\t\t"<<xbytes/time<<"\t\t"<<bidibytes/time<<std::endl; | ||||
|  | ||||
|       } | ||||
|  | ||||
|       timestat.statistics(t_time); | ||||
|  | ||||
|       dbytes=dbytes*ppn; | ||||
|       double xbytes    = dbytes*0.5; | ||||
|       double rbytes    = dbytes*0.5; | ||||
|       double bidibytes = dbytes; | ||||
|  | ||||
|       std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
|                <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
|                <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
|                <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
|                << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
|                << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|  | ||||
|  | ||||
|     } | ||||
|   } | ||||
|   }     | ||||
|  | ||||
|  | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking sequential STENCIL halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   header(); | ||||
|  | ||||
|   for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|     for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
|       				    lat*mpi_layout[1], | ||||
|       				    lat*mpi_layout[2], | ||||
|       				    lat*mpi_layout[3]}); | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       RealD Nrank = Grid._Nprocessors; | ||||
|       RealD Nnode = Grid.NodeCount(); | ||||
|       RealD ppn = Nrank/Nnode; | ||||
|  | ||||
|       std::vector<HalfSpinColourVectorD *> xbuf(8); | ||||
|       std::vector<HalfSpinColourVectorD *> rbuf(8); | ||||
|       Grid.ShmBufferFreeAll(); | ||||
|       for(int d=0;d<8;d++){ | ||||
| 	xbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	rbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)xbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)rbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
|       } | ||||
|  | ||||
|       int ncomm; | ||||
|       int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
|       double dbytes; | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
| 	double start=usecond(); | ||||
|  | ||||
| 	std::vector<CommsRequest_t> requests; | ||||
| 	dbytes=0; | ||||
| 	ncomm=0; | ||||
| 	for(int mu=0;mu<4;mu++){ | ||||
| 	 | ||||
| 	  if (mpi_layout[mu]>1 ) { | ||||
| 	   | ||||
| 	    ncomm++; | ||||
| 	    int comm_proc=1; | ||||
| 	    int xmit_to_rank; | ||||
| 	    int recv_from_rank; | ||||
| 	     | ||||
| 	    Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    dbytes+= | ||||
| 	      Grid.StencilSendToRecvFromBegin(requests, | ||||
| 					      (void *)&xbuf[mu][0], | ||||
| 					      xmit_to_rank, | ||||
| 					      (void *)&rbuf[mu][0], | ||||
| 					      recv_from_rank, | ||||
| 					      bytes,mu); | ||||
| 	    Grid.StencilSendToRecvFromComplete(requests,mu); | ||||
| 	    requests.resize(0); | ||||
|  | ||||
| 	    comm_proc = mpi_layout[mu]-1; | ||||
| 	   | ||||
| 	    Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    dbytes+= | ||||
| 	      Grid.StencilSendToRecvFromBegin(requests, | ||||
| 					      (void *)&xbuf[mu+4][0], | ||||
| 					      xmit_to_rank, | ||||
| 					      (void *)&rbuf[mu+4][0], | ||||
| 					      recv_from_rank, | ||||
| 					      bytes,mu+4); | ||||
| 	    Grid.StencilSendToRecvFromComplete(requests,mu+4); | ||||
| 	    requests.resize(0); | ||||
| 	   | ||||
| 	  } | ||||
| 	} | ||||
| 	Grid.Barrier(); | ||||
| 	double stop=usecond(); | ||||
| 	t_time[i] = stop-start; // microseconds | ||||
| 	 | ||||
|       } | ||||
|  | ||||
|       timestat.statistics(t_time); | ||||
|  | ||||
|       dbytes=dbytes*ppn; | ||||
|       double xbytes    = dbytes*0.5; | ||||
|       double rbytes    = dbytes*0.5; | ||||
|       double bidibytes = dbytes; | ||||
|  | ||||
|  | ||||
|       std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
|                <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
|                <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
|                <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
|                << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
|                << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|   | ||||
|     } | ||||
|   }     | ||||
|  | ||||
|  | ||||
| #ifdef GRID_OMP | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking threaded STENCIL halo exchange in "<<nmu<<" dimensions"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   header(); | ||||
|  | ||||
|   for(int lat=4;lat<=maxlat;lat+=4){ | ||||
|     for(int Ls=8;Ls<=8;Ls*=2){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0], | ||||
|       				    lat*mpi_layout[1], | ||||
|       				    lat*mpi_layout[2], | ||||
|       				    lat*mpi_layout[3]}); | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       RealD Nrank = Grid._Nprocessors; | ||||
|       RealD Nnode = Grid.NodeCount(); | ||||
|       RealD ppn = Nrank/Nnode; | ||||
|  | ||||
|       std::vector<HalfSpinColourVectorD *> xbuf(8); | ||||
|       std::vector<HalfSpinColourVectorD *> rbuf(8); | ||||
|       Grid.ShmBufferFreeAll(); | ||||
|       for(int d=0;d<8;d++){ | ||||
| 	xbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	rbuf[d] = (HalfSpinColourVectorD *)Grid.ShmBufferMalloc(lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)xbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
| 	bzero((void *)rbuf[d],lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD)); | ||||
|       } | ||||
|  | ||||
|       int ncomm; | ||||
|       int bytes=lat*lat*lat*Ls*sizeof(HalfSpinColourVectorD); | ||||
|       double dbytes; | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
| 	double start=usecond(); | ||||
|  | ||||
| 	std::vector<CommsRequest_t> requests; | ||||
| 	dbytes=0; | ||||
| 	ncomm=0; | ||||
|  | ||||
| #pragma omp parallel for num_threads(Grid::CartesianCommunicator::nCommThreads) | ||||
| 	for(int dir=0;dir<8;dir++){ | ||||
|  | ||||
| 	  double tbytes; | ||||
| 	  int mu =dir % 4; | ||||
|  | ||||
| 	  if (mpi_layout[mu]>1 ) { | ||||
| 	   | ||||
| 	    ncomm++; | ||||
| 	    int xmit_to_rank; | ||||
| 	    int recv_from_rank; | ||||
| 	    if ( dir == mu ) {  | ||||
| 	      int comm_proc=1; | ||||
| 	      Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    } else {  | ||||
| 	      int comm_proc = mpi_layout[mu]-1; | ||||
| 	      Grid.ShiftedRanks(mu,comm_proc,xmit_to_rank,recv_from_rank); | ||||
| 	    } | ||||
|             int tid = omp_get_thread_num(); | ||||
| 	    tbytes= Grid.StencilSendToRecvFrom((void *)&xbuf[dir][0], xmit_to_rank, | ||||
| 					       (void *)&rbuf[dir][0], recv_from_rank, bytes,tid); | ||||
|  | ||||
| #pragma omp atomic | ||||
| 	    dbytes+=tbytes; | ||||
| 	  } | ||||
| 	} | ||||
| 	Grid.Barrier(); | ||||
| 	double stop=usecond(); | ||||
| 	t_time[i] = stop-start; // microseconds | ||||
|       } | ||||
|  | ||||
|       timestat.statistics(t_time); | ||||
|  | ||||
|       dbytes=dbytes*ppn; | ||||
|       double xbytes    = dbytes*0.5; | ||||
|       double rbytes    = dbytes*0.5; | ||||
|       double bidibytes = dbytes; | ||||
|  | ||||
|  | ||||
|       std::cout<<GridLogMessage << std::setw(4) << lat<<"\t"<<Ls<<"\t" | ||||
|                <<std::setw(11) << bytes<< std::fixed << std::setprecision(1) << std::setw(7) | ||||
|                <<std::right<< xbytes/timestat.mean<<"  "<< xbytes*timestat.err/(timestat.mean*timestat.mean)<< " " | ||||
|                <<xbytes/timestat.max <<" "<< xbytes/timestat.min   | ||||
|                << "\t\t"<<std::setw(7)<< bidibytes/timestat.mean<< "  " << bidibytes*timestat.err/(timestat.mean*timestat.mean) << " " | ||||
|                << bidibytes/timestat.max << " " << bidibytes/timestat.min << std::endl; | ||||
|   | ||||
|     } | ||||
|   }     | ||||
| #endif | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= All done; Bye Bye"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
|   | ||||
| @@ -1,28 +1,22 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|  /************************************************************************************* | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_dwf.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|     Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
|     Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| @@ -37,32 +31,36 @@ struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
|   Gamma::GammaMatrix Gmu [] = { | ||||
|     Gamma::GammaX, | ||||
|     Gamma::GammaY, | ||||
|     Gamma::GammaZ, | ||||
|     Gamma::GammaT | ||||
|   Gamma::Algebra Gmu [] = { | ||||
|     Gamma::Algebra::GammaX, | ||||
|     Gamma::Algebra::GammaY, | ||||
|     Gamma::Algebra::GammaZ, | ||||
|     Gamma::Algebra::GammaT | ||||
|   }; | ||||
|  | ||||
| bool overlapComms = false; | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplR> WilsonFermion5DR; | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplF> WilsonFermion5DF; | ||||
| typedef WilsonFermion5D<DomainWallVec5dImplD> WilsonFermion5DD; | ||||
|  | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   if( GridCmdOptionExists(argv,argv+argc,"--asynch") ){ | ||||
|     overlapComms = true; | ||||
|   } | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   std::vector<int> latt4 = GridDefaultLatt(); | ||||
|   const int Ls=16; | ||||
|   int Ls=16; | ||||
|   for(int i=0;i<argc;i++) | ||||
|     if(std::string(argv[i]) == "-Ls"){ | ||||
|       std::stringstream ss(argv[i+1]); ss >> Ls; | ||||
|     } | ||||
|  | ||||
|   GridLogLayout(); | ||||
|  | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|  | ||||
|  | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
| @@ -76,35 +74,66 @@ int main (int argc, char ** argv) | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
|  | ||||
|    | ||||
|   std::cout << GridLogMessage << "Initialising 4d RNG" << std::endl; | ||||
|   GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|   std::cout << GridLogMessage << "Initialising 5d RNG" << std::endl; | ||||
|   GridParallelRNG          RNG5(FGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|   std::cout << GridLogMessage << "Initialised RNGs" << std::endl; | ||||
|  | ||||
|   LatticeFermion src   (FGrid); random(RNG5,src); | ||||
| #if 0 | ||||
|   src = zero; | ||||
|   { | ||||
|     std::vector<int> origin({0,0,0,latt4[2]-1,0}); | ||||
|     SpinColourVectorF tmp; | ||||
|     tmp=zero; | ||||
|     tmp()(0)(0)=Complex(-2.0,0.0); | ||||
|     std::cout << " source site 0 " << tmp<<std::endl; | ||||
|     pokeSite(tmp,src,origin); | ||||
|   } | ||||
| #else | ||||
|   RealD N2 = 1.0/::sqrt(norm2(src)); | ||||
|   src = src*N2; | ||||
| #endif | ||||
|  | ||||
|  | ||||
|   LatticeFermion result(FGrid); result=zero; | ||||
|   LatticeFermion    ref(FGrid);    ref=zero; | ||||
|   LatticeFermion    tmp(FGrid); | ||||
|   LatticeFermion    err(FGrid); | ||||
|  | ||||
|   std::cout << GridLogMessage << "Drawing gauge field" << std::endl; | ||||
|   LatticeGaugeField Umu(UGrid);  | ||||
|   random(RNG4,Umu); | ||||
|  | ||||
|   LatticeGaugeField Umu5d(FGrid);  | ||||
|   SU3::HotConfiguration(RNG4,Umu);  | ||||
|   std::cout << GridLogMessage << "Random gauge initialised " << std::endl; | ||||
| #if 0 | ||||
|   Umu=1.0; | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     LatticeColourMatrix ttmp(UGrid); | ||||
|     ttmp = PeekIndex<LorentzIndex>(Umu,mu); | ||||
|     //    if (mu !=2 ) ttmp = 0; | ||||
|     //    ttmp = ttmp* pow(10.0,mu); | ||||
|     PokeIndex<LorentzIndex>(Umu,ttmp,mu); | ||||
|   } | ||||
|   std::cout << GridLogMessage << "Forced to diagonal " << std::endl; | ||||
| #endif | ||||
|  | ||||
|   //////////////////////////////////// | ||||
|   // Naive wilson implementation | ||||
|   //////////////////////////////////// | ||||
|   // replicate across fifth dimension | ||||
|   LatticeGaugeField Umu5d(FGrid);  | ||||
|   std::vector<LatticeColourMatrix> U(4,FGrid); | ||||
|   for(int ss=0;ss<Umu._grid->oSites();ss++){ | ||||
|     for(int s=0;s<Ls;s++){ | ||||
|       Umu5d._odata[Ls*ss+s] = Umu._odata[ss]; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   //////////////////////////////////// | ||||
|   // Naive wilson implementation | ||||
|   //////////////////////////////////// | ||||
|   std::vector<LatticeColourMatrix> U(4,FGrid); | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     U[mu] = PeekIndex<LorentzIndex>(Umu5d,mu); | ||||
|   } | ||||
|   std::cout << GridLogMessage << "Setting up Cshift based reference " << std::endl; | ||||
|  | ||||
|   if (1) | ||||
|   { | ||||
| @@ -125,19 +154,32 @@ int main (int argc, char ** argv) | ||||
|   RealD M5  =1.8; | ||||
|  | ||||
|   RealD NP = UGrid->_Nprocessors; | ||||
|   RealD NN = UGrid->NodeCount(); | ||||
|  | ||||
|   for(int doasm=1;doasm<2;doasm++){ | ||||
|  | ||||
|     QCD::WilsonKernelsStatic::AsmOpt=doasm; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Kernel options --dslash-generic, --dslash-unroll, --dslash-asm" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Benchmarking DomainWallFermionR::Dhop                  "<<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Vectorising space-time by "<<vComplex::Nsimd()<<std::endl; | ||||
|   if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
|   if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| #ifdef GRID_OMP | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| #endif | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|  | ||||
|   DomainWallFermionR Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|    | ||||
|   std::cout<<GridLogMessage << "Naive wilson implementation "<<std::endl; | ||||
|   std::cout << GridLogMessage<< "Calling Dw"<<std::endl; | ||||
|   int ncall =100; | ||||
|   int ncall =500; | ||||
|   if (1) { | ||||
|  | ||||
|     FGrid->Barrier(); | ||||
|     Dw.ZeroCounters(); | ||||
|     Dw.Dhop(src,result,0); | ||||
|     std::cout<<GridLogMessage<<"Called warmup"<<std::endl; | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
| @@ -145,95 +187,151 @@ int main (int argc, char ** argv) | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=1344*volume*ncall; | ||||
|     double flops=single_site_flops*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     err = ref-result;  | ||||
|     std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|  | ||||
|     /* | ||||
|     if(( norm2(err)>1.0e-4) ) {  | ||||
|       std::cout << "RESULT\n " << result<<std::endl; | ||||
|       std::cout << "REF   \n " << ref   <<std::endl; | ||||
|       std::cout << "ERR   \n " << err   <<std::endl; | ||||
|       FGrid->Barrier(); | ||||
|       exit(-1); | ||||
|     } | ||||
|     */ | ||||
|     assert (norm2(err)< 1.0e-4 ); | ||||
|     Dw.Report(); | ||||
|   } | ||||
|  | ||||
|   DomainWallFermionRL DwH(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|   if (1) { | ||||
|     FGrid->Barrier(); | ||||
|     DwH.ZeroCounters(); | ||||
|     DwH.Dhop(src,result,0); | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
|       DwH.Dhop(src,result,0); | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=single_site_flops*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called half prec comms Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     err = ref-result;  | ||||
|     std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|  | ||||
|     assert (norm2(err)< 1.0e-3 ); | ||||
|     DwH.Report(); | ||||
|   } | ||||
|  | ||||
|   if (1) | ||||
|   { | ||||
|  | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|     std::cout << GridLogMessage<< "* Benchmarking WilsonFermion5D<DomainWallVec5dImplR>::Dhop "<<std::endl; | ||||
|     std::cout << GridLogMessage<< "* Vectorising fifth dimension by "<<vComplex::Nsimd()<<std::endl; | ||||
|     if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
|     if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| #ifdef GRID_OMP | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| #endif | ||||
|     if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|     if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|     if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|  | ||||
|     typedef WilsonFermion5D<DomainWallVec5dImplR> WilsonFermion5DR; | ||||
|     LatticeFermion ssrc(sFGrid); | ||||
|     LatticeFermion sref(sFGrid); | ||||
|     LatticeFermion sresult(sFGrid); | ||||
|  | ||||
|     WilsonFermion5DR sDw(Umu,*sFGrid,*sFrbGrid,*sUGrid,*sUrbGrid,M5); | ||||
|    | ||||
|     for(int x=0;x<latt4[0];x++){ | ||||
|     for(int y=0;y<latt4[1];y++){ | ||||
|     for(int z=0;z<latt4[2];z++){ | ||||
|     for(int t=0;t<latt4[3];t++){ | ||||
|     for(int s=0;s<Ls;s++){ | ||||
|       std::vector<int> site({s,x,y,z,t}); | ||||
|       SpinColourVector tmp; | ||||
|       peekSite(tmp,src,site); | ||||
|       pokeSite(tmp,ssrc,site); | ||||
|     }}}}} | ||||
|  | ||||
|     localConvert(src,ssrc); | ||||
|     std::cout<<GridLogMessage<< "src norms "<< norm2(src)<<" " <<norm2(ssrc)<<std::endl; | ||||
|     double t0=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|     sDw.Dhop(ssrc,sresult,0); | ||||
|     sDw.ZeroCounters(); | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
|       sDw.Dhop(ssrc,sresult,0); | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=1344*volume*ncall; | ||||
|     double flops=single_site_flops*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called Dw s_inner "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     //    std::cout<<GridLogMessage<< "res norms "<< norm2(result)<<" " <<norm2(sresult)<<std::endl; | ||||
|     sDw.Report(); | ||||
|    | ||||
|     if(0){ | ||||
|       for(int i=0;i< PerformanceCounter::NumTypes(); i++ ){ | ||||
|   sDw.Dhop(ssrc,sresult,0); | ||||
|   PerformanceCounter Counter(i); | ||||
|   Counter.Start(); | ||||
|   sDw.Dhop(ssrc,sresult,0); | ||||
|   Counter.Stop(); | ||||
|   Counter.Report(); | ||||
|       } | ||||
|     RealD sum=0; | ||||
|  | ||||
|     err=zero; | ||||
|     localConvert(sresult,err); | ||||
|     err = err - ref; | ||||
|     sum = norm2(err); | ||||
|     std::cout<<GridLogMessage<<" difference between normal ref and simd is "<<sum<<std::endl; | ||||
|     if(sum > 1.0e-4 ){ | ||||
|       std::cout<< "sD REF\n " <<ref << std::endl; | ||||
|       std::cout<< "sD ERR   \n " <<err  <<std::endl; | ||||
|     } | ||||
|     //    assert(sum < 1.0e-4); | ||||
|  | ||||
|     std::cout<<GridLogMessage<< "res norms "<< norm2(result)<<" " <<norm2(sresult)<<std::endl; | ||||
|     err=zero; | ||||
|     localConvert(sresult,err); | ||||
|     err = err - result; | ||||
|     sum = norm2(err); | ||||
|     std::cout<<GridLogMessage<<" difference between normal result and simd is "<<sum<<std::endl; | ||||
|     if(sum > 1.0e-4 ){ | ||||
|       std::cout<< "sD REF\n " <<result << std::endl; | ||||
|       std::cout<< "sD ERR   \n " << err  <<std::endl; | ||||
|     } | ||||
|     assert(sum < 1.0e-4); | ||||
|  | ||||
|  | ||||
|     RealF sum=0; | ||||
|     for(int x=0;x<latt4[0];x++){ | ||||
|     for(int y=0;y<latt4[1];y++){ | ||||
|     for(int z=0;z<latt4[2];z++){ | ||||
|     for(int t=0;t<latt4[3];t++){ | ||||
|     for(int s=0;s<Ls;s++){ | ||||
|       std::vector<int> site({s,x,y,z,t}); | ||||
|       SpinColourVector normal, simd; | ||||
|       peekSite(normal,result,site); | ||||
|       peekSite(simd,sresult,site); | ||||
|       sum=sum+norm2(normal-simd); | ||||
|       if (norm2(normal-simd) > 1.0e-6 ) { | ||||
|   std::cout << "site "<<x<<","<<y<<","<<z<<","<<t<<","<<s<<" "<<norm2(normal-simd)<<std::endl; | ||||
|   std::cout << "site "<<x<<","<<y<<","<<z<<","<<t<<","<<s<<" normal "<<normal<<std::endl; | ||||
|   std::cout << "site "<<x<<","<<y<<","<<z<<","<<t<<","<<s<<" simd   "<<simd<<std::endl; | ||||
|       } | ||||
|     }}}}} | ||||
|     std::cout<<GridLogMessage<<" difference between normal and simd is "<<sum<<std::endl; | ||||
|  | ||||
|  | ||||
|     if (1) { | ||||
|      | ||||
|     if(1){ | ||||
|       std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|       std::cout << GridLogMessage<< "* Benchmarking WilsonFermion5D<DomainWallVec5dImplR>::DhopEO "<<std::endl; | ||||
|       std::cout << GridLogMessage<< "* Vectorising fifth dimension by "<<vComplex::Nsimd()<<std::endl; | ||||
|       if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
|       if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| #ifdef GRID_OMP | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| #endif | ||||
|       if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   )  | ||||
| 	std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|       if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll)  | ||||
| 	std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|       if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm )  | ||||
| 	std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|       std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|  | ||||
|       LatticeFermion sr_eo(sFGrid); | ||||
|       LatticeFermion serr(sFGrid); | ||||
|  | ||||
|       LatticeFermion ssrc_e (sFrbGrid); | ||||
|       LatticeFermion ssrc_o (sFrbGrid); | ||||
|       LatticeFermion sr_e   (sFrbGrid); | ||||
| @@ -241,29 +339,30 @@ int main (int argc, char ** argv) | ||||
|  | ||||
|       pickCheckerboard(Even,ssrc_e,ssrc); | ||||
|       pickCheckerboard(Odd,ssrc_o,ssrc); | ||||
|  | ||||
|       setCheckerboard(sr_eo,ssrc_o); | ||||
|       setCheckerboard(sr_eo,ssrc_e); | ||||
|       serr = sr_eo-ssrc;  | ||||
|       std::cout<<GridLogMessage << "EO src norm diff   "<< norm2(serr)<<std::endl; | ||||
|       //      setCheckerboard(sr_eo,ssrc_o); | ||||
|       //      setCheckerboard(sr_eo,ssrc_e); | ||||
|  | ||||
|       sr_e = zero; | ||||
|       sr_o = zero; | ||||
|  | ||||
|       FGrid->Barrier(); | ||||
|       sDw.DhopEO(ssrc_o, sr_e, DaggerNo); | ||||
|       sDw.ZeroCounters(); | ||||
|       sDw.stat.init("DhopEO"); | ||||
|       //      sDw.stat.init("DhopEO"); | ||||
|       double t0=usecond(); | ||||
|       for (int i = 0; i < ncall; i++) { | ||||
|         sDw.DhopEO(ssrc_o, sr_e, DaggerNo); | ||||
|       } | ||||
|       double t1=usecond(); | ||||
|       sDw.stat.print(); | ||||
|       FGrid->Barrier(); | ||||
|       //      sDw.stat.print(); | ||||
|  | ||||
|       double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|       double flops=(1344.0*volume*ncall)/2; | ||||
|       double flops=(single_site_flops*volume*ncall)/2.0; | ||||
|  | ||||
|       std::cout<<GridLogMessage << "sDeo mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|       std::cout<<GridLogMessage << "sDeo mflop/s per node   "<< flops/(t1-t0)/NP<<std::endl; | ||||
|       std::cout<<GridLogMessage << "sDeo mflop/s per rank   "<< flops/(t1-t0)/NP<<std::endl; | ||||
|       std::cout<<GridLogMessage << "sDeo mflop/s per node   "<< flops/(t1-t0)/NN<<std::endl; | ||||
|       sDw.Report(); | ||||
|  | ||||
|       sDw.DhopEO(ssrc_o,sr_e,DaggerNo); | ||||
| @@ -272,42 +371,75 @@ int main (int argc, char ** argv) | ||||
|  | ||||
|       pickCheckerboard(Even,ssrc_e,sresult); | ||||
|       pickCheckerboard(Odd ,ssrc_o,sresult); | ||||
|  | ||||
|       ssrc_e = ssrc_e - sr_e; | ||||
|       RealD error = norm2(ssrc_e); | ||||
|       std::cout<<GridLogMessage << "sE norm diff   "<< norm2(ssrc_e)<< "  vec nrm"<<norm2(sr_e) <<std::endl; | ||||
|  | ||||
|       ssrc_o = ssrc_o - sr_o; | ||||
|       error+= norm2(ssrc_o); | ||||
|       std::cout<<GridLogMessage << "sO norm diff   "<< norm2(ssrc_o)<< "  vec nrm"<<norm2(sr_o) <<std::endl; | ||||
|  | ||||
|       if(( error>1.0e-4) ) {  | ||||
| 	setCheckerboard(ssrc,ssrc_o); | ||||
| 	setCheckerboard(ssrc,ssrc_e); | ||||
| 	std::cout<< "DIFF\n " <<ssrc << std::endl; | ||||
| 	setCheckerboard(ssrc,sr_o); | ||||
| 	setCheckerboard(ssrc,sr_e); | ||||
| 	std::cout<< "CBRESULT\n " <<ssrc << std::endl; | ||||
| 	std::cout<< "RESULT\n " <<sresult<< std::endl; | ||||
|       } | ||||
|       assert(error<1.0e-4); | ||||
|     } | ||||
|  | ||||
|   if(0){ | ||||
|     std::cout << "Single cache warm call to sDw.Dhop " <<std::endl; | ||||
|     for(int i=0;i< PerformanceCounter::NumTypes(); i++ ){ | ||||
|       sDw.Dhop(ssrc,sresult,0); | ||||
|       PerformanceCounter Counter(i); | ||||
|       Counter.Start(); | ||||
|       sDw.Dhop(ssrc,sresult,0); | ||||
|       Counter.Stop(); | ||||
|       Counter.Report(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   } | ||||
|  | ||||
|  | ||||
|  | ||||
|   if (1) | ||||
|   { // Naive wilson dag implementation | ||||
|     ref = zero; | ||||
|     for(int mu=0;mu<Nd;mu++){ | ||||
|  | ||||
|       //    ref =  src - Gamma(Gamma::GammaX)* src ; // 1+gamma_x | ||||
|       //    ref =  src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x | ||||
|       tmp = U[mu]*Cshift(src,mu+1,1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
|   ref._odata[i]+= tmp._odata[i] + Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
| 	ref._odata[i]+= tmp._odata[i] + Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
|       } | ||||
|  | ||||
|       tmp =adj(U[mu])*src; | ||||
|       tmp =Cshift(tmp,mu+1,-1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
|   ref._odata[i]+= tmp._odata[i] - Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
| 	ref._odata[i]+= tmp._odata[i] - Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
|       } | ||||
|     } | ||||
|     ref = -0.5*ref; | ||||
|   } | ||||
|   //  dump=1; | ||||
|   Dw.Dhop(src,result,1); | ||||
|   std::cout << GridLogMessage << "Naive wilson implementation Dag" << std::endl; | ||||
|   std::cout << GridLogMessage << "Compare to naive wilson implementation Dag to verify correctness" << std::endl; | ||||
|   std::cout<<GridLogMessage << "Called DwDag"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm dag result "<< norm2(result)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm dag ref    "<< norm2(ref)<<std::endl; | ||||
|   err = ref-result;  | ||||
|   std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "norm dag diff   "<< norm2(err)<<std::endl; | ||||
|   if((norm2(err)>1.0e-4)){ | ||||
| 	std::cout<< "DAG RESULT\n "  <<ref     << std::endl; | ||||
| 	std::cout<< "DAG sRESULT\n " <<result  << std::endl; | ||||
| 	std::cout<< "DAG ERR   \n "  << err    <<std::endl; | ||||
|   } | ||||
|   LatticeFermion src_e (FrbGrid); | ||||
|   LatticeFermion src_o (FrbGrid); | ||||
|   LatticeFermion r_e   (FrbGrid); | ||||
| @@ -315,26 +447,45 @@ int main (int argc, char ** argv) | ||||
|   LatticeFermion r_eo  (FGrid); | ||||
|  | ||||
|  | ||||
|   std::cout<<GridLogMessage << "Calling Deo and Doe"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Calling Deo and Doe and //assert Deo+Doe == Dunprec"<<std::endl; | ||||
|   pickCheckerboard(Even,src_e,src); | ||||
|   pickCheckerboard(Odd,src_o,src); | ||||
|  | ||||
|   std::cout<<GridLogMessage << "src_e"<<norm2(src_e)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "src_o"<<norm2(src_o)<<std::endl; | ||||
|  | ||||
|  | ||||
|   // S-direction is INNERMOST and takes no part in the parity. | ||||
|   std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Benchmarking DomainWallFermionR::DhopEO                "<<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Vectorising space-time by "<<vComplex::Nsimd()<<std::endl; | ||||
|   if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
|   if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
| #ifdef GRID_OMP | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| #endif | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|   { | ||||
|     Dw.ZeroCounters(); | ||||
|     FGrid->Barrier(); | ||||
|     Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=(1344.0*volume*ncall)/2; | ||||
|     double flops=(single_site_flops*volume*ncall)/2.0; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Deo mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "Deo mflop/s per node   "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "Deo mflop/s per rank   "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "Deo mflop/s per node   "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     Dw.Report(); | ||||
|   } | ||||
|   Dw.DhopEO(src_o,r_e,DaggerNo); | ||||
| @@ -350,14 +501,20 @@ int main (int argc, char ** argv) | ||||
|  | ||||
|   err = r_eo-result;  | ||||
|   std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|   if((norm2(err)>1.0e-4)){ | ||||
| 	std::cout<< "Deo RESULT\n " <<r_eo << std::endl; | ||||
| 	std::cout<< "Deo REF\n " <<result  << std::endl; | ||||
| 	std::cout<< "Deo ERR   \n " << err <<std::endl; | ||||
|   } | ||||
|  | ||||
|   pickCheckerboard(Even,src_e,err); | ||||
|   pickCheckerboard(Odd,src_o,err); | ||||
|   std::cout<<GridLogMessage << "norm diff even  "<< norm2(src_e)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm diff odd   "<< norm2(src_o)<<std::endl; | ||||
|  | ||||
|  | ||||
|   } | ||||
|  | ||||
|   assert(norm2(src_e)<1.0e-4); | ||||
|   assert(norm2(src_o)<1.0e-4); | ||||
|   Grid_finalize(); | ||||
|   exit(0); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,153 +0,0 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_dwf.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| template<class d> | ||||
| struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
|   Gamma::GammaMatrix Gmu [] = { | ||||
|     Gamma::GammaX, | ||||
|     Gamma::GammaY, | ||||
|     Gamma::GammaZ, | ||||
|     Gamma::GammaT | ||||
|   }; | ||||
|  | ||||
| bool overlapComms = false; | ||||
|  | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   if( GridCmdOptionExists(argv,argv+argc,"--asynch") ){ | ||||
|     overlapComms = true; | ||||
|   } | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   std::vector<int> latt4 = GridDefaultLatt(); | ||||
|   const int Ls=16; | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
|  | ||||
|   GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|   GridParallelRNG          RNG5(FGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|  | ||||
|   LatticeFermion src   (FGrid); random(RNG5,src); | ||||
|   LatticeFermion result(FGrid); result=zero; | ||||
|   LatticeFermion    ref(FGrid);    ref=zero; | ||||
|   LatticeFermion    tmp(FGrid); | ||||
|   LatticeFermion    err(FGrid); | ||||
|  | ||||
|   ColourMatrix cm = Complex(1.0,0.0); | ||||
|  | ||||
|   LatticeGaugeField Umu(UGrid);  | ||||
|   random(RNG4,Umu); | ||||
|  | ||||
|   LatticeGaugeField Umu5d(FGrid);  | ||||
|  | ||||
|   // replicate across fifth dimension | ||||
|   for(int ss=0;ss<Umu._grid->oSites();ss++){ | ||||
|     for(int s=0;s<Ls;s++){ | ||||
|       Umu5d._odata[Ls*ss+s] = Umu._odata[ss]; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   //////////////////////////////////// | ||||
|   // Naive wilson implementation | ||||
|   //////////////////////////////////// | ||||
|   std::vector<LatticeColourMatrix> U(4,FGrid); | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     U[mu] = PeekIndex<LorentzIndex>(Umu5d,mu); | ||||
|   } | ||||
|  | ||||
|   if (1) | ||||
|   { | ||||
|     ref = zero; | ||||
|     for(int mu=0;mu<Nd;mu++){ | ||||
|  | ||||
|       tmp = U[mu]*Cshift(src,mu+1,1); | ||||
|       ref=ref + tmp - Gamma(Gmu[mu])*tmp; | ||||
|  | ||||
|       tmp =adj(U[mu])*src; | ||||
|       tmp =Cshift(tmp,mu+1,-1); | ||||
|       ref=ref + tmp + Gamma(Gmu[mu])*tmp; | ||||
|     } | ||||
|     ref = -0.5*ref; | ||||
|   } | ||||
|  | ||||
|   RealD mass=0.1; | ||||
|   RealD M5  =1.8; | ||||
|  | ||||
|   typename DomainWallFermionR::ImplParams params;  | ||||
|   params.overlapCommsCompute = overlapComms; | ||||
|    | ||||
|   RealD NP = UGrid->_Nprocessors; | ||||
|  | ||||
|  | ||||
|   QCD::WilsonKernelsStatic::AsmOpt=1; | ||||
|  | ||||
|   DomainWallFermionR Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5,params); | ||||
|    | ||||
|   std::cout<<GridLogMessage << "Calling Dw"<<std::endl; | ||||
|   int ncall =50; | ||||
|   if (1) { | ||||
|  | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       Dw.Dhop(src,result,0); | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=1344*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     err = ref-result;  | ||||
|     std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|     //    Dw.Report(); | ||||
|   } | ||||
|   Grid_finalize(); | ||||
| } | ||||
| @@ -37,11 +37,11 @@ struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
|   Gamma::GammaMatrix Gmu [] = { | ||||
|     Gamma::GammaX, | ||||
|     Gamma::GammaY, | ||||
|     Gamma::GammaZ, | ||||
|     Gamma::GammaT | ||||
|   Gamma::Algebra Gmu [] = { | ||||
|     Gamma::Algebra::GammaX, | ||||
|     Gamma::Algebra::GammaY, | ||||
|     Gamma::Algebra::GammaZ, | ||||
|     Gamma::Algebra::GammaT | ||||
|   }; | ||||
|  | ||||
| void benchDw(std::vector<int> & L, int Ls, int threads, int report =0 ); | ||||
| @@ -51,24 +51,27 @@ int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|  | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Kernel options --dslash-generic, --dslash-unroll, --dslash-asm" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|  | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|  | ||||
|   const int Ls=8; | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   if ( getenv("ASMOPT") )  { | ||||
|     QCD::WilsonKernelsStatic::AsmOpt=1; | ||||
|   } else {  | ||||
|     QCD::WilsonKernelsStatic::AsmOpt=0; | ||||
|   } | ||||
|  | ||||
|   std::cout<<GridLogMessage << "=========================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking DWF"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "=========================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Volume \t\t\tProcs \t Dw \t eoDw \t sDw \t eosDw (Mflop/s)  "<<std::endl; | ||||
|   std::cout<<GridLogMessage << "=========================================================================="<<std::endl; | ||||
|  | ||||
|   int Lmax=32; | ||||
|   int dmin=0; | ||||
|   int Lmax=16; | ||||
|   int dmin=2; | ||||
|   if ( getenv("LMAX") ) Lmax=atoi(getenv("LMAX")); | ||||
|   if ( getenv("DMIN") ) dmin=atoi(getenv("DMIN")); | ||||
|   for (int L=8;L<=Lmax;L*=2){ | ||||
| @@ -105,6 +108,7 @@ void benchDw(std::vector<int> & latt4, int Ls, int threads,int report ) | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
| @@ -194,7 +198,7 @@ void benchDw(std::vector<int> & latt4, int Ls, int threads,int report ) | ||||
|    | ||||
|   if ( ! report ) { | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=1344*volume*ncall; | ||||
|     double flops=single_site_flops*volume*ncall; | ||||
|     std::cout <<"\t"<<NP<< "\t"<<flops/(t1-t0)<< "\t"; | ||||
|   } | ||||
|    | ||||
| @@ -226,7 +230,7 @@ void benchDw(std::vector<int> & latt4, int Ls, int threads,int report ) | ||||
|      | ||||
|     if(!report){ | ||||
|       double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|       double flops=(1344.0*volume*ncall)/2; | ||||
|       double flops=(single_site_flops*volume*ncall)/2.0; | ||||
|       std::cout<< flops/(t1-t0); | ||||
|     } | ||||
|   } | ||||
| @@ -235,6 +239,7 @@ void benchDw(std::vector<int> & latt4, int Ls, int threads,int report ) | ||||
| #define CHECK_SDW | ||||
| void benchsDw(std::vector<int> & latt4, int Ls, int threads, int report ) | ||||
| { | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|  | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
| @@ -319,7 +324,7 @@ void benchsDw(std::vector<int> & latt4, int Ls, int threads, int report ) | ||||
|     Counter.Report(); | ||||
|   } else {  | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=1344*volume*ncall; | ||||
|     double flops=single_site_flops*volume*ncall; | ||||
|     std::cout<<"\t"<< flops/(t1-t0); | ||||
|   } | ||||
|  | ||||
| @@ -356,7 +361,7 @@ void benchsDw(std::vector<int> & latt4, int Ls, int threads, int report ) | ||||
|     CounterSdw.Report(); | ||||
|   } else { | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=(1344.0*volume*ncall)/2; | ||||
|     double flops=(single_site_flops*volume*ncall)/2.0; | ||||
|     std::cout<<"\t"<< flops/(t1-t0); | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										190
									
								
								benchmarks/Benchmark_gparity.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										190
									
								
								benchmarks/Benchmark_gparity.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,190 @@ | ||||
| #include <Grid/Grid.h> | ||||
| #include <sstream> | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| template<class d> | ||||
| struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
|   Gamma::Algebra Gmu [] = { | ||||
|     Gamma::Algebra::GammaX, | ||||
|     Gamma::Algebra::GammaY, | ||||
|     Gamma::Algebra::GammaZ, | ||||
|     Gamma::Algebra::GammaT | ||||
|   }; | ||||
|  | ||||
| typedef typename GparityDomainWallFermionF::FermionField GparityLatticeFermionF; | ||||
| typedef typename GparityDomainWallFermionD::FermionField GparityLatticeFermionD; | ||||
|  | ||||
|  | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   int Ls=16; | ||||
|   for(int i=0;i<argc;i++) | ||||
|     if(std::string(argv[i]) == "-Ls"){ | ||||
|       std::stringstream ss(argv[i+1]); ss >> Ls; | ||||
|     } | ||||
|  | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Ls = " << Ls << std::endl; | ||||
|  | ||||
|   std::vector<int> latt4 = GridDefaultLatt(); | ||||
|  | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplexF::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
|    | ||||
|   std::cout << GridLogMessage << "Initialising 4d RNG" << std::endl; | ||||
|   GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|   std::cout << GridLogMessage << "Initialising 5d RNG" << std::endl; | ||||
|   GridParallelRNG          RNG5(FGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|   std::cout << GridLogMessage << "Initialised RNGs" << std::endl; | ||||
|  | ||||
|   GparityLatticeFermionF src   (FGrid); random(RNG5,src); | ||||
|   RealD N2 = 1.0/::sqrt(norm2(src)); | ||||
|   src = src*N2; | ||||
|  | ||||
|   GparityLatticeFermionF result(FGrid); result=zero; | ||||
|   GparityLatticeFermionF    ref(FGrid);    ref=zero; | ||||
|   GparityLatticeFermionF    tmp(FGrid); | ||||
|   GparityLatticeFermionF    err(FGrid); | ||||
|  | ||||
|   std::cout << GridLogMessage << "Drawing gauge field" << std::endl; | ||||
|   LatticeGaugeFieldF Umu(UGrid);  | ||||
|   SU3::HotConfiguration(RNG4,Umu);  | ||||
|   std::cout << GridLogMessage << "Random gauge initialised " << std::endl; | ||||
|  | ||||
|   RealD mass=0.1; | ||||
|   RealD M5  =1.8; | ||||
|  | ||||
|   RealD NP = UGrid->_Nprocessors; | ||||
|   RealD NN = UGrid->NodeCount(); | ||||
|  | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Kernel options --dslash-generic, --dslash-unroll, --dslash-asm" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Benchmarking DomainWallFermion::Dhop                  "<<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Vectorising space-time by "<<vComplexF::Nsimd()<<std::endl; | ||||
| #ifdef GRID_OMP | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsAndCompute ) std::cout << GridLogMessage<< "* Using Overlapped Comms/Compute" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Comms == WilsonKernelsStatic::CommsThenCompute) std::cout << GridLogMessage<< "* Using sequential comms compute" <<std::endl; | ||||
| #endif | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|  | ||||
|  | ||||
|  | ||||
|   std::cout << GridLogMessage<< "* SINGLE/SINGLE"<<std::endl; | ||||
|   GparityDomainWallFermionF Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|   int ncall =1000; | ||||
|   if (1) { | ||||
|     FGrid->Barrier(); | ||||
|     Dw.ZeroCounters(); | ||||
|     Dw.Dhop(src,result,0); | ||||
|     std::cout<<GridLogMessage<<"Called warmup"<<std::endl; | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
|       Dw.Dhop(src,result,0); | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=2*1320*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     Dw.Report(); | ||||
|   } | ||||
|  | ||||
|   std::cout << GridLogMessage<< "* SINGLE/HALF"<<std::endl; | ||||
|   GparityDomainWallFermionFH DwH(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|   if (1) { | ||||
|     FGrid->Barrier(); | ||||
|     DwH.ZeroCounters(); | ||||
|     DwH.Dhop(src,result,0); | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
|       DwH.Dhop(src,result,0); | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=2*1320*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called half prec comms Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     DwH.Report(); | ||||
|   } | ||||
|  | ||||
|   GridCartesian         * UGrid_d   = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplexD::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid_d = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid_d); | ||||
|   GridCartesian         * FGrid_d   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid_d); | ||||
|   GridRedBlackCartesian * FrbGrid_d = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid_d); | ||||
|  | ||||
|    | ||||
|   std::cout << GridLogMessage<< "* DOUBLE/DOUBLE"<<std::endl; | ||||
|   GparityLatticeFermionD src_d(FGrid_d); | ||||
|   precisionChange(src_d,src); | ||||
|  | ||||
|   LatticeGaugeFieldD Umu_d(UGrid_d);  | ||||
|   precisionChange(Umu_d,Umu); | ||||
|  | ||||
|   GparityLatticeFermionD result_d(FGrid_d); | ||||
|  | ||||
|   GparityDomainWallFermionD DwD(Umu_d,*FGrid_d,*FrbGrid_d,*UGrid_d,*UrbGrid_d,mass,M5); | ||||
|   if (1) { | ||||
|     FGrid_d->Barrier(); | ||||
|     DwD.ZeroCounters(); | ||||
|     DwD.Dhop(src_d,result_d,0); | ||||
|     std::cout<<GridLogMessage<<"Called warmup"<<std::endl; | ||||
|     double t0=usecond(); | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       __SSC_START; | ||||
|       DwD.Dhop(src_d,result_d,0); | ||||
|       __SSC_STOP; | ||||
|     } | ||||
|     double t1=usecond(); | ||||
|     FGrid_d->Barrier(); | ||||
|      | ||||
|     double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|     double flops=2*1320*volume*ncall; | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Called Dw "<<ncall<<" times in "<<t1-t0<<" us"<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|     //    std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per rank =  "<< flops/(t1-t0)/NP<<std::endl; | ||||
|     std::cout<<GridLogMessage << "mflop/s per node =  "<< flops/(t1-t0)/NN<<std::endl; | ||||
|     DwD.Report(); | ||||
|   } | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
|  | ||||
| @@ -66,7 +66,8 @@ int main (int argc, char ** argv) | ||||
|  | ||||
|     Vec tsum; tsum = zero; | ||||
|  | ||||
|     GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|     GridParallelRNG          pRNG(&Grid);       | ||||
|     pRNG.SeedFixedIntegers(std::vector<int>({56,17,89,101})); | ||||
|  | ||||
|     std::vector<double> stop(threads); | ||||
|     Vector<Vec> sum(threads); | ||||
| @@ -77,8 +78,7 @@ int main (int argc, char ** argv) | ||||
|     } | ||||
|  | ||||
|     double start=usecond(); | ||||
| PARALLEL_FOR_LOOP | ||||
|     for(int t=0;t<threads;t++){ | ||||
|     parallel_for(int t=0;t<threads;t++){ | ||||
|  | ||||
|       sum[t] = x[t]._odata[0]; | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|   | ||||
| @@ -55,21 +55,21 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s"<<"\t\t"<<"Gflop/s"<<"\t\t seconds"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|   uint64_t lmax=44; | ||||
| #define NLOOP (1*lmax*lmax*lmax*lmax/vol) | ||||
|   for(int lat=4;lat<=lmax;lat+=4){ | ||||
|   uint64_t lmax=64; | ||||
| #define NLOOP (10*lmax*lmax*lmax*lmax/vol) | ||||
|   for(int lat=8;lat<=lmax;lat+=8){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol= latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|  | ||||
|       uint64_t Nloop=NLOOP; | ||||
|  | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeVec z(&Grid); //random(pRNG,z); | ||||
|       LatticeVec x(&Grid); //random(pRNG,x); | ||||
|       LatticeVec y(&Grid); //random(pRNG,y); | ||||
|       LatticeVec z(&Grid);// random(pRNG,z); | ||||
|       LatticeVec x(&Grid);// random(pRNG,x); | ||||
|       LatticeVec y(&Grid);// random(pRNG,y); | ||||
|       double a=2.0; | ||||
|  | ||||
|  | ||||
| @@ -83,7 +83,7 @@ int main (int argc, char ** argv) | ||||
|       double time = (stop-start)/Nloop*1000; | ||||
|        | ||||
|       double flops=vol*Nvec*2;// mul,add | ||||
|       double bytes=3*vol*Nvec*sizeof(Real); | ||||
|       double bytes=3.0*vol*Nvec*sizeof(Real); | ||||
|       std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t"<<flops/time<<"\t\t"<<(stop-start)/1000./1000.<<std::endl; | ||||
|  | ||||
|     } | ||||
| @@ -94,17 +94,17 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s"<<"\t\t"<<"Gflop/s"<<"\t\t seconds"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|    | ||||
|   for(int lat=4;lat<=lmax;lat+=4){ | ||||
|   for(int lat=8;lat<=lmax;lat+=8){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol= latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|  | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeVec z(&Grid); //random(pRNG,z); | ||||
|       LatticeVec x(&Grid); //random(pRNG,x); | ||||
|       LatticeVec y(&Grid); //random(pRNG,y); | ||||
|       LatticeVec z(&Grid);// random(pRNG,z); | ||||
|       LatticeVec x(&Grid);// random(pRNG,x); | ||||
|       LatticeVec y(&Grid);// random(pRNG,y); | ||||
|       double a=2.0; | ||||
|  | ||||
|       uint64_t Nloop=NLOOP; | ||||
| @@ -119,7 +119,7 @@ int main (int argc, char ** argv) | ||||
|       double time = (stop-start)/Nloop*1000; | ||||
|       | ||||
|       double flops=vol*Nvec*2;// mul,add | ||||
|       double bytes=3*vol*Nvec*sizeof(Real); | ||||
|       double bytes=3.0*vol*Nvec*sizeof(Real); | ||||
|       std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t"<<flops/time<<"\t\t"<<(stop-start)/1000./1000.<<std::endl; | ||||
|  | ||||
|     } | ||||
| @@ -129,20 +129,20 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s"<<"\t\t"<<"Gflop/s"<<"\t\t seconds"<<std::endl; | ||||
|  | ||||
|   for(int lat=4;lat<=lmax;lat+=4){ | ||||
|   for(int lat=8;lat<=lmax;lat+=8){ | ||||
|  | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol= latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       uint64_t Nloop=NLOOP; | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|  | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeVec z(&Grid); //random(pRNG,z); | ||||
|       LatticeVec x(&Grid); //random(pRNG,x); | ||||
|       LatticeVec y(&Grid); //random(pRNG,y); | ||||
|       LatticeVec z(&Grid);// random(pRNG,z); | ||||
|       LatticeVec x(&Grid);// random(pRNG,x); | ||||
|       LatticeVec y(&Grid);// random(pRNG,y); | ||||
|       RealD a=2.0; | ||||
|  | ||||
|  | ||||
| @@ -154,7 +154,7 @@ int main (int argc, char ** argv) | ||||
|       double stop=usecond(); | ||||
|       double time = (stop-start)/Nloop*1000; | ||||
|        | ||||
|       double bytes=2*vol*Nvec*sizeof(Real); | ||||
|       double bytes=2.0*vol*Nvec*sizeof(Real); | ||||
|       double flops=vol*Nvec*1;// mul | ||||
|       std::cout<<GridLogMessage <<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t"<<flops/time<<"\t\t"<<(stop-start)/1000./1000.<<std::endl; | ||||
|  | ||||
| @@ -166,17 +166,17 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s"<<"\t\t"<<"Gflop/s"<<"\t\t seconds"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=4;lat<=lmax;lat+=4){ | ||||
|   for(int lat=8;lat<=lmax;lat+=8){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol= latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       uint64_t Nloop=NLOOP; | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|  | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       LatticeVec z(&Grid); //random(pRNG,z); | ||||
|       LatticeVec x(&Grid); //random(pRNG,x); | ||||
|       LatticeVec y(&Grid); //random(pRNG,y); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|       LatticeVec z(&Grid);// random(pRNG,z); | ||||
|       LatticeVec x(&Grid);// random(pRNG,x); | ||||
|       LatticeVec y(&Grid);// random(pRNG,y); | ||||
|       RealD a=2.0; | ||||
|       Real nn;       | ||||
|       double start=usecond(); | ||||
| @@ -187,7 +187,7 @@ int main (int argc, char ** argv) | ||||
|       double stop=usecond(); | ||||
|       double time = (stop-start)/Nloop*1000; | ||||
|        | ||||
|       double bytes=vol*Nvec*sizeof(Real); | ||||
|       double bytes=1.0*vol*Nvec*sizeof(Real); | ||||
|       double flops=vol*Nvec*2;// mul,add | ||||
|       std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"  \t\t"<<bytes/time<<"\t\t"<<flops/time<< "\t\t"<<(stop-start)/1000./1000.<< "\t\t " <<std::endl; | ||||
|  | ||||
|   | ||||
							
								
								
									
										222
									
								
								benchmarks/Benchmark_mooee.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										222
									
								
								benchmarks/Benchmark_mooee.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,222 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_dwf.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   std::vector<int> latt4 = GridDefaultLatt(); | ||||
|   const int Ls=16; | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|   std::cout << GridLogMessage << "Making Vec5d innermost grids"<<std::endl; | ||||
|   GridCartesian         * sUGrid   = SpaceTimeGrid::makeFourDimDWFGrid(GridDefaultLatt(),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * sUrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(sUGrid); | ||||
|   GridCartesian         * sFGrid   = SpaceTimeGrid::makeFiveDimDWFGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * sFrbGrid = SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
|  | ||||
|   GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|   std::cout << GridLogMessage << "Seeded"<<std::endl; | ||||
|  | ||||
|   LatticeGaugeField Umu(UGrid); SU3::HotConfiguration(RNG4,Umu); | ||||
|  | ||||
|   std::cout << GridLogMessage << "made random gauge fields"<<std::endl; | ||||
|  | ||||
|   RealD mass=0.1; | ||||
|   RealD M5  =1.8; | ||||
|   RealD NP = UGrid->_Nprocessors; | ||||
|  | ||||
|  | ||||
|   if (1) | ||||
|   { | ||||
|     const int ncall=1000; | ||||
|  | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|     std::cout << GridLogMessage<< "* Benchmarking DomainWallFermionR::Dhop "<<std::endl; | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|  | ||||
|     GridParallelRNG RNG5(FGrid); | ||||
|     LatticeFermion src(FGrid); random(RNG5,src); | ||||
|     LatticeFermion result(FGrid); | ||||
|  | ||||
|     DomainWallFermionR Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|     double t0,t1; | ||||
|  | ||||
|     LatticeFermion r_eo(FGrid); | ||||
|     LatticeFermion src_e (FrbGrid); | ||||
|     LatticeFermion src_o (FrbGrid); | ||||
|     LatticeFermion r_e   (FrbGrid); | ||||
|     LatticeFermion r_o   (FrbGrid); | ||||
|      | ||||
|     pickCheckerboard(Even,src_e,src); | ||||
|     pickCheckerboard(Odd,src_o,src); | ||||
|      | ||||
|     setCheckerboard(r_eo,src_o); | ||||
|     setCheckerboard(r_eo,src_e); | ||||
|      | ||||
|     r_e = zero; | ||||
|     r_o = zero; | ||||
|  | ||||
|  | ||||
| #define BENCH_DW(A,in,out)			\ | ||||
|     Dw.CayleyZeroCounters();			\ | ||||
|     Dw. A (in,out);				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     t0=usecond();				\ | ||||
|     for(int i=0;i<ncall;i++){			\ | ||||
|       Dw. A (in,out);				\ | ||||
|     }						\ | ||||
|     t1=usecond();				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     Dw.CayleyReport();					\ | ||||
|     std::cout<<GridLogMessage << "Called " #A " "<< (t1-t0)/ncall<<" us"<<std::endl;\ | ||||
|     std::cout<<GridLogMessage << "******************"<<std::endl; | ||||
|  | ||||
| #define BENCH_ZDW(A,in,out)			\ | ||||
|     zDw.CayleyZeroCounters();			\ | ||||
|     zDw. A (in,out);				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     t0=usecond();				\ | ||||
|     for(int i=0;i<ncall;i++){			\ | ||||
|       zDw. A (in,out);				\ | ||||
|     }						\ | ||||
|     t1=usecond();				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     zDw.CayleyReport();							\ | ||||
|     std::cout<<GridLogMessage << "Called ZDw " #A " "<< (t1-t0)/ncall<<" us"<<std::endl;\ | ||||
|     std::cout<<GridLogMessage << "******************"<<std::endl; | ||||
|  | ||||
| #define BENCH_DW_SSC(A,in,out)			\ | ||||
|     Dw.CayleyZeroCounters();			\ | ||||
|     Dw. A (in,out);				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     t0=usecond();				\ | ||||
|     for(int i=0;i<ncall;i++){			\ | ||||
|       __SSC_START ;				\ | ||||
|       Dw. A (in,out);				\ | ||||
|       __SSC_STOP ;				\ | ||||
|     }						\ | ||||
|     t1=usecond();				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     Dw.CayleyReport();					\ | ||||
|     std::cout<<GridLogMessage << "Called " #A " "<< (t1-t0)/ncall<<" us"<<std::endl;\ | ||||
|     std::cout<<GridLogMessage << "******************"<<std::endl; | ||||
|  | ||||
| #define BENCH_DW_MEO(A,in,out)			\ | ||||
|     Dw.CayleyZeroCounters();			\ | ||||
|     Dw. A (in,out,0);				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     t0=usecond();				\ | ||||
|     for(int i=0;i<ncall;i++){			\ | ||||
|       Dw. A (in,out,0);				\ | ||||
|     }						\ | ||||
|     t1=usecond();				\ | ||||
|     FGrid->Barrier();				\ | ||||
|     Dw.CayleyReport();					\ | ||||
|     std::cout<<GridLogMessage << "Called " #A " "<< (t1-t0)/ncall<<" us"<<std::endl;\ | ||||
|     std::cout<<GridLogMessage << "******************"<<std::endl; | ||||
|  | ||||
|     BENCH_DW_MEO(Dhop    ,src,result); | ||||
|     BENCH_DW_MEO(DhopEO  ,src_o,r_e); | ||||
|     BENCH_DW(Meooe   ,src_o,r_e); | ||||
|     BENCH_DW(Mooee   ,src_o,r_o); | ||||
|     BENCH_DW(MooeeInv,src_o,r_o); | ||||
|  | ||||
|   } | ||||
|  | ||||
|   if (1) | ||||
|   { | ||||
|     const int ncall=1000; | ||||
|  | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|     std::cout << GridLogMessage<< "* Benchmarking DomainWallFermionVec5dR::Dhop "<<std::endl; | ||||
|     std::cout << GridLogMessage<< "*********************************************************" <<std::endl; | ||||
|  | ||||
|     GridParallelRNG RNG5(sFGrid); | ||||
|     LatticeFermion src(sFGrid); random(RNG5,src); | ||||
|     LatticeFermion sref(sFGrid); | ||||
|     LatticeFermion result(sFGrid); | ||||
|  | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Constructing Vec5D Dw "<<std::endl; | ||||
|     DomainWallFermionVec5dR Dw(Umu,*sFGrid,*sFrbGrid,*sUGrid,*sUrbGrid,mass,M5); | ||||
|  | ||||
|     RealD b=1.5;// Scale factor b+c=2, b-c=1 | ||||
|     RealD c=0.5; | ||||
|     std::vector<ComplexD> gamma(Ls,std::complex<double>(1.0,0.0)); | ||||
|     ZMobiusFermionVec5dR zDw(Umu,*sFGrid,*sFrbGrid,*sUGrid,*sUrbGrid,mass,M5,gamma,b,c); | ||||
|  | ||||
|     std::cout<<GridLogMessage << "Calling Dhop "<<std::endl; | ||||
|     FGrid->Barrier(); | ||||
|  | ||||
|     double t0,t1; | ||||
|  | ||||
|     LatticeFermion r_eo(sFGrid); | ||||
|     LatticeFermion src_e (sFrbGrid); | ||||
|     LatticeFermion src_o (sFrbGrid); | ||||
|     LatticeFermion r_e   (sFrbGrid); | ||||
|     LatticeFermion r_o   (sFrbGrid); | ||||
|      | ||||
|     pickCheckerboard(Even,src_e,src); | ||||
|     pickCheckerboard(Odd,src_o,src); | ||||
|      | ||||
|     setCheckerboard(r_eo,src_o); | ||||
|     setCheckerboard(r_eo,src_e); | ||||
|      | ||||
|     r_e = zero; | ||||
|     r_o = zero; | ||||
|  | ||||
|     BENCH_DW_MEO(Dhop    ,src,result); | ||||
|     BENCH_DW_MEO(DhopEO  ,src_o,r_e); | ||||
|     BENCH_DW_SSC(Meooe   ,src_o,r_e); | ||||
|     BENCH_DW(Mooee   ,src_o,r_o); | ||||
|     BENCH_DW(MooeeInv,src_o,r_o); | ||||
|  | ||||
|     BENCH_ZDW(Mooee   ,src_o,r_o); | ||||
|     BENCH_ZDW(MooeeInv,src_o,r_o); | ||||
|  | ||||
|   } | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
							
								
								
									
										134
									
								
								benchmarks/Benchmark_staggered.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								benchmarks/Benchmark_staggered.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_staggered.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|  | ||||
|   std::vector<int> latt_size   = GridDefaultLatt(); | ||||
|   std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||
|   std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|   GridCartesian               Grid(latt_size,simd_layout,mpi_layout); | ||||
|   GridRedBlackCartesian     RBGrid(&Grid); | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REALF"<< sizeof(RealF)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REALD"<< sizeof(RealD)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REAL"<< sizeof(Real)<<std::endl; | ||||
|  | ||||
|   std::vector<int> seeds({1,2,3,4}); | ||||
|   GridParallelRNG          pRNG(&Grid); | ||||
|   pRNG.SeedFixedIntegers(seeds); | ||||
|   //  pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}); | ||||
|  | ||||
|   typedef typename ImprovedStaggeredFermionR::FermionField FermionField;  | ||||
|   typename ImprovedStaggeredFermionR::ImplParams params;  | ||||
|  | ||||
|   FermionField src   (&Grid); random(pRNG,src); | ||||
|   FermionField result(&Grid); result=zero; | ||||
|   FermionField    ref(&Grid);    ref=zero; | ||||
|   FermionField    tmp(&Grid);    tmp=zero; | ||||
|   FermionField    err(&Grid);    tmp=zero; | ||||
|   LatticeGaugeField Umu(&Grid); random(pRNG,Umu); | ||||
|   std::vector<LatticeColourMatrix> U(4,&Grid); | ||||
|  | ||||
|   double volume=1; | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     volume=volume*latt_size[mu]; | ||||
|   }   | ||||
|  | ||||
|   // Only one non-zero (y) | ||||
| #if 0 | ||||
|   Umu=zero; | ||||
|   Complex cone(1.0,0.0); | ||||
|   for(int nn=0;nn<Nd;nn++){ | ||||
|     random(pRNG,U[nn]); | ||||
|     if(1) { | ||||
|       if (nn!=2) { U[nn]=zero; std::cout<<GridLogMessage << "zeroing gauge field in dir "<<nn<<std::endl; } | ||||
|       //      else       { U[nn]= cone;std::cout<<GridLogMessage << "unit gauge field in dir "<<nn<<std::endl; } | ||||
|       else       { std::cout<<GridLogMessage << "random gauge field in dir "<<nn<<std::endl; } | ||||
|     } | ||||
|     PokeIndex<LorentzIndex>(Umu,U[nn],nn); | ||||
|   } | ||||
| #endif | ||||
|  | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     U[mu] = PeekIndex<LorentzIndex>(Umu,mu); | ||||
|   } | ||||
|   ref = zero; | ||||
|   /*   | ||||
|   { // Naive wilson implementation | ||||
|     ref = zero; | ||||
|     for(int mu=0;mu<Nd;mu++){ | ||||
|       //    ref =  src + Gamma(Gamma::GammaX)* src ; // 1-gamma_x | ||||
|       tmp = U[mu]*Cshift(src,mu,1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
| 	ref._odata[i]+= tmp._odata[i] - Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
|       } | ||||
|  | ||||
|       tmp =adj(U[mu])*src; | ||||
|       tmp =Cshift(tmp,mu,-1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
| 	ref._odata[i]+= tmp._odata[i] + Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   ref = -0.5*ref; | ||||
|   */ | ||||
|  | ||||
|   RealD mass=0.1; | ||||
|   RealD c1=9.0/8.0; | ||||
|   RealD c2=-1.0/24.0; | ||||
|   RealD u0=1.0; | ||||
|   ImprovedStaggeredFermionR Ds(Umu,Umu,Grid,RBGrid,mass,c1,c2,u0,params); | ||||
|    | ||||
|   std::cout<<GridLogMessage << "Calling Ds"<<std::endl; | ||||
|   int ncall=1000; | ||||
|   double t0=usecond(); | ||||
|   for(int i=0;i<ncall;i++){ | ||||
|     Ds.Dhop(src,result,0); | ||||
|   } | ||||
|   double t1=usecond(); | ||||
|   double flops=(16*(3*(6+8+8)) + 15*3*2)*volume*ncall; // == 66*16 +  == 1146 | ||||
|    | ||||
|   std::cout<<GridLogMessage << "Called Ds"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
|   err = ref-result;  | ||||
|   std::cout<<GridLogMessage << "norm diff   "<< norm2(err)<<std::endl; | ||||
|  | ||||
|   Grid_finalize(); | ||||
| } | ||||
| @@ -35,13 +35,16 @@ using namespace Grid::QCD; | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
| #define LMAX (32) | ||||
| #define LMIN (16) | ||||
| #define LINC (4) | ||||
|  | ||||
|   int Nloop=1000; | ||||
|   int64_t Nloop=2000; | ||||
|  | ||||
|   std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||
|   std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   int64_t threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
| @@ -50,19 +53,19 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=2;lat<=32;lat+=2){ | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeColourMatrix z(&Grid);// random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid);// random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid);// random(pRNG,y); | ||||
|       LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|       for(int64_t i=0;i<Nloop;i++){ | ||||
| 	x=x*y; | ||||
|       } | ||||
|       double stop=usecond(); | ||||
| @@ -82,20 +85,20 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=2;lat<=32;lat+=2){ | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeColourMatrix z(&Grid); //random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); //random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); //random(pRNG,y); | ||||
|       LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|       for(int64_t i=0;i<Nloop;i++){ | ||||
| 	z=x*y; | ||||
|       } | ||||
|       double stop=usecond(); | ||||
| @@ -113,20 +116,20 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=2;lat<=32;lat+=2){ | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeColourMatrix z(&Grid); //random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); //random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); //random(pRNG,y); | ||||
|       LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
|       for(int64_t i=0;i<Nloop;i++){ | ||||
| 	mult(z,x,y); | ||||
|       } | ||||
|       double stop=usecond(); | ||||
| @@ -144,30 +147,107 @@ int main (int argc, char ** argv) | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=2;lat<=32;lat+=2){ | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|      | ||||
|     std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|     int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|      | ||||
|     GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|     GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|      | ||||
|     LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|     LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|     LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|      | ||||
|     double start=usecond(); | ||||
|     for(int64_t i=0;i<Nloop;i++){ | ||||
|       mac(z,x,y); | ||||
|     } | ||||
|     double stop=usecond(); | ||||
|     double time = (stop-start)/Nloop*1000.0; | ||||
|      | ||||
|     double bytes=3*vol*Nc*Nc*sizeof(Complex); | ||||
|     double flops=Nc*Nc*(6+8+8)*vol; | ||||
|     std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t" << flops/time<<std::endl; | ||||
|      | ||||
|   } | ||||
|  | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking SU3xSU3  CovShiftForward(z,x,y)"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|  | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|       int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       //      GridParallelRNG          pRNG(&Grid);      pRNG.SeedRandomDevice(); | ||||
|       GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeColourMatrix z(&Grid); //random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); //random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); //random(pRNG,y); | ||||
|       LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|  | ||||
|       double start=usecond(); | ||||
|       for(int i=0;i<Nloop;i++){ | ||||
| 	mac(z,x,y); | ||||
|       for(int mu=0;mu<4;mu++){ | ||||
| 	      double start=usecond(); | ||||
| 	      for(int64_t i=0;i<Nloop;i++){ | ||||
| 	        z = PeriodicBC::CovShiftForward(x,mu,y); | ||||
| 	    } | ||||
| 	    double stop=usecond(); | ||||
| 	    double time = (stop-start)/Nloop*1000.0; | ||||
| 	 | ||||
| 	 | ||||
| 	    double bytes=3*vol*Nc*Nc*sizeof(Complex); | ||||
| 	    double flops=Nc*Nc*(6+8+8)*vol; | ||||
| 	    std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t" << flops/time<<std::endl; | ||||
|       } | ||||
|       double stop=usecond(); | ||||
|       double time = (stop-start)/Nloop*1000.0; | ||||
|        | ||||
|       double bytes=3*vol*Nc*Nc*sizeof(Complex); | ||||
|       double flops=Nc*Nc*(8+8+8)*vol; | ||||
|       std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t" << flops/time<<std::endl; | ||||
|   } | ||||
| #if 1 | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking SU3xSU3  z= x * Cshift(y)"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "===================================================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "  L  "<<"\t\t"<<"bytes"<<"\t\t\t"<<"GB/s\t\t GFlop/s"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "----------------------------------------------------------"<<std::endl; | ||||
|  | ||||
|   for(int lat=LMIN;lat<=LMAX;lat+=LINC){ | ||||
|       std::vector<int> latt_size  ({lat*mpi_layout[0],lat*mpi_layout[1],lat*mpi_layout[2],lat*mpi_layout[3]}); | ||||
|       int64_t vol = latt_size[0]*latt_size[1]*latt_size[2]*latt_size[3]; | ||||
|  | ||||
|       GridCartesian     Grid(latt_size,simd_layout,mpi_layout); | ||||
|       GridParallelRNG          pRNG(&Grid);      pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9})); | ||||
|  | ||||
|       LatticeColourMatrix z(&Grid); random(pRNG,z); | ||||
|       LatticeColourMatrix x(&Grid); random(pRNG,x); | ||||
|       LatticeColourMatrix y(&Grid); random(pRNG,y); | ||||
|       LatticeColourMatrix tmp(&Grid); | ||||
|  | ||||
|       for(int mu=0;mu<4;mu++){ | ||||
| 	double tshift=0; | ||||
| 	double tmult =0; | ||||
|  | ||||
| 	double start=usecond(); | ||||
| 	for(int64_t i=0;i<Nloop;i++){ | ||||
| 	  tshift-=usecond(); | ||||
| 	  tmp = Cshift(y,mu,-1); | ||||
| 	  tshift+=usecond(); | ||||
| 	  tmult-=usecond(); | ||||
| 	  z   = x*tmp; | ||||
| 	  tmult+=usecond(); | ||||
| 	} | ||||
| 	double stop=usecond(); | ||||
| 	double time = (stop-start)/Nloop; | ||||
| 	tshift = tshift/Nloop; | ||||
| 	tmult  = tmult /Nloop; | ||||
| 	 | ||||
| 	double bytes=3*vol*Nc*Nc*sizeof(Complex); | ||||
| 	double flops=Nc*Nc*(6+8+8)*vol; | ||||
| 	std::cout<<GridLogMessage<<std::setprecision(3) << "total us "<<time<<" shift "<<tshift <<" mult "<<tmult<<std::endl; | ||||
| 	time = time * 1000; // convert to NS for GB/s | ||||
| 	std::cout<<GridLogMessage<<std::setprecision(3) << lat<<"\t\t"<<bytes<<"   \t\t"<<bytes/time<<"\t\t" << flops/time<<std::endl; | ||||
|       } | ||||
|     } | ||||
|  | ||||
| #endif | ||||
|   Grid_finalize(); | ||||
| } | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|  | ||||
|     Source file: ./benchmarks/Benchmark_wilson.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|     Copyright (C) 2018 | ||||
|  | ||||
| Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
| @@ -32,19 +32,23 @@ using namespace std; | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
|  | ||||
| #include "Grid/util/Profiling.h" | ||||
|  | ||||
| template<class d> | ||||
| struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
|   Gamma::GammaMatrix Gmu [] = { | ||||
|     Gamma::GammaX, | ||||
|     Gamma::GammaY, | ||||
|     Gamma::GammaZ, | ||||
|     Gamma::GammaT | ||||
|   Gamma::Algebra Gmu [] = { | ||||
|     Gamma::Algebra::GammaX, | ||||
|     Gamma::Algebra::GammaY, | ||||
|     Gamma::Algebra::GammaZ, | ||||
|     Gamma::Algebra::GammaT | ||||
|   }; | ||||
|  | ||||
| bool overlapComms = false; | ||||
| bool perfProfiling = false; | ||||
|  | ||||
| int main (int argc, char ** argv) | ||||
| { | ||||
| @@ -53,23 +57,34 @@ int main (int argc, char ** argv) | ||||
|   if( GridCmdOptionExists(argv,argv+argc,"--asynch") ){ | ||||
|     overlapComms = true; | ||||
|   } | ||||
|   if( GridCmdOptionExists(argv,argv+argc,"--perf") ){ | ||||
|     perfProfiling = true; | ||||
|   } | ||||
|  | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|  | ||||
|  | ||||
|   std::vector<int> latt_size   = GridDefaultLatt(); | ||||
|   std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||
|   std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|   GridCartesian               Grid(latt_size,simd_layout,mpi_layout); | ||||
|   GridRedBlackCartesian     RBGrid(latt_size,simd_layout,mpi_layout); | ||||
|   GridRedBlackCartesian     RBGrid(&Grid); | ||||
|  | ||||
|   int threads = GridThread::GetThreads(); | ||||
|   std::cout<<GridLogMessage << "Grid is setup to use "<<threads<<" threads"<<std::endl; | ||||
|  | ||||
|   GridLogLayout(); | ||||
|  | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REALF"<< sizeof(RealF)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REALD"<< sizeof(RealD)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid floating point word size is REAL"<< sizeof(Real)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Grid number of colours : "<< QCD::Nc <<std::endl; | ||||
|   std::cout<<GridLogMessage << "Benchmarking Wilson operator in the fundamental representation" << std::endl; | ||||
|  | ||||
|  | ||||
|   std::vector<int> seeds({1,2,3,4}); | ||||
|   GridParallelRNG          pRNG(&Grid); | ||||
|   pRNG.SeedFixedIntegers(seeds); | ||||
|   //  pRNG.SeedRandomDevice(); | ||||
|   //  pRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}); | ||||
|  | ||||
|   LatticeFermion src   (&Grid); random(pRNG,src); | ||||
|   LatticeFermion result(&Grid); result=zero; | ||||
| @@ -106,7 +121,7 @@ int main (int argc, char ** argv) | ||||
|   { // Naive wilson implementation | ||||
|     ref = zero; | ||||
|     for(int mu=0;mu<Nd;mu++){ | ||||
|       //    ref =  src + Gamma(Gamma::GammaX)* src ; // 1-gamma_x | ||||
|       //    ref =  src + Gamma(Gamma::Algebra::GammaX)* src ; // 1-gamma_x | ||||
|       tmp = U[mu]*Cshift(src,mu,1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
| 	ref._odata[i]+= tmp._odata[i] - Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
| @@ -134,9 +149,25 @@ int main (int argc, char ** argv) | ||||
|     Dw.Dhop(src,result,0); | ||||
|   } | ||||
|   double t1=usecond(); | ||||
|   double flops=1344*volume*ncall; | ||||
|   double flops=single_site_flops*volume*ncall; | ||||
|    | ||||
|   if (perfProfiling){ | ||||
|   std::cout<<GridLogMessage << "Profiling Dw with perf"<<std::endl; | ||||
|      | ||||
|   System::profile("kernel", [&]() { | ||||
|     for(int i=0;i<ncall;i++){ | ||||
|       Dw.Dhop(src,result,0); | ||||
|     } | ||||
|   }); | ||||
|  | ||||
|   std::cout<<GridLogMessage << "Generated kernel.data"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Use with: perf report -i kernel.data"<<std::endl; | ||||
|  | ||||
|   } | ||||
|  | ||||
|  | ||||
|   std::cout<<GridLogMessage << "Called Dw"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "flops per site " << single_site_flops << std::endl; | ||||
|   std::cout<<GridLogMessage << "norm result "<< norm2(result)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "norm ref    "<< norm2(ref)<<std::endl; | ||||
|   std::cout<<GridLogMessage << "mflop/s =   "<< flops/(t1-t0)<<std::endl; | ||||
| @@ -159,7 +190,7 @@ int main (int argc, char ** argv) | ||||
|     ref = zero; | ||||
|     for(int mu=0;mu<Nd;mu++){ | ||||
|  | ||||
|       //    ref =  src - Gamma(Gamma::GammaX)* src ; // 1+gamma_x | ||||
|       //    ref =  src - Gamma(Gamma::Algebra::GammaX)* src ; // 1+gamma_x | ||||
|       tmp = U[mu]*Cshift(src,mu,1); | ||||
|       for(int i=0;i<ref._odata.size();i++){ | ||||
| 	ref._odata[i]+= tmp._odata[i] + Gamma(Gmu[mu])*tmp._odata[i]; ; | ||||
|   | ||||
| @@ -30,11 +30,11 @@ struct scal { | ||||
|   d internal; | ||||
| }; | ||||
|  | ||||
| Gamma::GammaMatrix Gmu [] = { | ||||
|   Gamma::GammaX, | ||||
|   Gamma::GammaY, | ||||
|   Gamma::GammaZ, | ||||
|   Gamma::GammaT | ||||
| Gamma::Algebra Gmu [] = { | ||||
|     Gamma::Algebra::GammaX, | ||||
|     Gamma::Algebra::GammaY, | ||||
|     Gamma::Algebra::GammaZ, | ||||
|     Gamma::Algebra::GammaT | ||||
| }; | ||||
|  | ||||
| bool overlapComms = false; | ||||
| @@ -58,11 +58,27 @@ int main (int argc, char ** argv) | ||||
|   std::vector<int> seeds({1,2,3,4}); | ||||
|   RealD mass = 0.1; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "============================================================================="<< std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking Wilson" << std::endl; | ||||
|   std::cout<<GridLogMessage << "============================================================================="<< std::endl; | ||||
|   std::cout<<GridLogMessage << "Volume\t\t\tWilson/MFLOPs\tWilsonDag/MFLOPs" << std::endl; | ||||
|   std::cout<<GridLogMessage << "============================================================================="<< std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Kernel options --dslash-generic, --dslash-unroll, --dslash-asm" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Number of colours "<< QCD::Nc <<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Benchmarking WilsonFermionR::Dhop                  "<<std::endl; | ||||
|   std::cout << GridLogMessage<< "* Vectorising space-time by "<<vComplex::Nsimd()<<std::endl; | ||||
|   if ( sizeof(Real)==4 )   std::cout << GridLogMessage<< "* SINGLE precision "<<std::endl; | ||||
|   if ( sizeof(Real)==8 )   std::cout << GridLogMessage<< "* DOUBLE precision "<<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptGeneric   ) std::cout << GridLogMessage<< "* Using GENERIC Nc WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptHandUnroll) std::cout << GridLogMessage<< "* Using Nc=3       WilsonKernels" <<std::endl; | ||||
|   if ( WilsonKernelsStatic::Opt == WilsonKernelsStatic::OptInlineAsm ) std::cout << GridLogMessage<< "* Using Asm Nc=3   WilsonKernels" <<std::endl; | ||||
|   std::cout << GridLogMessage << "* OpenMP threads       : "<< GridThread::GetThreads() <<std::endl; | ||||
|   std::cout << GridLogMessage << "* MPI tasks            : "<< GridCmdVectorIntToString(mpi_layout) << std::endl; | ||||
|   std::cout << GridLogMessage<< "*****************************************************************" <<std::endl; | ||||
|  | ||||
|   std::cout<<GridLogMessage << "================================================================================================="<< std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking Wilson operator in the fundamental representation" << std::endl; | ||||
|   std::cout<<GridLogMessage << "================================================================================================="<< std::endl; | ||||
|   std::cout<<GridLogMessage << "Volume\t\t\tWilson/MFLOPs\tWilsonDag/MFLOPs\tWilsonEO/MFLOPs\tWilsonDagEO/MFLOPs" << std::endl; | ||||
|   std::cout<<GridLogMessage << "================================================================================================="<< std::endl; | ||||
|  | ||||
|   int Lmax = 32; | ||||
|   int dmin = 0; | ||||
| @@ -80,17 +96,24 @@ int main (int argc, char ** argv) | ||||
| 	  std::cout << latt_size.back() << "\t\t"; | ||||
|  | ||||
| 	  GridCartesian           Grid(latt_size,simd_layout,mpi_layout); | ||||
| 	  GridRedBlackCartesian RBGrid(latt_size,simd_layout,mpi_layout); | ||||
| 	  GridRedBlackCartesian RBGrid(&Grid); | ||||
|  | ||||
| 	  GridParallelRNG  pRNG(&Grid); pRNG.SeedFixedIntegers(seeds); | ||||
| 	  LatticeGaugeField Umu(&Grid); random(pRNG,Umu); | ||||
| 	  LatticeFermion    src(&Grid); random(pRNG,src); | ||||
| 	  LatticeFermion result(&Grid); result=zero; | ||||
| 	  LatticeFermion        src(&Grid); random(pRNG,src); | ||||
| 	  LatticeFermion    src_o(&RBGrid); pickCheckerboard(Odd,src_o,src); | ||||
| 	  LatticeFermion     result(&Grid); result=zero; | ||||
| 	  LatticeFermion result_e(&RBGrid); result_e=zero; | ||||
|  | ||||
| 	  double volume = std::accumulate(latt_size.begin(),latt_size.end(),1,std::multiplies<int>()); | ||||
|  | ||||
| 	  WilsonFermionR Dw(Umu,Grid,RBGrid,mass,params); | ||||
|        | ||||
|  | ||||
|     // Full operator       | ||||
| 	  bench_wilson(src,result,Dw,volume,DaggerNo); | ||||
| 	  bench_wilson(src,result,Dw,volume,DaggerYes); | ||||
|     std::cout << "\t"; | ||||
|     // EO | ||||
| 	  bench_wilson(src,result,Dw,volume,DaggerNo); | ||||
| 	  bench_wilson(src,result,Dw,volume,DaggerYes); | ||||
| 	  std::cout << std::endl; | ||||
| @@ -109,9 +132,26 @@ void bench_wilson ( | ||||
| 		   int const           dag ) | ||||
| { | ||||
|   int ncall    = 1000; | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|   double t0    = usecond(); | ||||
|   for(int i=0; i<ncall; i++) { Dw.Dhop(src,result,dag); } | ||||
|   double t1    = usecond(); | ||||
|   double flops = 1344 * volume * ncall; | ||||
|   double flops = single_site_flops * volume * ncall; | ||||
|   std::cout << flops/(t1-t0) << "\t\t"; | ||||
| } | ||||
|  | ||||
| void bench_wilson_eo ( | ||||
| 		   LatticeFermion &    src, | ||||
| 		   LatticeFermion & result, | ||||
| 		   WilsonFermionR &     Dw, | ||||
| 		   double const     volume, | ||||
| 		   int const           dag ) | ||||
| { | ||||
|   int ncall    = 1000; | ||||
|   long unsigned int single_site_flops = 8*QCD::Nc*(7+16*QCD::Nc); | ||||
|   double t0    = usecond(); | ||||
|   for(int i=0; i<ncall; i++) { Dw.DhopEO(src,result,dag); } | ||||
|   double t1    = usecond(); | ||||
|   double flops = (single_site_flops * volume * ncall)/2.0; | ||||
|   std::cout << flops/(t1-t0) << "\t\t"; | ||||
| } | ||||
|   | ||||
| @@ -1,175 +0,0 @@ | ||||
|     /************************************************************************************* | ||||
|  | ||||
|     Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
|     Source file: ./tests/Test_zmm.cc | ||||
|  | ||||
|     Copyright (C) 2015 | ||||
|  | ||||
| Author: paboyle <paboyle@ph.ed.ac.uk> | ||||
|  | ||||
|     This program is free software; you can redistribute it and/or modify | ||||
|     it under the terms of the GNU General Public License as published by | ||||
|     the Free Software Foundation; either version 2 of the License, or | ||||
|     (at your option) any later version. | ||||
|  | ||||
|     This program is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU General Public License along | ||||
|     with this program; if not, write to the Free Software Foundation, Inc., | ||||
|     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Grid::QCD; | ||||
|  | ||||
|  | ||||
| int bench(std::ofstream &os, std::vector<int> &latt4,int Ls); | ||||
|  | ||||
| int main(int argc,char **argv) | ||||
| { | ||||
|   Grid_init(&argc,&argv); | ||||
|   std::ofstream os("zmm.dat"); | ||||
|  | ||||
|   os << "#V Ls Lxy Lzt C++ Asm OMP L1 " <<std::endl; | ||||
|   std::cout<<GridLogMessage << "====================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "= Benchmarking ZMM"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "====================================================================="<<std::endl; | ||||
|   std::cout<<GridLogMessage << "Volume \t\t\t\tC++DW/MFLOPs\tASM-DW/MFLOPs\tdiff"<<std::endl; | ||||
|   std::cout<<GridLogMessage << "====================================================================="<<std::endl; | ||||
|   for(int L=4;L<=32;L+=4){ | ||||
|     for(int m=1;m<=2;m++){ | ||||
|       for(int Ls=8;Ls<=16;Ls+=8){ | ||||
| 	std::vector<int> grid({L,L,m*L,m*L}); | ||||
|   std::cout << GridLogMessage <<"\t"; | ||||
| 	for(int i=0;i<4;i++) {  | ||||
| 	  std::cout << grid[i]<<"x"; | ||||
| 	} | ||||
| 	std::cout << Ls<<"\t\t"; | ||||
| 	bench(os,grid,Ls); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| int bench(std::ofstream &os, std::vector<int> &latt4,int Ls) | ||||
| { | ||||
|  | ||||
|   GridCartesian         * UGrid   = SpaceTimeGrid::makeFourDimGrid(latt4, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi()); | ||||
|   GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); | ||||
|   GridCartesian         * FGrid   = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid); | ||||
|   GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid); | ||||
|  | ||||
|   std::vector<int> simd_layout = GridDefaultSimd(Nd,vComplex::Nsimd()); | ||||
|   std::vector<int> mpi_layout  = GridDefaultMpi(); | ||||
|   int threads = GridThread::GetThreads(); | ||||
|  | ||||
|   std::vector<int> seeds4({1,2,3,4}); | ||||
|   std::vector<int> seeds5({5,6,7,8}); | ||||
|  | ||||
|   GridSerialRNG sRNG; sRNG.SeedFixedIntegers(seeds4); | ||||
|  | ||||
|   LatticeFermion src (FGrid); | ||||
|   LatticeFermion tmp (FGrid); | ||||
|   LatticeFermion srce(FrbGrid); | ||||
|  | ||||
|   LatticeFermion resulto(FrbGrid); resulto=zero; | ||||
|   LatticeFermion resulta(FrbGrid); resulta=zero; | ||||
|   LatticeFermion junk(FrbGrid); junk=zero; | ||||
|   LatticeFermion diff(FrbGrid);  | ||||
|   LatticeGaugeField Umu(UGrid); | ||||
|  | ||||
|   double mfc, mfa, mfo, mfl1; | ||||
|  | ||||
|   GridParallelRNG          RNG4(UGrid);  RNG4.SeedFixedIntegers(seeds4); | ||||
|   GridParallelRNG          RNG5(FGrid);  RNG5.SeedFixedIntegers(seeds5); | ||||
|   random(RNG5,src); | ||||
| #if 1 | ||||
|   random(RNG4,Umu); | ||||
| #else | ||||
|   int mmu=2; | ||||
|   std::vector<LatticeColourMatrix> U(4,UGrid); | ||||
|   for(int mu=0;mu<Nd;mu++){ | ||||
|     U[mu] = PeekIndex<LorentzIndex>(Umu,mu); | ||||
|     if ( mu!=mmu ) U[mu] = zero; | ||||
|     if ( mu==mmu ) U[mu] = 1.0; | ||||
|     PokeIndex<LorentzIndex>(Umu,U[mu],mu); | ||||
|   } | ||||
| #endif | ||||
|  pickCheckerboard(Even,srce,src); | ||||
|  | ||||
|   RealD mass=0.1; | ||||
|   RealD M5  =1.8; | ||||
|   DomainWallFermionR Dw(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5); | ||||
|  | ||||
|   int ncall=50; | ||||
|   double t0=usecond(); | ||||
|   for(int i=0;i<ncall;i++){ | ||||
|     Dw.DhopOE(srce,resulto,0); | ||||
|   } | ||||
|   double t1=usecond(); | ||||
|  | ||||
|   double volume=Ls;  for(int mu=0;mu<Nd;mu++) volume=volume*latt4[mu]; | ||||
|   double flops=1344*volume/2; | ||||
|  | ||||
|   mfc = flops*ncall/(t1-t0); | ||||
|   std::cout<<mfc<<"\t\t"; | ||||
|  | ||||
|   QCD::WilsonKernelsStatic::AsmOpt=1; | ||||
|   t0=usecond(); | ||||
|   for(int i=0;i<ncall;i++){ | ||||
|     Dw.DhopOE(srce,resulta,0); | ||||
|   } | ||||
|   t1=usecond(); | ||||
|   mfa = flops*ncall/(t1-t0); | ||||
|   std::cout<<mfa<<"\t\t"; | ||||
|   /* | ||||
|   int dag=DaggerNo; | ||||
|   t0=usecond(); | ||||
|   for(int i=0;i<1;i++){ | ||||
|     Dw.DhopInternalOMPbench(Dw.StencilEven,Dw.LebesgueEvenOdd,Dw.UmuOdd,srce,resulta,dag); | ||||
|   } | ||||
|   t1=usecond(); | ||||
|   mfo = flops*100/(t1-t0); | ||||
|   std::cout<<GridLogMessage << "Called ASM-OMP Dw"<< " mflop/s =   "<< mfo<<std::endl; | ||||
|  | ||||
|   t0=usecond(); | ||||
|   for(int i=0;i<1;i++){ | ||||
|     Dw.DhopInternalL1bench(Dw.StencilEven,Dw.LebesgueEvenOdd,Dw.UmuOdd,srce,resulta,dag); | ||||
|   } | ||||
|   t1=usecond(); | ||||
|   mfl1= flops*100/(t1-t0); | ||||
|   std::cout<<GridLogMessage << "Called ASM-L1 Dw"<< " mflop/s =   "<< mfl1<<std::endl; | ||||
|   os << latt4[0]*latt4[1]*latt4[2]*latt4[3]<< " "<<Ls<<" "<< latt4[0] <<" " <<latt4[2]<< " " | ||||
|      << mfc<<" " | ||||
|      << mfa<<" " | ||||
|      << mfo<<" " | ||||
|      << mfl1<<std::endl; | ||||
|   */ | ||||
|  | ||||
| #if 0 | ||||
|   for(int i=0;i< PerformanceCounter::NumTypes(); i++ ){ | ||||
|     Dw.DhopOE(srce,resulta,0); | ||||
|     PerformanceCounter Counter(i); | ||||
|     Counter.Start(); | ||||
|     Dw.DhopOE(srce,resulta,0); | ||||
|     Counter.Stop(); | ||||
|     Counter.Report(); | ||||
|   } | ||||
| #endif | ||||
|   //resulta = (-0.5) * resulta; | ||||
|  | ||||
|   diff = resulto-resulta; | ||||
|   std::cout<<norm2(diff)<<std::endl; | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -1 +1,7 @@ | ||||
| include Make.inc | ||||
|  | ||||
| bench-local: all | ||||
| 	./Benchmark_su3 | ||||
| 	./Benchmark_memory_bandwidth | ||||
| 	./Benchmark_wilson | ||||
| 	./Benchmark_dwf --dslash-unroll | ||||
							
								
								
									
										11
									
								
								benchmarks/simple_simd_test.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								benchmarks/simple_simd_test.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| Grid::vRealD add(const Grid::vRealD &x, const Grid::vRealD &y) | ||||
| { | ||||
| 	return x+y; | ||||
| } | ||||
|  | ||||
| Grid::vRealD sub(const Grid::vRealD &x, const Grid::vRealD &y) | ||||
| { | ||||
| 	return x-y; | ||||
| } | ||||
| @@ -25,7 +25,7 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid.h> | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
|   | ||||
| @@ -25,7 +25,7 @@ Author: Peter Boyle <paboyle@ph.ed.ac.uk> | ||||
|     See the full license in the file "LICENSE" in the top level distribution directory | ||||
|     *************************************************************************************/ | ||||
|     /*  END LEGAL */ | ||||
| #include <Grid.h> | ||||
| #include <Grid/Grid.h> | ||||
|  | ||||
| using namespace std; | ||||
| using namespace Grid; | ||||
|   | ||||
							
								
								
									
										12
									
								
								bootstrap.sh
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								bootstrap.sh
									
									
									
									
									
								
							| @@ -1,17 +1,9 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| EIGEN_URL='http://bitbucket.org/eigen/eigen/get/3.2.9.tar.bz2' | ||||
| FFTW_URL=http://www.fftw.org/fftw-3.3.4.tar.gz | ||||
| EIGEN_URL='http://bitbucket.org/eigen/eigen/get/3.3.3.tar.bz2' | ||||
|  | ||||
| echo "-- deploying Eigen source..." | ||||
| wget ${EIGEN_URL} --no-check-certificate | ||||
| ./scripts/update_eigen.sh `basename ${EIGEN_URL}` | ||||
| rm `basename ${EIGEN_URL}` | ||||
|  | ||||
| echo "-- copying fftw prototypes..." | ||||
| wget ${FFTW_URL} | ||||
| ./scripts/update_fftw.sh `basename ${FFTW_URL}` | ||||
| rm `basename ${FFTW_URL}` | ||||
| wget ${EIGEN_URL} --no-check-certificate && ./scripts/update_eigen.sh `basename ${EIGEN_URL}` && rm `basename ${EIGEN_URL}` | ||||
|  | ||||
| echo '-- generating Make.inc files...' | ||||
| ./scripts/filelist | ||||
|   | ||||
							
								
								
									
										492
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										492
									
								
								configure.ac
									
									
									
									
									
								
							| @@ -1,30 +1,50 @@ | ||||
| AC_PREREQ([2.63]) | ||||
| AC_INIT([Grid], [0.5.1-dev], [https://github.com/paboyle/Grid], [Grid]) | ||||
| AC_INIT([Grid], [0.7.0], [https://github.com/paboyle/Grid], [Grid]) | ||||
| AC_CANONICAL_BUILD | ||||
| AC_CANONICAL_HOST | ||||
| AC_CANONICAL_TARGET | ||||
| AM_INIT_AUTOMAKE(subdir-objects) | ||||
| AM_INIT_AUTOMAKE([subdir-objects 1.13]) | ||||
| AM_EXTRA_RECURSIVE_TARGETS([tests bench]) | ||||
| AC_CONFIG_MACRO_DIR([m4]) | ||||
| AC_CONFIG_SRCDIR([lib/Grid.h]) | ||||
| AC_CONFIG_HEADERS([lib/Config.h]) | ||||
| AC_CONFIG_HEADERS([lib/Config.h],[sed -i 's|PACKAGE_|GRID_|' lib/Config.h]) | ||||
| m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) | ||||
|  | ||||
| ################ Get git info | ||||
| #AC_REVISION([m4_esyscmd_s([./scripts/configure.commit])]) | ||||
|  | ||||
| ################ Set flags | ||||
| # do not move! | ||||
| CXXFLAGS="-O3 $CXXFLAGS" | ||||
|  | ||||
| ############### Checks for programs | ||||
| AC_LANG(C++) | ||||
| CXXFLAGS="-O3 $CXXFLAGS" | ||||
| AC_PROG_CXX | ||||
| AC_PROG_RANLIB | ||||
|  | ||||
| ############ openmp  ############### | ||||
| ############### Get compiler informations | ||||
| AC_LANG([C++]) | ||||
| AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) | ||||
| AX_COMPILER_VENDOR | ||||
| AC_DEFINE_UNQUOTED([CXX_COMP_VENDOR],["$ax_cv_cxx_compiler_vendor"], | ||||
|       [vendor of C++ compiler that will compile the code]) | ||||
| AX_GXX_VERSION | ||||
| AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"], | ||||
|       [version of g++ that will compile the code]) | ||||
|  | ||||
|  | ||||
|  | ||||
| ############### Checks for typedefs, structures, and compiler characteristics | ||||
| AC_TYPE_SIZE_T | ||||
| AC_TYPE_UINT32_T | ||||
| AC_TYPE_UINT64_T | ||||
|  | ||||
| ############### OpenMP | ||||
| AC_OPENMP | ||||
|  | ||||
| ac_openmp=no | ||||
|  | ||||
| if test "${OPENMP_CXXFLAGS}X" != "X"; then | ||||
| ac_openmp=yes | ||||
| AM_CXXFLAGS="$OPENMP_CXXFLAGS $AM_CXXFLAGS" | ||||
| AM_LDFLAGS="$OPENMP_CXXFLAGS $AM_LDFLAGS" | ||||
|   ac_openmp=yes | ||||
|   AM_CXXFLAGS="$OPENMP_CXXFLAGS $AM_CXXFLAGS" | ||||
|   AM_LDFLAGS="$OPENMP_CXXFLAGS $AM_LDFLAGS" | ||||
| fi | ||||
|  | ||||
| ############### Checks for header files | ||||
| @@ -34,15 +54,15 @@ AC_CHECK_HEADERS(malloc/malloc.h) | ||||
| AC_CHECK_HEADERS(malloc.h) | ||||
| AC_CHECK_HEADERS(endian.h) | ||||
| AC_CHECK_HEADERS(execinfo.h) | ||||
| AC_CHECK_HEADERS(numaif.h) | ||||
| AC_CHECK_DECLS([ntohll],[], [], [[#include <arpa/inet.h>]]) | ||||
| AC_CHECK_DECLS([be64toh],[], [], [[#include <arpa/inet.h>]]) | ||||
|  | ||||
| ############### Checks for typedefs, structures, and compiler characteristics | ||||
| AC_TYPE_SIZE_T | ||||
| AC_TYPE_UINT32_T | ||||
| AC_TYPE_UINT64_T | ||||
| ############## Standard libraries | ||||
| AC_CHECK_LIB([m],[cos]) | ||||
| AC_CHECK_LIB([stdc++],[abort]) | ||||
|  | ||||
| ############### GMP and MPFR ################# | ||||
| ############### GMP and MPFR | ||||
| AC_ARG_WITH([gmp], | ||||
|     [AS_HELP_STRING([--with-gmp=prefix], | ||||
|     [try this for a non-standard install prefix of the GMP library])], | ||||
| @@ -54,10 +74,24 @@ AC_ARG_WITH([mpfr], | ||||
|     [AM_CXXFLAGS="-I$with_mpfr/include $AM_CXXFLAGS"] | ||||
|     [AM_LDFLAGS="-L$with_mpfr/lib $AM_LDFLAGS"]) | ||||
|  | ||||
| ################## lapack #################### | ||||
| ############### FFTW3 | ||||
| AC_ARG_WITH([fftw], | ||||
|             [AS_HELP_STRING([--with-fftw=prefix], | ||||
|             [try this for a non-standard install prefix of the FFTW3 library])], | ||||
|             [AM_CXXFLAGS="-I$with_fftw/include $AM_CXXFLAGS"] | ||||
|             [AM_LDFLAGS="-L$with_fftw/lib $AM_LDFLAGS"]) | ||||
|  | ||||
| ############### LIME | ||||
| AC_ARG_WITH([lime], | ||||
|             [AS_HELP_STRING([--with-lime=prefix], | ||||
|             [try this for a non-standard install prefix of the LIME library])], | ||||
|             [AM_CXXFLAGS="-I$with_lime/include $AM_CXXFLAGS"] | ||||
|             [AM_LDFLAGS="-L$with_lime/lib $AM_LDFLAGS"]) | ||||
|  | ||||
| ############### lapack | ||||
| AC_ARG_ENABLE([lapack], | ||||
|     [AC_HELP_STRING([--enable-lapack=yes|no|prefix], [enable LAPACK])],  | ||||
|     [ac_LAPACK=${enable_lapack}],[ac_LAPACK=no]) | ||||
|     [AC_HELP_STRING([--enable-lapack=yes|no|prefix], [enable LAPACK])], | ||||
|     [ac_LAPACK=${enable_lapack}], [ac_LAPACK=no]) | ||||
|  | ||||
| case ${ac_LAPACK} in | ||||
|     no) | ||||
| @@ -67,12 +101,47 @@ case ${ac_LAPACK} in | ||||
|     *) | ||||
|         AM_CXXFLAGS="-I$ac_LAPACK/include $AM_CXXFLAGS" | ||||
|         AM_LDFLAGS="-L$ac_LAPACK/lib $AM_LDFLAGS" | ||||
|         AC_DEFINE([USE_LAPACK],[1],[use LAPACK]) | ||||
|         AC_DEFINE([USE_LAPACK],[1],[use LAPACK]);; | ||||
| esac | ||||
|  | ||||
| ################## first-touch #################### | ||||
| ############### FP16 conversions | ||||
| AC_ARG_ENABLE([sfw-fp16], | ||||
|     [AC_HELP_STRING([--enable-sfw-fp16=yes|no], [enable software fp16 comms])], | ||||
|     [ac_SFW_FP16=${enable_sfw_fp16}], [ac_SFW_FP16=yes]) | ||||
| case ${ac_SFW_FP16} in | ||||
|     yes) | ||||
|       AC_DEFINE([SFW_FP16],[1],[software conversion to fp16]);; | ||||
|     no);; | ||||
|     *) | ||||
|       AC_MSG_ERROR(["SFW FP16 option not supported ${ac_SFW_FP16}"]);; | ||||
| esac | ||||
|  | ||||
| ############### MKL | ||||
| AC_ARG_ENABLE([mkl], | ||||
|     [AC_HELP_STRING([--enable-mkl=yes|no|prefix], [enable Intel MKL for LAPACK & FFTW])], | ||||
|     [ac_MKL=${enable_mkl}], [ac_MKL=no]) | ||||
|  | ||||
| case ${ac_MKL} in | ||||
|     no) | ||||
|         ;; | ||||
|     yes) | ||||
|         AC_DEFINE([USE_MKL], [1], [Define to 1 if you use the Intel MKL]);; | ||||
|     *) | ||||
|         AM_CXXFLAGS="-I$ac_MKL/include $AM_CXXFLAGS" | ||||
|         AM_LDFLAGS="-L$ac_MKL/lib $AM_LDFLAGS" | ||||
|         AC_DEFINE([USE_MKL], [1], [Define to 1 if you use the Intel MKL]);; | ||||
| esac | ||||
|  | ||||
| ############### HDF5 | ||||
| AC_ARG_WITH([hdf5], | ||||
|     [AS_HELP_STRING([--with-hdf5=prefix], | ||||
|     [try this for a non-standard install prefix of the HDF5 library])], | ||||
|     [AM_CXXFLAGS="-I$with_hdf5/include $AM_CXXFLAGS"] | ||||
|     [AM_LDFLAGS="-L$with_hdf5/lib $AM_LDFLAGS"]) | ||||
|  | ||||
| ############### first-touch | ||||
| AC_ARG_ENABLE([numa], | ||||
|     [AC_HELP_STRING([--enable-numa=yes|no|prefix], [enable first touch numa opt])],  | ||||
|     [AC_HELP_STRING([--enable-numa=yes|no|prefix], [enable first touch numa opt])], | ||||
|     [ac_NUMA=${enable_NUMA}],[ac_NUMA=no]) | ||||
|  | ||||
| case ${ac_NUMA} in | ||||
| @@ -84,84 +153,121 @@ case ${ac_NUMA} in | ||||
|         AC_DEFINE([GRID_NUMA],[1],[First touch numa locality]);; | ||||
| esac | ||||
|  | ||||
| ################## FFTW3 #################### | ||||
| AC_ARG_WITH([fftw],     | ||||
|             [AS_HELP_STRING([--with-fftw=prefix], | ||||
|             [try this for a non-standard install prefix of the FFTW3 library])], | ||||
|             [AM_CXXFLAGS="-I$with_fftw/include $AM_CXXFLAGS"] | ||||
|             [AM_LDFLAGS="-L$with_fftw/lib $AM_LDFLAGS"]) | ||||
|  | ||||
| ################ Get compiler informations | ||||
| AC_LANG([C++]) | ||||
| AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) | ||||
| AX_COMPILER_VENDOR | ||||
| AC_DEFINE_UNQUOTED([CXX_COMP_VENDOR],["$ax_cv_cxx_compiler_vendor"], | ||||
|       [vendor of C++ compiler that will compile the code]) | ||||
| AX_GXX_VERSION | ||||
| AC_DEFINE_UNQUOTED([GXX_VERSION],["$GXX_VERSION"], | ||||
|       [version of g++ that will compile the code]) | ||||
|  | ||||
| ############### Checks for library functions | ||||
| CXXFLAGS_CPY=$CXXFLAGS | ||||
| LDFLAGS_CPY=$LDFLAGS | ||||
| CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" | ||||
| LDFLAGS="$AM_LDFLAGS $LDFLAGS" | ||||
|  | ||||
| AC_CHECK_FUNCS([gettimeofday]) | ||||
| AC_CHECK_LIB([gmp],[__gmpf_init], | ||||
|              [AC_CHECK_LIB([mpfr],[mpfr_init], | ||||
|                  [AC_DEFINE([HAVE_LIBMPFR], [1], [Define to 1 if you have the `MPFR' library (-lmpfr).])] | ||||
|                  [have_mpfr=true] | ||||
|                  [LIBS="$LIBS -lmpfr"], | ||||
|                  [AC_MSG_ERROR([MPFR library not found])])] | ||||
|    	     [AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have the `GMP' library (-lgmp).])] | ||||
|              [have_gmp=true] | ||||
|              [LIBS="$LIBS -lgmp"], | ||||
|              [AC_MSG_WARN([**** GMP library not found, Grid can still compile but RHMC will not work ****])]) | ||||
|  | ||||
| if test "${ac_MKL}x" != "nox"; then | ||||
|     AC_SEARCH_LIBS([mkl_set_interface_layer], [mkl_rt], [], | ||||
|                    [AC_MSG_ERROR("MKL enabled but library not found")]) | ||||
| fi | ||||
|  | ||||
| AC_SEARCH_LIBS([__gmpf_init], [gmp], | ||||
|                [AC_SEARCH_LIBS([mpfr_init], [mpfr], | ||||
|                                [AC_DEFINE([HAVE_LIBMPFR], [1], | ||||
|                                           [Define to 1 if you have the `MPFR' library])] | ||||
|                                [have_mpfr=true], [AC_MSG_ERROR([MPFR library not found])])] | ||||
|                [AC_DEFINE([HAVE_LIBGMP], [1], [Define to 1 if you have the `GMP' library])] | ||||
|                [have_gmp=true]) | ||||
|  | ||||
| if test "${ac_LAPACK}x" != "nox"; then | ||||
|     AC_CHECK_LIB([lapack],[LAPACKE_sbdsdc],[], | ||||
|                  [AC_MSG_ERROR("LAPACK enabled but library not found")]) | ||||
|     AC_SEARCH_LIBS([LAPACKE_sbdsdc], [lapack], [], | ||||
|                    [AC_MSG_ERROR("LAPACK enabled but library not found")]) | ||||
| fi | ||||
| AC_CHECK_LIB([fftw3],[fftw_execute], | ||||
|   [AC_DEFINE([HAVE_FFTW],[1],[Define to 1 if you have the `FFTW' library (-lfftw3).])] | ||||
|   [have_fftw=true] | ||||
|   [LIBS="$LIBS -lfftw3 -lfftw3f"], | ||||
|   [AC_MSG_WARN([**** FFTW library not found, Grid can still compile but FFT-based routines will not work ****])]) | ||||
|  | ||||
| AC_SEARCH_LIBS([fftw_execute], [fftw3], | ||||
|                [AC_SEARCH_LIBS([fftwf_execute], [fftw3f], [], | ||||
|                                [AC_MSG_ERROR("single precision FFTW library not found")])] | ||||
|                [AC_DEFINE([HAVE_FFTW], [1], [Define to 1 if you have the `FFTW' library])] | ||||
|                [have_fftw=true]) | ||||
|  | ||||
| AC_SEARCH_LIBS([limeCreateReader], [lime], | ||||
|                [AC_DEFINE([HAVE_LIME], [1], [Define to 1 if you have the `LIME' library])] | ||||
|                [have_lime=true], | ||||
| 	       [AC_MSG_WARN(C-LIME library was not found in your system. | ||||
| In order to use ILGG file format please install or provide the correct path to your installation | ||||
| Info at: http://usqcd.jlab.org/usqcd-docs/c-lime/)]) | ||||
|  | ||||
| AC_SEARCH_LIBS([crc32], [z], | ||||
|                [AC_DEFINE([HAVE_ZLIB], [1], [Define to 1 if you have the `LIBZ' library])] | ||||
|                [have_zlib=true] [LIBS="${LIBS} -lz"], | ||||
| 	       [AC_MSG_ERROR(zlib library was not found in your system.)]) | ||||
|  | ||||
| AC_SEARCH_LIBS([move_pages], [numa], | ||||
|                [AC_DEFINE([HAVE_LIBNUMA], [1], [Define to 1 if you have the `LIBNUMA' library])] | ||||
|                [have_libnuma=true] [LIBS="${LIBS} -lnuma"], | ||||
| 	       [AC_MSG_WARN(libnuma library was not found in your system. Some optimisations will not apply)]) | ||||
|  | ||||
| AC_SEARCH_LIBS([H5Fopen], [hdf5_cpp], | ||||
|                [AC_DEFINE([HAVE_HDF5], [1], [Define to 1 if you have the `HDF5' library])] | ||||
|                [have_hdf5=true] | ||||
|                [LIBS="${LIBS} -lhdf5"], [], [-lhdf5]) | ||||
| AM_CONDITIONAL(BUILD_HDF5, [ test "${have_hdf5}X" == "trueX" ]) | ||||
|  | ||||
| CXXFLAGS=$CXXFLAGS_CPY | ||||
| LDFLAGS=$LDFLAGS_CPY | ||||
|  | ||||
| ############### SIMD instruction selection | ||||
| AC_ARG_ENABLE([simd],[AC_HELP_STRING([--enable-simd=SSE4|AVX|AVXFMA4|AVXFMA|AVX2|AVX512|AVX512MIC|IMCI|KNL|KNC],\ | ||||
| 	[Select instructions to be SSE4.0, AVX 1.0, AVX 2.0+FMA, AVX 512, IMCI])],\ | ||||
| 	[ac_SIMD=${enable_simd}],[ac_SIMD=GEN]) | ||||
| AC_ARG_ENABLE([simd],[AC_HELP_STRING([--enable-simd=code], | ||||
|               [select SIMD target (cf. README.md)])], [ac_SIMD=${enable_simd}], [ac_SIMD=GEN]) | ||||
|  | ||||
| AC_ARG_ENABLE([gen-simd-width], | ||||
|             [AS_HELP_STRING([--enable-gen-simd-width=size], | ||||
|             [size (in bytes) of the generic SIMD vectors (default: 32)])], | ||||
|             [ac_gen_simd_width=$enable_gen_simd_width], | ||||
|             [ac_gen_simd_width=32]) | ||||
|  | ||||
| case ${ax_cv_cxx_compiler_vendor} in | ||||
|   clang|gnu) | ||||
|     case ${ac_SIMD} in | ||||
|       SSE4) | ||||
|         AC_DEFINE([SSE4],[1],[SSE4 intrinsics]) | ||||
|         SIMD_FLAGS='-msse4.2';; | ||||
| 	case ${ac_SFW_FP16} in | ||||
| 	  yes) | ||||
| 	  SIMD_FLAGS='-msse4.2';; | ||||
| 	  no) | ||||
| 	  SIMD_FLAGS='-msse4.2 -mf16c';; | ||||
| 	  *) | ||||
|           AC_MSG_ERROR(["SFW_FP16 must be either yes or no value ${ac_SFW_FP16} "]);; | ||||
| 	esac;; | ||||
|       AVX) | ||||
|         AC_DEFINE([AVX1],[1],[AVX intrinsics]) | ||||
|         SIMD_FLAGS='-mavx';; | ||||
|         SIMD_FLAGS='-mavx -mf16c';; | ||||
|       AVXFMA4) | ||||
|         AC_DEFINE([AVXFMA4],[1],[AVX intrinsics with FMA4]) | ||||
|         SIMD_FLAGS='-mavx -mfma4';; | ||||
|         SIMD_FLAGS='-mavx -mfma4 -mf16c';; | ||||
|       AVXFMA) | ||||
|         AC_DEFINE([AVXFMA],[1],[AVX intrinsics with FMA3]) | ||||
|         SIMD_FLAGS='-mavx -mfma';; | ||||
|         SIMD_FLAGS='-mavx -mfma -mf16c';; | ||||
|       AVX2) | ||||
|         AC_DEFINE([AVX2],[1],[AVX2 intrinsics]) | ||||
|         SIMD_FLAGS='-mavx2 -mfma';; | ||||
|       AVX512|AVX512MIC|KNL) | ||||
|         SIMD_FLAGS='-mavx2 -mfma -mf16c';; | ||||
|       AVX512) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics]) | ||||
|         SIMD_FLAGS='-mavx512f -mavx512pf -mavx512er -mavx512cd';; | ||||
|       IMCI|KNC) | ||||
|       SKL) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics for SkyLake Xeon]) | ||||
|         SIMD_FLAGS='-march=skylake-avx512';; | ||||
|       KNC) | ||||
|         AC_DEFINE([IMCI],[1],[IMCI intrinsics for Knights Corner]) | ||||
|         SIMD_FLAGS='';; | ||||
|       KNL) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics]) | ||||
|         AC_DEFINE([KNL],[1],[Knights landing processor]) | ||||
|         SIMD_FLAGS='-march=knl';; | ||||
|       GEN) | ||||
|         AC_DEFINE([GENERIC_VEC],[1],[generic vector code]) | ||||
|         AC_DEFINE([GEN],[1],[generic vector code]) | ||||
|         AC_DEFINE_UNQUOTED([GEN_SIMD_WIDTH],[$ac_gen_simd_width], | ||||
|                            [generic SIMD vector width (in bytes)]) | ||||
|         SIMD_GEN_WIDTH_MSG=" (width= $ac_gen_simd_width)" | ||||
|         SIMD_FLAGS='';; | ||||
|       NEONv8) | ||||
|         AC_DEFINE([NEONV8],[1],[ARMv8 NEON]) | ||||
|         SIMD_FLAGS='-march=armv8-a';; | ||||
|       QPX|BGQ) | ||||
|         AC_DEFINE([QPX],[1],[QPX intrinsics for BG/Q]) | ||||
|         SIMD_FLAGS='';; | ||||
| @@ -176,26 +282,27 @@ case ${ax_cv_cxx_compiler_vendor} in | ||||
|       AVX) | ||||
|         AC_DEFINE([AVX1],[1],[AVX intrinsics]) | ||||
|         SIMD_FLAGS='-mavx -xavx';; | ||||
|       AVXFMA4) | ||||
|         AC_DEFINE([AVXFMA4],[1],[AVX intrinsics with FMA4]) | ||||
|         SIMD_FLAGS='-mavx -mfma';; | ||||
|       AVXFMA) | ||||
|         AC_DEFINE([AVXFMA],[1],[AVX intrinsics with FMA4]) | ||||
|         SIMD_FLAGS='-mavx -mfma';; | ||||
|         AC_DEFINE([AVXFMA],[1],[AVX intrinsics with FMA3]) | ||||
|         SIMD_FLAGS='-mavx -fma';; | ||||
|       AVX2) | ||||
|         AC_DEFINE([AVX2],[1],[AVX2 intrinsics]) | ||||
|         SIMD_FLAGS='-march=core-avx2 -xcore-avx2';; | ||||
|       AVX512) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics]) | ||||
|         SIMD_FLAGS='-xcore-avx512';; | ||||
|       AVX512MIC|KNL) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics for Knights Landing]) | ||||
|         SIMD_FLAGS='-xmic-avx512';; | ||||
|       IMCI|KNC) | ||||
|       KNC) | ||||
|         AC_DEFINE([IMCI],[1],[IMCI Intrinsics for Knights Corner]) | ||||
|         SIMD_FLAGS='';; | ||||
|       KNL) | ||||
|         AC_DEFINE([AVX512],[1],[AVX512 intrinsics for Knights Landing]) | ||||
|         AC_DEFINE([KNL],[1],[Knights landing processor]) | ||||
|         SIMD_FLAGS='-xmic-avx512';; | ||||
|       GEN) | ||||
|         AC_DEFINE([GENERIC_VEC],[1],[generic vector code]) | ||||
|         AC_DEFINE([GEN],[1],[generic vector code]) | ||||
|         AC_DEFINE_UNQUOTED([GEN_SIMD_WIDTH],[$ac_gen_simd_width], | ||||
|                            [generic SIMD vector width (in bytes)]) | ||||
|         SIMD_GEN_WIDTH_MSG=" (width= $ac_gen_simd_width)" | ||||
|         SIMD_FLAGS='';; | ||||
|       *) | ||||
|         AC_MSG_ERROR(["SIMD option ${ac_SIMD} not supported by the Intel compiler"]);; | ||||
| @@ -208,14 +315,18 @@ AM_CXXFLAGS="$SIMD_FLAGS $AM_CXXFLAGS" | ||||
| AM_CFLAGS="$SIMD_FLAGS $AM_CFLAGS" | ||||
|  | ||||
| case ${ac_SIMD} in | ||||
|   AVX512|AVX512MIC|KNL) | ||||
|   AVX512|KNL) | ||||
|     AC_DEFINE([TEST_ZMM],[1],[compile ZMM test]);; | ||||
|   *) | ||||
| 	;; | ||||
| esac | ||||
|  | ||||
| ############### precision selection | ||||
| AC_ARG_ENABLE([precision],[AC_HELP_STRING([--enable-precision=single|double],[Select default word size of Real])],[ac_PRECISION=${enable_precision}],[ac_PRECISION=double]) | ||||
| ############### Precision selection | ||||
| AC_ARG_ENABLE([precision], | ||||
|               [AC_HELP_STRING([--enable-precision=single|double], | ||||
|                               [Select default word size of Real])], | ||||
|               [ac_PRECISION=${enable_precision}],[ac_PRECISION=double]) | ||||
|  | ||||
| case ${ac_PRECISION} in | ||||
|      single) | ||||
|        AC_DEFINE([GRID_DEFAULT_PRECISION_SINGLE],[1],[GRID_DEFAULT_PRECISION is SINGLE] ) | ||||
| @@ -223,42 +334,84 @@ case ${ac_PRECISION} in | ||||
|      double) | ||||
|        AC_DEFINE([GRID_DEFAULT_PRECISION_DOUBLE],[1],[GRID_DEFAULT_PRECISION is DOUBLE] ) | ||||
|      ;; | ||||
|      *) | ||||
|      AC_MSG_ERROR([${ac_PRECISION} unsupported --enable-precision option]); | ||||
|      ;; | ||||
| esac | ||||
|  | ||||
| ######################  Shared memory allocation technique under MPI3 | ||||
| AC_ARG_ENABLE([shm],[AC_HELP_STRING([--enable-shm=shmopen|shmget|hugetlbfs|shmnone], | ||||
|               [Select SHM allocation technique])],[ac_SHM=${enable_shm}],[ac_SHM=shmopen]) | ||||
|  | ||||
| case ${ac_SHM} in | ||||
|  | ||||
|      shmopen) | ||||
|      AC_DEFINE([GRID_MPI3_SHMOPEN],[1],[GRID_MPI3_SHMOPEN] ) | ||||
|      ;; | ||||
|  | ||||
|      shmget) | ||||
|      AC_DEFINE([GRID_MPI3_SHMGET],[1],[GRID_MPI3_SHMGET] ) | ||||
|      ;; | ||||
|  | ||||
|      shmnone) | ||||
|      AC_DEFINE([GRID_MPI3_SHM_NONE],[1],[GRID_MPI3_SHM_NONE] ) | ||||
|      ;; | ||||
|  | ||||
|      hugetlbfs) | ||||
|      AC_DEFINE([GRID_MPI3_SHMMMAP],[1],[GRID_MPI3_SHMMMAP] ) | ||||
|      ;; | ||||
|  | ||||
|      *) | ||||
|      AC_MSG_ERROR([${ac_SHM} unsupported --enable-shm option]); | ||||
|      ;; | ||||
| esac | ||||
|  | ||||
| ######################  Shared base path for SHMMMAP | ||||
| AC_ARG_ENABLE([shmpath],[AC_HELP_STRING([--enable-shmpath=path], | ||||
|               [Select SHM mmap base path for hugetlbfs])], | ||||
| 	      [ac_SHMPATH=${enable_shmpath}], | ||||
| 	      [ac_SHMPATH=/var/lib/hugetlbfs/global/pagesize-2MB/]) | ||||
| AC_DEFINE_UNQUOTED([GRID_SHM_PATH],["$ac_SHMPATH"],[Path to a hugetlbfs filesystem for MMAPing]) | ||||
|  | ||||
| ############### communication type selection | ||||
| AC_ARG_ENABLE([comms],[AC_HELP_STRING([--enable-comms=none|mpi|mpi-auto|shmem],[Select communications])],[ac_COMMS=${enable_comms}],[ac_COMMS=none]) | ||||
| AC_ARG_ENABLE([comms],[AC_HELP_STRING([--enable-comms=none|mpi|mpi-auto], | ||||
|               [Select communications])],[ac_COMMS=${enable_comms}],[ac_COMMS=none]) | ||||
|  | ||||
| case ${ac_COMMS} in | ||||
|      none) | ||||
|        AC_DEFINE([GRID_COMMS_NONE],[1],[GRID_COMMS_NONE] ) | ||||
|         AC_DEFINE([GRID_COMMS_NONE],[1],[GRID_COMMS_NONE] ) | ||||
|         comms_type='none' | ||||
|      ;; | ||||
|      mpi-auto) | ||||
|        AC_DEFINE([GRID_COMMS_MPI],[1],[GRID_COMMS_MPI] ) | ||||
|        LX_FIND_MPI | ||||
|        if test "x$have_CXX_mpi" = 'xno'; then AC_MSG_ERROR(["MPI not found"]); fi | ||||
|        AM_CXXFLAGS="$MPI_CXXFLAGS $AM_CXXFLAGS" | ||||
|        AM_CFLAGS="$MPI_CFLAGS $AM_CFLAGS" | ||||
|        AM_LDFLAGS="`echo $MPI_CXXLDFLAGS | sed -E 's/-l@<:@^ @:>@+//g'` $AM_LDFLAGS" | ||||
|        LIBS="`echo $MPI_CXXLDFLAGS | sed -E 's/-L@<:@^ @:>@+//g'` $LIBS" | ||||
|      ;; | ||||
|      mpi) | ||||
|        AC_DEFINE([GRID_COMMS_MPI],[1],[GRID_COMMS_MPI] ) | ||||
|      ;; | ||||
|      shmem) | ||||
|        AC_DEFINE([GRID_COMMS_SHMEM],[1],[GRID_COMMS_SHMEM] ) | ||||
|      mpi*) | ||||
|         AC_DEFINE([GRID_COMMS_MPI3],[1],[GRID_COMMS_MPI3] ) | ||||
|         comms_type='mpi3' | ||||
|      ;; | ||||
|      *) | ||||
|      AC_MSG_ERROR([${ac_COMMS} unsupported --enable-comms option]);  | ||||
|         AC_MSG_ERROR([${ac_COMMS} unsupported --enable-comms option]); | ||||
|      ;; | ||||
| esac | ||||
| AM_CONDITIONAL(BUILD_COMMS_SHMEM,[ test "X${ac_COMMS}X" == "XshmemX" ]) | ||||
| AM_CONDITIONAL(BUILD_COMMS_MPI,[ test "X${ac_COMMS}X" == "XmpiX" || test "X${ac_COMMS}X" == "Xmpi-autoX" ]) | ||||
| AM_CONDITIONAL(BUILD_COMMS_NONE,[ test "X${ac_COMMS}X" == "XnoneX" ]) | ||||
| case ${ac_COMMS} in | ||||
|     *-auto) | ||||
|         LX_FIND_MPI | ||||
|         if test "x$have_CXX_mpi" = 'xno'; then AC_MSG_ERROR(["The configure could not find the MPI compilation flags. N.B. The -auto mode is not supported by Cray wrappers. Use the non -auto version in this case."]); fi | ||||
|         AM_CXXFLAGS="$MPI_CXXFLAGS $AM_CXXFLAGS" | ||||
|         AM_CFLAGS="$MPI_CFLAGS $AM_CFLAGS" | ||||
|         AM_LDFLAGS="`echo $MPI_CXXLDFLAGS | sed -E 's/-l@<:@^ @:>@+//g'` $AM_LDFLAGS" | ||||
|         LIBS="`echo $MPI_CXXLDFLAGS | sed -E 's/-L@<:@^ @:>@+//g'` $LIBS";; | ||||
|     *) | ||||
|         ;; | ||||
| esac | ||||
|  | ||||
| AM_CONDITIONAL(BUILD_COMMS_SHMEM, [ test "${comms_type}X" == "shmemX" ]) | ||||
| AM_CONDITIONAL(BUILD_COMMS_MPI,   [ test "${comms_type}X" == "mpiX" ]) | ||||
| AM_CONDITIONAL(BUILD_COMMS_MPI3,  [ test "${comms_type}X" == "mpi3X" ] ) | ||||
| AM_CONDITIONAL(BUILD_COMMS_MPIT,  [ test "${comms_type}X" == "mpitX" ] ) | ||||
| AM_CONDITIONAL(BUILD_COMMS_NONE,  [ test "${comms_type}X" == "noneX" ]) | ||||
|  | ||||
| ############### RNG selection | ||||
| AC_ARG_ENABLE([rng],[AC_HELP_STRING([--enable-rng=ranlux48|mt19937],\ | ||||
| 	[Select Random Number Generator to be used])],\ | ||||
| 	[ac_RNG=${enable_rng}],[ac_RNG=ranlux48]) | ||||
| AC_ARG_ENABLE([rng],[AC_HELP_STRING([--enable-rng=ranlux48|mt19937|sitmo],\ | ||||
| 	            [Select Random Number Generator to be used])],\ | ||||
| 	            [ac_RNG=${enable_rng}],[ac_RNG=sitmo]) | ||||
|  | ||||
| case ${ac_RNG} in | ||||
|      ranlux48) | ||||
| @@ -267,15 +420,19 @@ case ${ac_RNG} in | ||||
|      mt19937) | ||||
|       AC_DEFINE([RNG_MT19937],[1],[RNG_MT19937] ) | ||||
|      ;; | ||||
|      sitmo) | ||||
|       AC_DEFINE([RNG_SITMO],[1],[RNG_SITMO] ) | ||||
|      ;; | ||||
|      *) | ||||
|       AC_MSG_ERROR([${ac_RNG} unsupported --enable-rng option]);  | ||||
|       AC_MSG_ERROR([${ac_RNG} unsupported --enable-rng option]); | ||||
|      ;; | ||||
| esac | ||||
|  | ||||
| ############### timer option | ||||
| ############### Timer option | ||||
| AC_ARG_ENABLE([timers],[AC_HELP_STRING([--enable-timers],\ | ||||
| 	[Enable system dependent high res timers])],\ | ||||
| 	[ac_TIMERS=${enable_timers}],[ac_TIMERS=yes]) | ||||
| 	            [Enable system dependent high res timers])],\ | ||||
| 	            [ac_TIMERS=${enable_timers}],[ac_TIMERS=yes]) | ||||
|  | ||||
| case ${ac_TIMERS} in | ||||
|      yes) | ||||
|       AC_DEFINE([TIMERS_ON],[1],[TIMERS_ON] ) | ||||
| @@ -284,37 +441,100 @@ case ${ac_TIMERS} in | ||||
|       AC_DEFINE([TIMERS_OFF],[1],[TIMERS_OFF] ) | ||||
|      ;; | ||||
|      *) | ||||
|       AC_MSG_ERROR([${ac_TIMERS} unsupported --enable-timers option]);  | ||||
|       AC_MSG_ERROR([${ac_TIMERS} unsupported --enable-timers option]); | ||||
|      ;; | ||||
| esac | ||||
|  | ||||
| ############### Chroma regression test | ||||
| AC_ARG_ENABLE([chroma],[AC_HELP_STRING([--enable-chroma],[Expect chroma compiled under c++11 ])],ac_CHROMA=yes,ac_CHROMA=no) | ||||
| AC_ARG_ENABLE([chroma],[AC_HELP_STRING([--enable-chroma], | ||||
|               [Expect chroma compiled under c++11 ])],ac_CHROMA=yes,ac_CHROMA=no) | ||||
|  | ||||
| case ${ac_CHROMA} in | ||||
|      yes|no) | ||||
|      ;; | ||||
|      *) | ||||
|        AC_MSG_ERROR([${ac_CHROMA} unsupported --enable-chroma option]);  | ||||
|        AC_MSG_ERROR([${ac_CHROMA} unsupported --enable-chroma option]); | ||||
|      ;; | ||||
| esac | ||||
|  | ||||
| AM_CONDITIONAL(BUILD_CHROMA_REGRESSION,[ test "X${ac_CHROMA}X" == "XyesX" ]) | ||||
|  | ||||
| ############### Doxygen | ||||
| AC_PROG_DOXYGEN | ||||
|  | ||||
| if test -n "$DOXYGEN" | ||||
| then | ||||
| AC_CONFIG_FILES([docs/doxy.cfg]) | ||||
| fi | ||||
| DX_DOXYGEN_FEATURE([OFF]) | ||||
| DX_DOT_FEATURE([OFF]) | ||||
| DX_HTML_FEATURE([ON]) | ||||
| DX_CHM_FEATURE([OFF]) | ||||
| DX_CHI_FEATURE([OFF]) | ||||
| DX_MAN_FEATURE([OFF]) | ||||
| DX_RTF_FEATURE([OFF]) | ||||
| DX_XML_FEATURE([OFF]) | ||||
| DX_PDF_FEATURE([OFF]) | ||||
| DX_PS_FEATURE([OFF]) | ||||
| DX_INIT_DOXYGEN([$PACKAGE_NAME], [doxygen.cfg]) | ||||
|  | ||||
| ############### Ouput | ||||
| cwd=`pwd -P`; cd ${srcdir}; abs_srcdir=`pwd -P`; cd ${cwd} | ||||
| GRID_CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" | ||||
| GRID_LDFLAGS="$AM_LDFLAGS $LDFLAGS" | ||||
| GRID_LIBS=$LIBS | ||||
| GRID_SHORT_SHA=`git rev-parse --short HEAD` | ||||
| GRID_SHA=`git rev-parse HEAD` | ||||
| GRID_BRANCH=`git rev-parse --abbrev-ref HEAD` | ||||
| AM_CXXFLAGS="-I${abs_srcdir}/include $AM_CXXFLAGS" | ||||
| AM_CFLAGS="-I${abs_srcdir}/include $AM_CFLAGS" | ||||
| AM_LDFLAGS="-L${cwd}/lib $AM_LDFLAGS" | ||||
| AC_SUBST([AM_CFLAGS]) | ||||
| AC_SUBST([AM_CXXFLAGS]) | ||||
| AC_SUBST([AM_LDFLAGS]) | ||||
| AC_SUBST([GRID_CXXFLAGS]) | ||||
| AC_SUBST([GRID_LDFLAGS]) | ||||
| AC_SUBST([GRID_LIBS]) | ||||
| AC_SUBST([GRID_SHA]) | ||||
| AC_SUBST([GRID_BRANCH]) | ||||
|  | ||||
| git_commit=`cd $srcdir && ./scripts/configure.commit` | ||||
|  | ||||
| echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
| Summary of configuration for $PACKAGE v$VERSION | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
| ----- GIT VERSION ------------------------------------- | ||||
| $git_commit | ||||
| ----- PLATFORM ---------------------------------------- | ||||
| architecture (build)        : $build_cpu | ||||
| os (build)                  : $build_os | ||||
| architecture (target)       : $target_cpu | ||||
| os (target)                 : $target_os | ||||
| compiler vendor             : ${ax_cv_cxx_compiler_vendor} | ||||
| compiler version            : ${ax_cv_gxx_version} | ||||
| ----- BUILD OPTIONS ----------------------------------- | ||||
| SIMD                        : ${ac_SIMD}${SIMD_GEN_WIDTH_MSG} | ||||
| Threading                   : ${ac_openmp} | ||||
| Communications type         : ${comms_type} | ||||
| Shared memory allocator     : ${ac_SHM} | ||||
| Shared memory mmap path     : ${ac_SHMPATH} | ||||
| Default precision           : ${ac_PRECISION} | ||||
| Software FP16 conversion    : ${ac_SFW_FP16} | ||||
| RNG choice                  : ${ac_RNG} | ||||
| GMP                         : `if test "x$have_gmp" = xtrue; then echo yes; else echo no; fi` | ||||
| LAPACK                      : ${ac_LAPACK} | ||||
| FFTW                        : `if test "x$have_fftw" = xtrue; then echo yes; else echo no; fi` | ||||
| LIME (ILDG support)         : `if test "x$have_lime" = xtrue; then echo yes; else echo no; fi` | ||||
| HDF5                        : `if test "x$have_hdf5" = xtrue; then echo yes; else echo no; fi` | ||||
| build DOXYGEN documentation : `if test "$DX_FLAG_doc" = '1'; then echo yes; else echo no; fi` | ||||
| ----- BUILD FLAGS ------------------------------------- | ||||
| CXXFLAGS: | ||||
| `echo ${AM_CXXFLAGS} ${CXXFLAGS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| LDFLAGS: | ||||
| `echo ${AM_LDFLAGS} ${LDFLAGS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| LIBS: | ||||
| `echo ${LIBS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| -------------------------------------------------------" > grid.configure.summary | ||||
|  | ||||
| GRID_SUMMARY="`cat grid.configure.summary`" | ||||
| AM_SUBST_NOTMAKE([GRID_SUMMARY]) | ||||
| AC_SUBST([GRID_SUMMARY]) | ||||
|  | ||||
| AC_CONFIG_FILES([grid-config], [chmod +x grid-config]) | ||||
| AC_CONFIG_FILES(Makefile) | ||||
| AC_CONFIG_FILES(lib/Makefile) | ||||
| AC_CONFIG_FILES(tests/Makefile) | ||||
| @@ -322,41 +542,19 @@ AC_CONFIG_FILES(tests/IO/Makefile) | ||||
| AC_CONFIG_FILES(tests/core/Makefile) | ||||
| AC_CONFIG_FILES(tests/debug/Makefile) | ||||
| AC_CONFIG_FILES(tests/forces/Makefile) | ||||
| AC_CONFIG_FILES(tests/hadrons/Makefile) | ||||
| AC_CONFIG_FILES(tests/hmc/Makefile) | ||||
| AC_CONFIG_FILES(tests/solver/Makefile) | ||||
| AC_CONFIG_FILES(tests/lanczos/Makefile) | ||||
| AC_CONFIG_FILES(tests/smearing/Makefile) | ||||
| AC_CONFIG_FILES(tests/qdpxx/Makefile) | ||||
| AC_CONFIG_FILES(tests/testu01/Makefile) | ||||
| AC_CONFIG_FILES(benchmarks/Makefile) | ||||
| AC_CONFIG_FILES(extras/Makefile) | ||||
| AC_CONFIG_FILES(extras/Hadrons/Makefile) | ||||
| AC_OUTPUT | ||||
|  | ||||
| echo " | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
| Summary of configuration for $PACKAGE v$VERSION | ||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||
| echo "" | ||||
| cat grid.configure.summary | ||||
| echo "" | ||||
|  | ||||
| ----- PLATFORM ---------------------------------------- | ||||
| - architecture (build)          : $build_cpu | ||||
| - os (build)                    : $build_os | ||||
| - architecture (target)         : $target_cpu | ||||
| - os (target)                   : $target_os | ||||
| - compiler vendor               : ${ax_cv_cxx_compiler_vendor} | ||||
| - compiler version              : ${ax_cv_gxx_version} | ||||
| ----- BUILD OPTIONS ----------------------------------- | ||||
| - SIMD                          : ${ac_SIMD} | ||||
| - Threading                     : ${ac_openmp}  | ||||
| - Communications type           : ${ac_COMMS} | ||||
| - Default precision             : ${ac_PRECISION} | ||||
| - RNG choice                    : ${ac_RNG}  | ||||
| - GMP                           : `if test "x$have_gmp" = xtrue; then echo yes; else echo no; fi` | ||||
| - LAPACK                        : ${ac_LAPACK} | ||||
| - FFTW                          : `if test "x$have_fftw" = xtrue; then echo yes; else echo no; fi` | ||||
| - build DOXYGEN documentation   : `if test "x$enable_doc" = xyes; then echo yes; else echo no; fi` | ||||
| - graphs and diagrams           : `if test "x$enable_dot" = xyes; then echo yes; else echo no; fi` | ||||
| ----- BUILD FLAGS ------------------------------------- | ||||
| - CXXFLAGS: | ||||
| `echo ${AM_CXXFLAGS} ${CXXFLAGS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| - LDFLAGS: | ||||
| `echo ${AM_LDFLAGS} ${LDFLAGS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| - LIBS: | ||||
| `echo ${LIBS} | tr ' ' '\n' | sed 's/^-/    -/g'` | ||||
| ------------------------------------------------------- | ||||
| " | ||||
|   | ||||
							
								
								
									
										2305
									
								
								docs/doxy.cfg.in
									
									
									
									
									
								
							
							
						
						
									
										2305
									
								
								docs/doxy.cfg.in
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										184
									
								
								doxygen.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								doxygen.inc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,184 @@ | ||||
| # Copyright (C) 2004 Oren Ben-Kiki | ||||
| # This file is distributed under the same terms as the Automake macro files. | ||||
|  | ||||
| # Generate automatic documentation using Doxygen. Goals and variables values | ||||
| # are controlled by the various DX_COND_??? conditionals set by autoconf. | ||||
| # | ||||
| # The provided goals are: | ||||
| # doxygen-doc: Generate all doxygen documentation. | ||||
| # doxygen-run: Run doxygen, which will generate some of the documentation | ||||
| #              (HTML, CHM, CHI, MAN, RTF, XML) but will not do the post | ||||
| #              processing required for the rest of it (PS, PDF, and some MAN). | ||||
| # doxygen-man: Rename some doxygen generated man pages. | ||||
| # doxygen-ps: Generate doxygen PostScript documentation. | ||||
| # doxygen-pdf: Generate doxygen PDF documentation. | ||||
| # | ||||
| # Note that by default these are not integrated into the automake goals. If | ||||
| # doxygen is used to generate man pages, you can achieve this integration by | ||||
| # setting man3_MANS to the list of man pages generated and then adding the | ||||
| # dependency: | ||||
| # | ||||
| #   $(man3_MANS): doxygen-doc | ||||
| # | ||||
| # This will cause make to run doxygen and generate all the documentation. | ||||
| # | ||||
| # The following variable is intended for use in Makefile.am: | ||||
| # | ||||
| # DX_CLEANFILES = everything to clean. | ||||
| # | ||||
| # This is usually added to MOSTLYCLEANFILES. | ||||
|  | ||||
| ## --------------------------------- ## | ||||
| ## Format-independent Doxygen rules. ## | ||||
| ## --------------------------------- ## | ||||
|  | ||||
| if DX_COND_doc | ||||
|  | ||||
| ## ------------------------------- ## | ||||
| ## Rules specific for HTML output. ## | ||||
| ## ------------------------------- ## | ||||
|  | ||||
| if DX_COND_html | ||||
|  | ||||
| DX_CLEAN_HTML = @DX_DOCDIR@/html | ||||
|  | ||||
| endif DX_COND_html | ||||
|  | ||||
| ## ------------------------------ ## | ||||
| ## Rules specific for CHM output. ## | ||||
| ## ------------------------------ ## | ||||
|  | ||||
| if DX_COND_chm | ||||
|  | ||||
| DX_CLEAN_CHM = @DX_DOCDIR@/chm | ||||
|  | ||||
| if DX_COND_chi | ||||
|  | ||||
| DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi | ||||
|  | ||||
| endif DX_COND_chi | ||||
|  | ||||
| endif DX_COND_chm | ||||
|  | ||||
| ## ------------------------------ ## | ||||
| ## Rules specific for MAN output. ## | ||||
| ## ------------------------------ ## | ||||
|  | ||||
| if DX_COND_man | ||||
|  | ||||
| DX_CLEAN_MAN = @DX_DOCDIR@/man | ||||
|  | ||||
| endif DX_COND_man | ||||
|  | ||||
| ## ------------------------------ ## | ||||
| ## Rules specific for RTF output. ## | ||||
| ## ------------------------------ ## | ||||
|  | ||||
| if DX_COND_rtf | ||||
|  | ||||
| DX_CLEAN_RTF = @DX_DOCDIR@/rtf | ||||
|  | ||||
| endif DX_COND_rtf | ||||
|  | ||||
| ## ------------------------------ ## | ||||
| ## Rules specific for XML output. ## | ||||
| ## ------------------------------ ## | ||||
|  | ||||
| if DX_COND_xml | ||||
|  | ||||
| DX_CLEAN_XML = @DX_DOCDIR@/xml | ||||
|  | ||||
| endif DX_COND_xml | ||||
|  | ||||
| ## ----------------------------- ## | ||||
| ## Rules specific for PS output. ## | ||||
| ## ----------------------------- ## | ||||
|  | ||||
| if DX_COND_ps | ||||
|  | ||||
| DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps | ||||
|  | ||||
| DX_PS_GOAL = doxygen-ps | ||||
|  | ||||
| doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps | ||||
|  | ||||
| @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag | ||||
| 	cd @DX_DOCDIR@/latex; \ | ||||
| 	rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ | ||||
| 	$(DX_LATEX) refman.tex; \ | ||||
| 	$(MAKEINDEX_PATH) refman.idx; \ | ||||
| 	$(DX_LATEX) refman.tex; \ | ||||
| 	countdown=5; \ | ||||
| 	while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ | ||||
| 	                  refman.log > /dev/null 2>&1 \ | ||||
| 	   && test $$countdown -gt 0; do \ | ||||
| 	    $(DX_LATEX) refman.tex; \ | ||||
| 	    countdown=`expr $$countdown - 1`; \ | ||||
| 	done; \ | ||||
| 	$(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi | ||||
|  | ||||
| endif DX_COND_ps | ||||
|  | ||||
| ## ------------------------------ ## | ||||
| ## Rules specific for PDF output. ## | ||||
| ## ------------------------------ ## | ||||
|  | ||||
| if DX_COND_pdf | ||||
|  | ||||
| DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf | ||||
|  | ||||
| DX_PDF_GOAL = doxygen-pdf | ||||
|  | ||||
| doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf | ||||
|  | ||||
| @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag | ||||
| 	cd @DX_DOCDIR@/latex; \ | ||||
| 	rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ | ||||
| 	$(DX_PDFLATEX) refman.tex; \ | ||||
| 	$(DX_MAKEINDEX) refman.idx; \ | ||||
| 	$(DX_PDFLATEX) refman.tex; \ | ||||
| 	countdown=5; \ | ||||
| 	while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ | ||||
| 	                  refman.log > /dev/null 2>&1 \ | ||||
| 	   && test $$countdown -gt 0; do \ | ||||
| 	    $(DX_PDFLATEX) refman.tex; \ | ||||
| 	    countdown=`expr $$countdown - 1`; \ | ||||
| 	done; \ | ||||
| 	mv refman.pdf ../@PACKAGE@.pdf | ||||
|  | ||||
| endif DX_COND_pdf | ||||
|  | ||||
| ## ------------------------------------------------- ## | ||||
| ## Rules specific for LaTeX (shared for PS and PDF). ## | ||||
| ## ------------------------------------------------- ## | ||||
|  | ||||
| if DX_COND_latex | ||||
|  | ||||
| DX_CLEAN_LATEX = @DX_DOCDIR@/latex | ||||
|  | ||||
| endif DX_COND_latex | ||||
|  | ||||
| .INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) | ||||
|  | ||||
| doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag | ||||
|  | ||||
| doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL) | ||||
|  | ||||
| @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) | ||||
| 	rm -rf @DX_DOCDIR@ | ||||
| 	$(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) | ||||
|  | ||||
| DX_CLEANFILES = \ | ||||
|     @DX_DOCDIR@/@PACKAGE@.tag \ | ||||
|     -r \ | ||||
|     $(DX_CLEAN_HTML) \ | ||||
|     $(DX_CLEAN_CHM) \ | ||||
|     $(DX_CLEAN_CHI) \ | ||||
|     $(DX_CLEAN_MAN) \ | ||||
|     $(DX_CLEAN_RTF) \ | ||||
|     $(DX_CLEAN_XML) \ | ||||
|     $(DX_CLEAN_PS) \ | ||||
|     $(DX_CLEAN_PDF) \ | ||||
|     $(DX_CLEAN_LATEX) | ||||
|  | ||||
| endif DX_COND_doc | ||||
							
								
								
									
										229
									
								
								extras/Hadrons/Application.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								extras/Hadrons/Application.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,229 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Application.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Application.hpp> | ||||
| #include <Grid/Hadrons/GeneticScheduler.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| #define BIG_SEP "===============" | ||||
| #define SEP     "---------------" | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Application implementation                           * | ||||
|  ******************************************************************************/ | ||||
| // constructors //////////////////////////////////////////////////////////////// | ||||
| Application::Application(void) | ||||
| { | ||||
|     initLogger(); | ||||
|     auto dim = GridDefaultLatt(), mpi = GridDefaultMpi(), loc(dim); | ||||
|     locVol_ = 1; | ||||
|     for (unsigned int d = 0; d < dim.size(); ++d) | ||||
|     { | ||||
|         loc[d]  /= mpi[d]; | ||||
|         locVol_ *= loc[d]; | ||||
|     } | ||||
|     LOG(Message) << "Global lattice: " << dim << std::endl; | ||||
|     LOG(Message) << "MPI partition : " << mpi << std::endl; | ||||
|     LOG(Message) << "Local lattice : " << loc << std::endl; | ||||
| } | ||||
|  | ||||
| Application::Application(const Application::GlobalPar &par) | ||||
| : Application() | ||||
| { | ||||
|     setPar(par); | ||||
| } | ||||
|  | ||||
| Application::Application(const std::string parameterFileName) | ||||
| : Application() | ||||
| { | ||||
|     parameterFileName_ = parameterFileName; | ||||
| } | ||||
|  | ||||
| // access ////////////////////////////////////////////////////////////////////// | ||||
| void Application::setPar(const Application::GlobalPar &par) | ||||
| { | ||||
|     par_ = par; | ||||
|     env().setSeed(strToVec<int>(par_.seed)); | ||||
| } | ||||
|  | ||||
| const Application::GlobalPar & Application::getPar(void) | ||||
| { | ||||
|     return par_; | ||||
| } | ||||
|  | ||||
| // execute ///////////////////////////////////////////////////////////////////// | ||||
| void Application::run(void) | ||||
| { | ||||
|     if (!parameterFileName_.empty() and (vm().getNModule() == 0)) | ||||
|     { | ||||
|         parseParameterFile(parameterFileName_); | ||||
|     } | ||||
|     vm().printContent(); | ||||
|     env().printContent(); | ||||
|     schedule(); | ||||
|     printSchedule(); | ||||
|     configLoop(); | ||||
| } | ||||
|  | ||||
| // parse parameter file //////////////////////////////////////////////////////// | ||||
| class ObjectId: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(ObjectId, | ||||
|                                     std::string, name, | ||||
|                                     std::string, type); | ||||
| }; | ||||
|  | ||||
| void Application::parseParameterFile(const std::string parameterFileName) | ||||
| { | ||||
|     XmlReader reader(parameterFileName); | ||||
|     GlobalPar par; | ||||
|     ObjectId  id; | ||||
|      | ||||
|     LOG(Message) << "Building application from '" << parameterFileName << "'..." << std::endl; | ||||
|     read(reader, "parameters", par); | ||||
|     setPar(par); | ||||
|     if (!push(reader, "modules")) | ||||
|     { | ||||
|         HADRON_ERROR(Parsing, "Cannot open node 'modules' in parameter file '"  | ||||
|                               + parameterFileName + "'"); | ||||
|     } | ||||
|     if (!push(reader, "module")) | ||||
|     { | ||||
|         HADRON_ERROR(Parsing, "Cannot open node 'modules/module' in parameter file '"  | ||||
|                               + parameterFileName + "'"); | ||||
|     } | ||||
|     do | ||||
|     { | ||||
|         read(reader, "id", id); | ||||
|         vm().createModule(id.name, id.type, reader); | ||||
|     } while (reader.nextElement("module")); | ||||
|     pop(reader); | ||||
|     pop(reader); | ||||
| } | ||||
|  | ||||
| void Application::saveParameterFile(const std::string parameterFileName) | ||||
| { | ||||
|     XmlWriter          writer(parameterFileName); | ||||
|     ObjectId           id; | ||||
|     const unsigned int nMod = vm().getNModule(); | ||||
|      | ||||
|     LOG(Message) << "Saving application to '" << parameterFileName << "'..." << std::endl; | ||||
|     write(writer, "parameters", getPar()); | ||||
|     push(writer, "modules"); | ||||
|     for (unsigned int i = 0; i < nMod; ++i) | ||||
|     { | ||||
|         push(writer, "module"); | ||||
|         id.name = vm().getModuleName(i); | ||||
|         id.type = vm().getModule(i)->getRegisteredName(); | ||||
|         write(writer, "id", id); | ||||
|         vm().getModule(i)->saveParameters(writer, "options"); | ||||
|         pop(writer); | ||||
|     } | ||||
|     pop(writer); | ||||
|     pop(writer); | ||||
| } | ||||
|  | ||||
| // schedule computation //////////////////////////////////////////////////////// | ||||
| void Application::schedule(void) | ||||
| { | ||||
|     if (!scheduled_ and !loadedSchedule_) | ||||
|     { | ||||
|         program_   = vm().schedule(par_.genetic); | ||||
|         scheduled_ = true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Application::saveSchedule(const std::string filename) | ||||
| { | ||||
|     TextWriter               writer(filename); | ||||
|     std::vector<std::string> program; | ||||
|      | ||||
|     if (!scheduled_) | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "Computation not scheduled"); | ||||
|     } | ||||
|     LOG(Message) << "Saving current schedule to '" << filename << "'..." | ||||
|                  << std::endl; | ||||
|     for (auto address: program_) | ||||
|     { | ||||
|         program.push_back(vm().getModuleName(address)); | ||||
|     } | ||||
|     write(writer, "schedule", program); | ||||
| } | ||||
|  | ||||
| void Application::loadSchedule(const std::string filename) | ||||
| { | ||||
|     TextReader               reader(filename); | ||||
|     std::vector<std::string> program; | ||||
|      | ||||
|     LOG(Message) << "Loading schedule from '" << filename << "'..." | ||||
|                  << std::endl; | ||||
|     read(reader, "schedule", program); | ||||
|     program_.clear(); | ||||
|     for (auto &name: program) | ||||
|     { | ||||
|         program_.push_back(vm().getModuleAddress(name)); | ||||
|     } | ||||
|     loadedSchedule_ = true; | ||||
| } | ||||
|  | ||||
| void Application::printSchedule(void) | ||||
| { | ||||
|     if (!scheduled_) | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "Computation not scheduled"); | ||||
|     } | ||||
|     auto peak = vm().memoryNeeded(program_); | ||||
|     LOG(Message) << "Schedule (memory needed: " << sizeString(peak) << "):" | ||||
|                  << std::endl; | ||||
|     for (unsigned int i = 0; i < program_.size(); ++i) | ||||
|     { | ||||
|         LOG(Message) << std::setw(4) << i + 1 << ": " | ||||
|                      << vm().getModuleName(program_[i]) << std::endl; | ||||
|     } | ||||
| } | ||||
|  | ||||
| // loop on configurations ////////////////////////////////////////////////////// | ||||
| void Application::configLoop(void) | ||||
| { | ||||
|     auto range = par_.trajCounter; | ||||
|      | ||||
|     for (unsigned int t = range.start; t < range.end; t += range.step) | ||||
|     { | ||||
|         LOG(Message) << BIG_SEP << " Starting measurement for trajectory " << t | ||||
|                      << " " << BIG_SEP << std::endl; | ||||
|         vm().setTrajectory(t); | ||||
|         vm().executeProgram(program_); | ||||
|     } | ||||
|     LOG(Message) << BIG_SEP << " End of measurement " << BIG_SEP << std::endl; | ||||
|     env().freeAll(); | ||||
| } | ||||
							
								
								
									
										121
									
								
								extras/Hadrons/Application.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								extras/Hadrons/Application.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,121 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Application.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Application_hpp_ | ||||
| #define Hadrons_Application_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/VirtualMachine.hpp> | ||||
| #include <Grid/Hadrons/Modules.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Main program manager                               * | ||||
|  ******************************************************************************/ | ||||
| class Application | ||||
| { | ||||
| public: | ||||
|     class TrajRange: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(TrajRange, | ||||
|                                         unsigned int, start, | ||||
|                                         unsigned int, end, | ||||
|                                         unsigned int, step); | ||||
|     }; | ||||
|     class GlobalPar: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(GlobalPar, | ||||
|                                         TrajRange,                  trajCounter, | ||||
|                                         VirtualMachine::GeneticPar, genetic, | ||||
|                                         std::string,                seed); | ||||
|     }; | ||||
| public: | ||||
|     // constructors | ||||
|     Application(void); | ||||
|     Application(const GlobalPar &par); | ||||
|     Application(const std::string parameterFileName); | ||||
|     // destructor | ||||
|     virtual ~Application(void) = default; | ||||
|     // access | ||||
|     void              setPar(const GlobalPar &par); | ||||
|     const GlobalPar & getPar(void); | ||||
|     // module creation | ||||
|     template <typename M> | ||||
|     void createModule(const std::string name); | ||||
|     template <typename M> | ||||
|     void createModule(const std::string name, const typename M::Par &par); | ||||
|     // execute | ||||
|     void run(void); | ||||
|     // XML parameter file I/O | ||||
|     void parseParameterFile(const std::string parameterFileName); | ||||
|     void saveParameterFile(const std::string parameterFileName); | ||||
|     // schedule computation | ||||
|     void schedule(void); | ||||
|     void saveSchedule(const std::string filename); | ||||
|     void loadSchedule(const std::string filename); | ||||
|     void printSchedule(void); | ||||
|     // loop on configurations | ||||
|     void configLoop(void); | ||||
| private: | ||||
|     // environment shortcut | ||||
|     DEFINE_ENV_ALIAS; | ||||
|     // virtual machine shortcut | ||||
|     DEFINE_VM_ALIAS; | ||||
| private: | ||||
|     long unsigned int       locVol_; | ||||
|     std::string             parameterFileName_{""}; | ||||
|     GlobalPar               par_; | ||||
|     VirtualMachine::Program program_; | ||||
|     bool                    scheduled_{false}, loadedSchedule_{false}; | ||||
| }; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     Application template implementation                    * | ||||
|  ******************************************************************************/ | ||||
| // module creation ///////////////////////////////////////////////////////////// | ||||
| template <typename M> | ||||
| void Application::createModule(const std::string name) | ||||
| { | ||||
|     vm().createModule<M>(name); | ||||
|     scheduled_ = false; | ||||
| } | ||||
|  | ||||
| template <typename M> | ||||
| void Application::createModule(const std::string name, | ||||
|                                const typename M::Par &par) | ||||
| { | ||||
|     vm().createModule<M>(name, par); | ||||
|     scheduled_ = false; | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Application_hpp_ | ||||
							
								
								
									
										391
									
								
								extras/Hadrons/Environment.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										391
									
								
								extras/Hadrons/Environment.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,391 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Environment.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Environment.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| #define ERROR_NO_ADDRESS(address)\ | ||||
| HADRON_ERROR(Definition, "no object with address " + std::to_string(address)); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Environment implementation                           * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| Environment::Environment(void) | ||||
| { | ||||
|     dim_ = GridDefaultLatt(); | ||||
|     nd_  = dim_.size(); | ||||
|     grid4d_.reset(SpaceTimeGrid::makeFourDimGrid( | ||||
|         dim_, GridDefaultSimd(nd_, vComplex::Nsimd()), | ||||
|         GridDefaultMpi())); | ||||
|     gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get())); | ||||
|     auto loc = getGrid()->LocalDimensions(); | ||||
|     locVol_ = 1; | ||||
|     for (unsigned int d = 0; d < loc.size(); ++d) | ||||
|     { | ||||
|         locVol_ *= loc[d]; | ||||
|     } | ||||
|     rng4d_.reset(new GridParallelRNG(grid4d_.get())); | ||||
| } | ||||
|  | ||||
| // grids /////////////////////////////////////////////////////////////////////// | ||||
| void Environment::createGrid(const unsigned int Ls) | ||||
| { | ||||
|     if (grid5d_.find(Ls) == grid5d_.end()) | ||||
|     { | ||||
|         auto g = getGrid(); | ||||
|          | ||||
|         grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, g)); | ||||
|         gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, g)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| GridCartesian * Environment::getGrid(const unsigned int Ls) const | ||||
| { | ||||
|     try | ||||
|     { | ||||
|         if (Ls == 1) | ||||
|         { | ||||
|             return grid4d_.get(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return grid5d_.at(Ls).get(); | ||||
|         } | ||||
|     } | ||||
|     catch(std::out_of_range &) | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "no grid with Ls= " + std::to_string(Ls)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| GridRedBlackCartesian * Environment::getRbGrid(const unsigned int Ls) const | ||||
| { | ||||
|     try | ||||
|     { | ||||
|         if (Ls == 1) | ||||
|         { | ||||
|             return gridRb4d_.get(); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return gridRb5d_.at(Ls).get(); | ||||
|         } | ||||
|     } | ||||
|     catch(std::out_of_range &) | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "no red-black 5D grid with Ls= " + std::to_string(Ls)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| unsigned int Environment::getNd(void) const | ||||
| { | ||||
|     return nd_; | ||||
| } | ||||
|  | ||||
| std::vector<int> Environment::getDim(void) const | ||||
| { | ||||
|     return dim_; | ||||
| } | ||||
|  | ||||
| int Environment::getDim(const unsigned int mu) const | ||||
| { | ||||
|     return dim_[mu]; | ||||
| } | ||||
|  | ||||
| unsigned long int Environment::getLocalVolume(void) const | ||||
| { | ||||
|     return locVol_; | ||||
| } | ||||
|  | ||||
| // random number generator ///////////////////////////////////////////////////// | ||||
| void Environment::setSeed(const std::vector<int> &seed) | ||||
| { | ||||
|     rng4d_->SeedFixedIntegers(seed); | ||||
| } | ||||
|  | ||||
| GridParallelRNG * Environment::get4dRng(void) const | ||||
| { | ||||
|     return rng4d_.get(); | ||||
| } | ||||
|  | ||||
| // general memory management /////////////////////////////////////////////////// | ||||
| void Environment::addObject(const std::string name, const int moduleAddress) | ||||
| { | ||||
|     if (!hasObject(name)) | ||||
|     { | ||||
|         ObjInfo info; | ||||
|          | ||||
|         info.name   = name; | ||||
|         info.module = moduleAddress; | ||||
|         info.data   = nullptr; | ||||
|         object_.push_back(std::move(info)); | ||||
|         objectAddress_[name] = static_cast<unsigned int>(object_.size() - 1); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "object '" + name + "' already exists"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Environment::setObjectModule(const unsigned int objAddress, | ||||
|                                   const int modAddress) | ||||
| { | ||||
|     object_[objAddress].module = modAddress; | ||||
| } | ||||
|  | ||||
| unsigned int Environment::getMaxAddress(void) const | ||||
| { | ||||
|     return object_.size(); | ||||
| } | ||||
|  | ||||
| unsigned int Environment::getObjectAddress(const std::string name) const | ||||
| { | ||||
|     if (hasObject(name)) | ||||
|     { | ||||
|         return objectAddress_.at(name); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "no object with name '" + name + "'"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| std::string Environment::getObjectName(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return object_[address].name; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| std::string Environment::getObjectType(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         if (object_[address].type) | ||||
|         { | ||||
|             return typeName(object_[address].type); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return "<no type>"; | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| std::string Environment::getObjectType(const std::string name) const | ||||
| { | ||||
|     return getObjectType(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| Environment::Size Environment::getObjectSize(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return object_[address].size; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| Environment::Size Environment::getObjectSize(const std::string name) const | ||||
| { | ||||
|     return getObjectSize(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| Environment::Storage Environment::getObjectStorage(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return object_[address].storage; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| Environment::Storage Environment::getObjectStorage(const std::string name) const | ||||
| { | ||||
|     return getObjectStorage(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| int Environment::getObjectModule(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return object_[address].module; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| int Environment::getObjectModule(const std::string name) const | ||||
| { | ||||
|     return getObjectModule(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| unsigned int Environment::getObjectLs(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return object_[address].Ls; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         ERROR_NO_ADDRESS(address); | ||||
|     } | ||||
| } | ||||
|  | ||||
| unsigned int Environment::getObjectLs(const std::string name) const | ||||
| { | ||||
|     return getObjectLs(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| bool Environment::hasObject(const unsigned int address) const | ||||
| { | ||||
|     return (address < object_.size()); | ||||
| } | ||||
|  | ||||
| bool Environment::hasObject(const std::string name) const | ||||
| { | ||||
|     auto it = objectAddress_.find(name); | ||||
|      | ||||
|     return ((it != objectAddress_.end()) and hasObject(it->second)); | ||||
| } | ||||
|  | ||||
| bool Environment::hasCreatedObject(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         return (object_[address].data != nullptr); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| bool Environment::hasCreatedObject(const std::string name) const | ||||
| { | ||||
|     if (hasObject(name)) | ||||
|     { | ||||
|         return hasCreatedObject(getObjectAddress(name)); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| bool Environment::isObject5d(const unsigned int address) const | ||||
| { | ||||
|     return (getObjectLs(address) > 1); | ||||
| } | ||||
|  | ||||
| bool Environment::isObject5d(const std::string name) const | ||||
| { | ||||
|     return (getObjectLs(name) > 1); | ||||
| } | ||||
|  | ||||
| Environment::Size Environment::getTotalSize(void) const | ||||
| { | ||||
|     Environment::Size size = 0; | ||||
|      | ||||
|     for (auto &o: object_) | ||||
|     { | ||||
|         size += o.size; | ||||
|     } | ||||
|      | ||||
|     return size; | ||||
| } | ||||
|  | ||||
| void Environment::freeObject(const unsigned int address) | ||||
| { | ||||
|     if (hasCreatedObject(address)) | ||||
|     { | ||||
|         LOG(Message) << "Destroying object '" << object_[address].name | ||||
|                      << "'" << std::endl; | ||||
|     } | ||||
|     object_[address].size = 0; | ||||
|     object_[address].type = nullptr; | ||||
|     object_[address].data.reset(nullptr); | ||||
| } | ||||
|  | ||||
| void Environment::freeObject(const std::string name) | ||||
| { | ||||
|     freeObject(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| void Environment::freeAll(void) | ||||
| { | ||||
|     for (unsigned int i = 0; i < object_.size(); ++i) | ||||
|     { | ||||
|         freeObject(i); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void Environment::protectObjects(const bool protect) | ||||
| { | ||||
|     protect_ = protect; | ||||
| } | ||||
|  | ||||
| bool Environment::objectsProtected(void) const | ||||
| { | ||||
|     return protect_; | ||||
| } | ||||
|  | ||||
| // print environment content /////////////////////////////////////////////////// | ||||
| void Environment::printContent(void) const | ||||
| { | ||||
|     LOG(Debug) << "Objects: " << std::endl; | ||||
|     for (unsigned int i = 0; i < object_.size(); ++i) | ||||
|     { | ||||
|         LOG(Debug) << std::setw(4) << i << ": " | ||||
|                    << getObjectName(i) << " (" | ||||
|                    << sizeString(getObjectSize(i)) << ")" << std::endl; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										313
									
								
								extras/Hadrons/Environment.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										313
									
								
								extras/Hadrons/Environment.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,313 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Environment.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Environment_hpp_ | ||||
| #define Hadrons_Environment_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Global environment                                 * | ||||
|  ******************************************************************************/ | ||||
| class Object | ||||
| { | ||||
| public: | ||||
|     Object(void) = default; | ||||
|     virtual ~Object(void) = default; | ||||
| }; | ||||
|  | ||||
| template <typename T> | ||||
| class Holder: public Object | ||||
| { | ||||
| public: | ||||
|     Holder(void) = default; | ||||
|     Holder(T *pt); | ||||
|     virtual ~Holder(void) = default; | ||||
|     T &       get(void) const; | ||||
|     T *       getPt(void) const; | ||||
|     void      reset(T *pt); | ||||
| private: | ||||
|     std::unique_ptr<T> objPt_{nullptr}; | ||||
| }; | ||||
|  | ||||
| #define DEFINE_ENV_ALIAS \ | ||||
| inline Environment & env(void) const\ | ||||
| {\ | ||||
|     return Environment::getInstance();\ | ||||
| } | ||||
|  | ||||
| class Environment | ||||
| { | ||||
|     SINGLETON(Environment); | ||||
| public: | ||||
|     typedef SITE_SIZE_TYPE                         Size; | ||||
|     typedef std::unique_ptr<GridCartesian>         GridPt; | ||||
|     typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt; | ||||
|     typedef std::unique_ptr<GridParallelRNG>       RngPt; | ||||
|     enum class Storage {object, cache, temporary}; | ||||
| private: | ||||
|     struct ObjInfo | ||||
|     { | ||||
|         Size                    size{0}; | ||||
|         Storage                 storage{Storage::object}; | ||||
|         unsigned int            Ls{0}; | ||||
|         const std::type_info    *type{nullptr}; | ||||
|         std::string             name; | ||||
|         int                     module{-1}; | ||||
|         std::unique_ptr<Object> data{nullptr}; | ||||
|     }; | ||||
| public: | ||||
|     // grids | ||||
|     void                    createGrid(const unsigned int Ls); | ||||
|     GridCartesian *         getGrid(const unsigned int Ls = 1) const; | ||||
|     GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const; | ||||
|     std::vector<int>        getDim(void) const; | ||||
|     int                     getDim(const unsigned int mu) const; | ||||
|     unsigned long int       getLocalVolume(void) const; | ||||
|     unsigned int            getNd(void) const; | ||||
|     // random number generator | ||||
|     void                    setSeed(const std::vector<int> &seed); | ||||
|     GridParallelRNG *       get4dRng(void) const; | ||||
|     // general memory management | ||||
|     void                    addObject(const std::string name, | ||||
|                                       const int moduleAddress = -1); | ||||
|     template <typename B, typename T, typename ... Ts> | ||||
|     void                    createDerivedObject(const std::string name, | ||||
|                                                 const Environment::Storage storage, | ||||
|                                                 const unsigned int Ls, | ||||
|                                                 Ts && ... args); | ||||
|     template <typename T, typename ... Ts> | ||||
|     void                    createObject(const std::string name, | ||||
|                                          const Environment::Storage storage, | ||||
|                                          const unsigned int Ls, | ||||
|                                          Ts && ... args); | ||||
|     void                    setObjectModule(const unsigned int objAddress, | ||||
|                                             const int modAddress); | ||||
|     template <typename T> | ||||
|     T *                     getObject(const unsigned int address) const; | ||||
|     template <typename T> | ||||
|     T *                     getObject(const std::string name) const; | ||||
|     unsigned int            getMaxAddress(void) const; | ||||
|     unsigned int            getObjectAddress(const std::string name) const; | ||||
|     std::string             getObjectName(const unsigned int address) const; | ||||
|     std::string             getObjectType(const unsigned int address) const; | ||||
|     std::string             getObjectType(const std::string name) const; | ||||
|     Size                    getObjectSize(const unsigned int address) const; | ||||
|     Size                    getObjectSize(const std::string name) const; | ||||
|     Storage                 getObjectStorage(const unsigned int address) const; | ||||
|     Storage                 getObjectStorage(const std::string name) const; | ||||
|     int                     getObjectModule(const unsigned int address) const; | ||||
|     int                     getObjectModule(const std::string name) const; | ||||
|     unsigned int            getObjectLs(const unsigned int address) const; | ||||
|     unsigned int            getObjectLs(const std::string name) const; | ||||
|     bool                    hasObject(const unsigned int address) const; | ||||
|     bool                    hasObject(const std::string name) const; | ||||
|     bool                    hasCreatedObject(const unsigned int address) const; | ||||
|     bool                    hasCreatedObject(const std::string name) const; | ||||
|     bool                    isObject5d(const unsigned int address) const; | ||||
|     bool                    isObject5d(const std::string name) const; | ||||
|     template <typename T> | ||||
|     bool                    isObjectOfType(const unsigned int address) const; | ||||
|     template <typename T> | ||||
|     bool                    isObjectOfType(const std::string name) const; | ||||
|     Environment::Size       getTotalSize(void) const; | ||||
|     void                    freeObject(const unsigned int address); | ||||
|     void                    freeObject(const std::string name); | ||||
|     void                    freeAll(void); | ||||
|     void                    protectObjects(const bool protect); | ||||
|     bool                    objectsProtected(void) const; | ||||
|     // print environment content | ||||
|     void                    printContent(void) const; | ||||
| private: | ||||
|     // general | ||||
|     unsigned long int                      locVol_; | ||||
|     bool                                   protect_{true}; | ||||
|     // grids | ||||
|     std::vector<int>                       dim_; | ||||
|     GridPt                                 grid4d_; | ||||
|     std::map<unsigned int, GridPt>         grid5d_; | ||||
|     GridRbPt                               gridRb4d_; | ||||
|     std::map<unsigned int, GridRbPt>       gridRb5d_; | ||||
|     unsigned int                           nd_; | ||||
|     // random number generator | ||||
|     RngPt                                  rng4d_; | ||||
|     // object store | ||||
|     std::vector<ObjInfo>                   object_; | ||||
|     std::map<std::string, unsigned int>    objectAddress_; | ||||
| }; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Holder template implementation                       * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| Holder<T>::Holder(T *pt) | ||||
| : objPt_(pt) | ||||
| {} | ||||
|  | ||||
| // access ////////////////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| T & Holder<T>::get(void) const | ||||
| { | ||||
|     return &objPt_.get(); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| T * Holder<T>::getPt(void) const | ||||
| { | ||||
|     return objPt_.get(); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| void Holder<T>::reset(T *pt) | ||||
| { | ||||
|     objPt_.reset(pt); | ||||
| } | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     Environment template implementation                    * | ||||
|  ******************************************************************************/ | ||||
| // general memory management /////////////////////////////////////////////////// | ||||
| template <typename B, typename T, typename ... Ts> | ||||
| void Environment::createDerivedObject(const std::string name, | ||||
|                                       const Environment::Storage storage, | ||||
|                                       const unsigned int Ls, | ||||
|                                       Ts && ... args) | ||||
| { | ||||
|     if (!hasObject(name)) | ||||
|     { | ||||
|         addObject(name); | ||||
|     } | ||||
|      | ||||
|     unsigned int address = getObjectAddress(name); | ||||
|      | ||||
|     if (!object_[address].data or !objectsProtected()) | ||||
|     { | ||||
|         MemoryStats memStats; | ||||
|      | ||||
|         if (!MemoryProfiler::stats) | ||||
|         { | ||||
|             MemoryProfiler::stats = &memStats; | ||||
|         } | ||||
|         size_t initMem           = MemoryProfiler::stats->currentlyAllocated; | ||||
|         object_[address].storage = storage; | ||||
|         object_[address].Ls      = Ls; | ||||
|         object_[address].data.reset(new Holder<B>(new T(std::forward<Ts>(args)...))); | ||||
|         object_[address].size    = MemoryProfiler::stats->maxAllocated - initMem; | ||||
|         object_[address].type    = &typeid(T); | ||||
|         if (MemoryProfiler::stats == &memStats) | ||||
|         { | ||||
|             MemoryProfiler::stats = nullptr; | ||||
|         } | ||||
|     } | ||||
|     // object already exists, no error if it is a cache, error otherwise | ||||
|     else if ((object_[address].storage != Storage::cache) or  | ||||
|              (object_[address].storage != storage)        or | ||||
|              (object_[address].name    != name)           or | ||||
|              (object_[address].type    != &typeid(T))) | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "object '" + name + "' already allocated"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename T, typename ... Ts> | ||||
| void Environment::createObject(const std::string name,  | ||||
|                                const Environment::Storage storage, | ||||
|                                const unsigned int Ls, | ||||
|                                Ts && ... args) | ||||
| { | ||||
|     createDerivedObject<T, T>(name, storage, Ls, std::forward<Ts>(args)...); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| T * Environment::getObject(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         if (hasCreatedObject(address)) | ||||
|         { | ||||
|             if (auto h = dynamic_cast<Holder<T> *>(object_[address].data.get())) | ||||
|             { | ||||
|                 return h->getPt(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 HADRON_ERROR(Definition, "object with address " + std::to_string(address) + | ||||
|                             " does not have type '" + typeName(&typeid(T)) + | ||||
|                             "' (has type '" + getObjectType(address) + "')"); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             HADRON_ERROR(Definition, "object with address " + std::to_string(address) + | ||||
|                          " is empty"); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "no object with address " + std::to_string(address)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| T * Environment::getObject(const std::string name) const | ||||
| { | ||||
|     return getObject<T>(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| bool Environment::isObjectOfType(const unsigned int address) const | ||||
| { | ||||
|     if (hasObject(address)) | ||||
|     { | ||||
|         if (auto h = dynamic_cast<Holder<T> *>(object_[address].data.get())) | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Definition, "no object with address " + std::to_string(address)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| bool Environment::isObjectOfType(const std::string name) const | ||||
| { | ||||
|     return isObjectOfType<T>(getObjectAddress(name)); | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Environment_hpp_ | ||||
							
								
								
									
										57
									
								
								extras/Hadrons/Exceptions.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								extras/Hadrons/Exceptions.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Exceptions.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Exceptions.hpp> | ||||
|  | ||||
| #ifndef ERR_SUFF | ||||
| #define ERR_SUFF " (" + loc + ")" | ||||
| #endif | ||||
|  | ||||
| #define CONST_EXC(name, init) \ | ||||
| name::name(std::string msg, std::string loc)\ | ||||
| :init\ | ||||
| {} | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace Exceptions; | ||||
|  | ||||
| // logic errors | ||||
| CONST_EXC(Logic, logic_error(msg + ERR_SUFF)) | ||||
| CONST_EXC(Definition, Logic("definition error: " + msg, loc)) | ||||
| CONST_EXC(Implementation, Logic("implementation error: " + msg, loc)) | ||||
| CONST_EXC(Range, Logic("range error: " + msg, loc)) | ||||
| CONST_EXC(Size, Logic("size error: " + msg, loc)) | ||||
| // runtime errors | ||||
| CONST_EXC(Runtime, runtime_error(msg + ERR_SUFF)) | ||||
| CONST_EXC(Argument, Runtime("argument error: " + msg, loc)) | ||||
| CONST_EXC(Io, Runtime("IO error: " + msg, loc)) | ||||
| CONST_EXC(Memory, Runtime("memory error: " + msg, loc)) | ||||
| CONST_EXC(Parsing, Runtime("parsing error: " + msg, loc)) | ||||
| CONST_EXC(Program, Runtime("program error: " + msg, loc)) | ||||
| CONST_EXC(System, Runtime("system error: " + msg, loc)) | ||||
							
								
								
									
										72
									
								
								extras/Hadrons/Exceptions.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								extras/Hadrons/Exceptions.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Exceptions.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Exceptions_hpp_ | ||||
| #define Hadrons_Exceptions_hpp_ | ||||
|  | ||||
| #include <stdexcept> | ||||
| #ifndef Hadrons_Global_hpp_ | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #endif | ||||
|  | ||||
| #define SRC_LOC std::string(__FUNCTION__) + " at " + std::string(__FILE__) + ":"\ | ||||
|                 + std::to_string(__LINE__) | ||||
| #define HADRON_ERROR(exc, msg)\ | ||||
| LOG(Error) << msg << std::endl;\ | ||||
| throw(Exceptions::exc(msg, SRC_LOC)); | ||||
|  | ||||
| #define DECL_EXC(name, base) \ | ||||
| class name: public base\ | ||||
| {\ | ||||
| public:\ | ||||
|     name(std::string msg, std::string loc);\ | ||||
| } | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| namespace Exceptions | ||||
| { | ||||
|     // logic errors | ||||
|     DECL_EXC(Logic, std::logic_error); | ||||
|     DECL_EXC(Definition, Logic); | ||||
|     DECL_EXC(Implementation, Logic); | ||||
|     DECL_EXC(Range, Logic); | ||||
|     DECL_EXC(Size, Logic); | ||||
|     // runtime errors | ||||
|     DECL_EXC(Runtime, std::runtime_error); | ||||
|     DECL_EXC(Argument, Runtime); | ||||
|     DECL_EXC(Io, Runtime); | ||||
|     DECL_EXC(Memory, Runtime); | ||||
|     DECL_EXC(Parsing, Runtime); | ||||
|     DECL_EXC(Program, Runtime); | ||||
|     DECL_EXC(System, Runtime); | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Exceptions_hpp_ | ||||
							
								
								
									
										105
									
								
								extras/Hadrons/Factory.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								extras/Hadrons/Factory.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Factory.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Factory_hpp_ | ||||
| #define Hadrons_Factory_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                        abstract factory class                              * | ||||
|  ******************************************************************************/ | ||||
| template <typename T> | ||||
| class Factory | ||||
| { | ||||
| public: | ||||
|     typedef std::function<std::unique_ptr<T>(const std::string)> Func; | ||||
| public: | ||||
|     // constructor | ||||
|     Factory(void) = default; | ||||
|     // destructor | ||||
|     virtual ~Factory(void) = default; | ||||
|     // registration | ||||
|     void registerBuilder(const std::string type, const Func &f); | ||||
|     // get builder list | ||||
|     std::vector<std::string> getBuilderList(void) const; | ||||
|     // factory | ||||
|     std::unique_ptr<T> create(const std::string type, | ||||
|                               const std::string name) const; | ||||
| private: | ||||
|     std::map<std::string, Func> builder_; | ||||
| }; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         template implementation                            * | ||||
|  ******************************************************************************/ | ||||
| // registration //////////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| void Factory<T>::registerBuilder(const std::string type, const Func &f) | ||||
| { | ||||
|     builder_[type] = f; | ||||
| } | ||||
|  | ||||
| // get module list ///////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| std::vector<std::string> Factory<T>::getBuilderList(void) const | ||||
| { | ||||
|     std::vector<std::string> list; | ||||
|      | ||||
|     for (auto &b: builder_) | ||||
|     { | ||||
|         list.push_back(b.first); | ||||
|     } | ||||
|      | ||||
|     return list; | ||||
| } | ||||
|  | ||||
| // factory ///////////////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| std::unique_ptr<T> Factory<T>::create(const std::string type, | ||||
|                                       const std::string name) const | ||||
| { | ||||
|     Func func; | ||||
|      | ||||
|     try | ||||
|     { | ||||
|         func = builder_.at(type); | ||||
|     } | ||||
|     catch (std::out_of_range &) | ||||
|     { | ||||
|         HADRON_ERROR(Argument, "object of type '" + type + "' unknown"); | ||||
|     } | ||||
|      | ||||
|     return func(name); | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Factory_hpp_ | ||||
							
								
								
									
										323
									
								
								extras/Hadrons/GeneticScheduler.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										323
									
								
								extras/Hadrons/GeneticScheduler.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,323 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/GeneticScheduler.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_GeneticScheduler_hpp_ | ||||
| #define Hadrons_GeneticScheduler_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Graph.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                   Scheduler based on a genetic algorithm                   * | ||||
|  ******************************************************************************/ | ||||
| template <typename V, typename T> | ||||
| class GeneticScheduler | ||||
| { | ||||
| public: | ||||
|     typedef std::vector<T>                 Gene; | ||||
|     typedef std::pair<Gene *, Gene *>      GenePair; | ||||
|     typedef std::function<V(const Gene &)> ObjFunc; | ||||
|     struct Parameters | ||||
|     { | ||||
|         double       mutationRate; | ||||
|         unsigned int popSize, seed; | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     GeneticScheduler(Graph<T> &graph, const ObjFunc &func, | ||||
|                      const Parameters &par); | ||||
|     // destructor | ||||
|     virtual ~GeneticScheduler(void) = default; | ||||
|     // access | ||||
|     const Gene & getMinSchedule(void); | ||||
|     int          getMinValue(void); | ||||
|     // breed a new generation | ||||
|     void nextGeneration(void); | ||||
|     // heuristic benchmarks | ||||
|     void benchmarkCrossover(const unsigned int nIt); | ||||
|     // print population | ||||
|     friend std::ostream & operator<<(std::ostream &out, | ||||
|                                      const GeneticScheduler<V, T> &s) | ||||
|     { | ||||
|         out << "["; | ||||
|         for (auto &p: s.population_) | ||||
|         { | ||||
|             out << p.first << ", "; | ||||
|         } | ||||
|         out << "\b\b]"; | ||||
|          | ||||
|         return out; | ||||
|     } | ||||
| private: | ||||
|     // evolution steps | ||||
|     void initPopulation(void); | ||||
|     void doCrossover(void); | ||||
|     void doMutation(void); | ||||
|     // genetic operators | ||||
|     GenePair selectPair(void); | ||||
|     void     crossover(Gene &c1, Gene &c2, const Gene &p1, const Gene &p2); | ||||
|     void     mutation(Gene &m, const Gene &c); | ||||
|      | ||||
| private: | ||||
|     Graph<T>               &graph_; | ||||
|     const ObjFunc          &func_; | ||||
|     const Parameters       par_; | ||||
|     std::multimap<V, Gene> population_; | ||||
|     std::mt19937           gen_; | ||||
| }; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       template implementation                              * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename V, typename T> | ||||
| GeneticScheduler<V, T>::GeneticScheduler(Graph<T> &graph, const ObjFunc &func, | ||||
|                                       const Parameters &par) | ||||
| : graph_(graph) | ||||
| , func_(func) | ||||
| , par_(par) | ||||
| { | ||||
|     gen_.seed(par_.seed); | ||||
| } | ||||
|  | ||||
| // access ////////////////////////////////////////////////////////////////////// | ||||
| template <typename V, typename T> | ||||
| const typename GeneticScheduler<V, T>::Gene & | ||||
| GeneticScheduler<V, T>::getMinSchedule(void) | ||||
| { | ||||
|     return population_.begin()->second; | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| int GeneticScheduler<V, T>::getMinValue(void) | ||||
| { | ||||
|     return population_.begin()->first; | ||||
| } | ||||
|  | ||||
| // breed a new generation ////////////////////////////////////////////////////// | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::nextGeneration(void) | ||||
| { | ||||
|     // random initialization of the population if necessary | ||||
|     if (population_.size() != par_.popSize) | ||||
|     { | ||||
|         initPopulation(); | ||||
|     } | ||||
|     LOG(Debug) << "Starting population:\n" << *this << std::endl; | ||||
|      | ||||
|     // random mutations | ||||
|     //PARALLEL_FOR_LOOP | ||||
|     for (unsigned int i = 0; i < par_.popSize; ++i) | ||||
|     { | ||||
|         doMutation(); | ||||
|     } | ||||
|     LOG(Debug) << "After mutations:\n" << *this << std::endl; | ||||
|      | ||||
|     // mating | ||||
|     //PARALLEL_FOR_LOOP | ||||
|     for (unsigned int i = 0; i < par_.popSize/2; ++i) | ||||
|     { | ||||
|         doCrossover(); | ||||
|     } | ||||
|     LOG(Debug) << "After mating:\n" << *this << std::endl; | ||||
|      | ||||
|     // grim reaper | ||||
|     auto it = population_.begin(); | ||||
|      | ||||
|     std::advance(it, par_.popSize); | ||||
|     population_.erase(it, population_.end()); | ||||
|     LOG(Debug) << "After grim reaper:\n" << *this << std::endl; | ||||
| } | ||||
|  | ||||
| // evolution steps ///////////////////////////////////////////////////////////// | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::initPopulation(void) | ||||
| { | ||||
|     population_.clear(); | ||||
|     for (unsigned int i = 0; i < par_.popSize; ++i) | ||||
|     { | ||||
|         auto p = graph_.topoSort(gen_); | ||||
|          | ||||
|         population_.insert(std::make_pair(func_(p), p)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::doCrossover(void) | ||||
| { | ||||
|     auto p = selectPair(); | ||||
|     Gene &p1 = *(p.first), &p2 = *(p.second); | ||||
|     Gene c1, c2; | ||||
|      | ||||
|     crossover(c1, c2, p1, p2); | ||||
|     PARALLEL_CRITICAL | ||||
|     { | ||||
|         population_.insert(std::make_pair(func_(c1), c1)); | ||||
|         population_.insert(std::make_pair(func_(c2), c2)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::doMutation(void) | ||||
| { | ||||
|     std::uniform_real_distribution<double>      mdis(0., 1.); | ||||
|     std::uniform_int_distribution<unsigned int> pdis(0, population_.size() - 1); | ||||
|      | ||||
|     if (mdis(gen_) < par_.mutationRate) | ||||
|     { | ||||
|         Gene m; | ||||
|         auto it = population_.begin(); | ||||
|          | ||||
|         std::advance(it, pdis(gen_)); | ||||
|         mutation(m, it->second); | ||||
|         PARALLEL_CRITICAL | ||||
|         { | ||||
|             population_.insert(std::make_pair(func_(m), m)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| // genetic operators /////////////////////////////////////////////////////////// | ||||
| template <typename V, typename T> | ||||
| typename GeneticScheduler<V, T>::GenePair GeneticScheduler<V, T>::selectPair(void) | ||||
| { | ||||
|     std::vector<double> prob; | ||||
|     unsigned int        ind; | ||||
|     Gene                *p1, *p2; | ||||
|     const double        max = population_.rbegin()->first; | ||||
|      | ||||
|  | ||||
|     for (auto &c: population_) | ||||
|     { | ||||
|         prob.push_back(std::exp((c.first-1.)/max)); | ||||
|     }         | ||||
|     std::discrete_distribution<unsigned int> dis1(prob.begin(), prob.end()); | ||||
|     auto rIt = population_.begin(); | ||||
|     ind = dis1(gen_); | ||||
|     std::advance(rIt, ind); | ||||
|     p1 = &(rIt->second); | ||||
|     prob[ind] = 0.; | ||||
|     std::discrete_distribution<unsigned int> dis2(prob.begin(), prob.end()); | ||||
|     rIt = population_.begin(); | ||||
|     std::advance(rIt, dis2(gen_)); | ||||
|     p2 = &(rIt->second); | ||||
|      | ||||
|     return std::make_pair(p1, p2); | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::crossover(Gene &c1, Gene &c2, const Gene &p1, | ||||
|                                     const Gene &p2) | ||||
| { | ||||
|     Gene                                        buf; | ||||
|     std::uniform_int_distribution<unsigned int> dis(0, p1.size() - 1); | ||||
|     unsigned int                                cut = dis(gen_); | ||||
|      | ||||
|     c1.clear(); | ||||
|     buf = p2; | ||||
|     for (unsigned int i = 0; i < cut; ++i) | ||||
|     { | ||||
|         c1.push_back(p1[i]); | ||||
|         buf.erase(std::find(buf.begin(), buf.end(), p1[i])); | ||||
|     } | ||||
|     for (unsigned int i = 0; i < buf.size(); ++i) | ||||
|     { | ||||
|         c1.push_back(buf[i]); | ||||
|     } | ||||
|     c2.clear(); | ||||
|     buf = p2; | ||||
|     for (unsigned int i = cut; i < p1.size(); ++i) | ||||
|     { | ||||
|         buf.erase(std::find(buf.begin(), buf.end(), p1[i])); | ||||
|     } | ||||
|     for (unsigned int i = 0; i < buf.size(); ++i) | ||||
|     { | ||||
|         c2.push_back(buf[i]); | ||||
|     } | ||||
|     for (unsigned int i = cut; i < p1.size(); ++i) | ||||
|     { | ||||
|         c2.push_back(p1[i]); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::mutation(Gene &m, const Gene &c) | ||||
| { | ||||
|     Gene                                        buf; | ||||
|     std::uniform_int_distribution<unsigned int> dis(0, c.size() - 1); | ||||
|     unsigned int                                cut = dis(gen_); | ||||
|     Graph<T>                                    g1 = graph_, g2 = graph_; | ||||
|      | ||||
|     for (unsigned int i = 0; i < cut; ++i) | ||||
|     { | ||||
|         g1.removeVertex(c[i]); | ||||
|     } | ||||
|     for (unsigned int i = cut; i < c.size(); ++i) | ||||
|     { | ||||
|         g2.removeVertex(c[i]); | ||||
|     } | ||||
|     if (g1.size() > 0) | ||||
|     { | ||||
|         buf = g1.topoSort(gen_); | ||||
|     } | ||||
|     if (g2.size() > 0) | ||||
|     { | ||||
|         m = g2.topoSort(gen_); | ||||
|     } | ||||
|     for (unsigned int i = cut; i < c.size(); ++i) | ||||
|     { | ||||
|         m.push_back(buf[i - cut]); | ||||
|     } | ||||
| } | ||||
|  | ||||
| template <typename V, typename T> | ||||
| void GeneticScheduler<V, T>::benchmarkCrossover(const unsigned int nIt) | ||||
| { | ||||
|     Gene   p1, p2, c1, c2; | ||||
|     double neg = 0., eq = 0., pos = 0., total; | ||||
|     int    improvement; | ||||
|      | ||||
|     LOG(Message) << "Benchmarking crossover..." << std::endl; | ||||
|     for (unsigned int i = 0; i < nIt; ++i) | ||||
|     { | ||||
|         p1 = graph_.topoSort(gen_); | ||||
|         p2 = graph_.topoSort(gen_); | ||||
|         crossover(c1, c2, p1, p2); | ||||
|         improvement = (func_(c1) + func_(c2) - func_(p1) - func_(p2))/2; | ||||
|         if (improvement < 0) neg++; else if (improvement == 0) eq++; else pos++; | ||||
|     } | ||||
|     total = neg + eq + pos; | ||||
|     LOG(Message) << "  -: " << neg/total << "  =: " << eq/total | ||||
|                  << "  +: " << pos/total << std::endl; | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_GeneticScheduler_hpp_ | ||||
							
								
								
									
										76
									
								
								extras/Hadrons/Global.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								extras/Hadrons/Global.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,76 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Global.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| HadronsLogger Hadrons::HadronsLogError(1,"Error"); | ||||
| HadronsLogger Hadrons::HadronsLogWarning(1,"Warning"); | ||||
| HadronsLogger Hadrons::HadronsLogMessage(1,"Message"); | ||||
| HadronsLogger Hadrons::HadronsLogIterative(1,"Iterative"); | ||||
| HadronsLogger Hadrons::HadronsLogDebug(1,"Debug"); | ||||
|  | ||||
| void Hadrons::initLogger(void) | ||||
| { | ||||
|     auto w = std::string("Hadrons").length(); | ||||
|     GridLogError.setTopWidth(w); | ||||
|     GridLogWarning.setTopWidth(w); | ||||
|     GridLogMessage.setTopWidth(w); | ||||
|     GridLogIterative.setTopWidth(w); | ||||
|     GridLogDebug.setTopWidth(w); | ||||
|     HadronsLogError.Active(GridLogError.isActive()); | ||||
|     HadronsLogWarning.Active(GridLogWarning.isActive()); | ||||
|     HadronsLogMessage.Active(GridLogMessage.isActive()); | ||||
|     HadronsLogIterative.Active(GridLogIterative.isActive()); | ||||
|     HadronsLogDebug.Active(GridLogDebug.isActive()); | ||||
| } | ||||
|  | ||||
| // type utilities ////////////////////////////////////////////////////////////// | ||||
| constexpr unsigned int maxNameSize = 1024u; | ||||
|  | ||||
| std::string Hadrons::typeName(const std::type_info *info) | ||||
| { | ||||
|     char        *buf; | ||||
|     std::string name; | ||||
|      | ||||
|     buf  = abi::__cxa_demangle(info->name(), nullptr, nullptr, nullptr); | ||||
|     name = buf; | ||||
|     free(buf); | ||||
|      | ||||
|     return name; | ||||
| } | ||||
|  | ||||
| // default writers/readers ///////////////////////////////////////////////////// | ||||
| #ifdef HAVE_HDF5 | ||||
| const std::string Hadrons::resultFileExt = "h5"; | ||||
| #else | ||||
| const std::string Hadrons::resultFileExt = "xml"; | ||||
| #endif | ||||
							
								
								
									
										187
									
								
								extras/Hadrons/Global.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								extras/Hadrons/Global.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,187 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Global.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Global_hpp_ | ||||
| #define Hadrons_Global_hpp_ | ||||
|  | ||||
| #include <set> | ||||
| #include <stack> | ||||
| #include <Grid/Grid.h> | ||||
| #include <cxxabi.h> | ||||
|  | ||||
| #ifndef SITE_SIZE_TYPE | ||||
| #define SITE_SIZE_TYPE size_t | ||||
| #endif | ||||
|  | ||||
| #define BEGIN_HADRONS_NAMESPACE \ | ||||
| namespace Grid {\ | ||||
| using namespace QCD;\ | ||||
| namespace Hadrons {\ | ||||
| using Grid::operator<<; | ||||
| #define END_HADRONS_NAMESPACE }} | ||||
|  | ||||
| #define BEGIN_MODULE_NAMESPACE(name)\ | ||||
| namespace name {\ | ||||
| using Grid::operator<<; | ||||
| #define END_MODULE_NAMESPACE } | ||||
|  | ||||
| /* the 'using Grid::operator<<;' statement prevents a very nasty compilation | ||||
|  * error with GCC 5 (clang & GCC 6 compile fine without it). | ||||
|  */ | ||||
|  | ||||
| #ifndef FIMPL | ||||
| #define FIMPL WilsonImplR | ||||
| #endif | ||||
| #ifndef SIMPL | ||||
| #define SIMPL ScalarImplCR | ||||
| #endif | ||||
| #ifndef GIMPL | ||||
| #define GIMPL GimplTypesR | ||||
| #endif | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| // type aliases | ||||
| #define FERM_TYPE_ALIASES(FImpl, suffix)\ | ||||
| typedef FermionOperator<FImpl>                        FMat##suffix;            \ | ||||
| typedef typename FImpl::FermionField                  FermionField##suffix;    \ | ||||
| typedef typename FImpl::PropagatorField               PropagatorField##suffix; \ | ||||
| typedef typename FImpl::SitePropagator::scalar_object SitePropagator##suffix;  \ | ||||
| typedef std::vector<SitePropagator##suffix>           SlicedPropagator##suffix; | ||||
|  | ||||
| #define GAUGE_TYPE_ALIASES(FImpl, suffix)\ | ||||
| typedef typename FImpl::DoubledGaugeField DoubledGaugeField##suffix; | ||||
|  | ||||
| #define SCALAR_TYPE_ALIASES(SImpl, suffix)\ | ||||
| typedef typename SImpl::Field ScalarField##suffix;\ | ||||
| typedef typename SImpl::Field PropagatorField##suffix; | ||||
|  | ||||
| #define SOLVER_TYPE_ALIASES(FImpl, suffix)\ | ||||
| typedef std::function<void(FermionField##suffix &,\ | ||||
|                       const FermionField##suffix &)> SolverFn##suffix; | ||||
|  | ||||
| #define SINK_TYPE_ALIASES(suffix)\ | ||||
| typedef std::function<SlicedPropagator##suffix\ | ||||
|                       (const PropagatorField##suffix &)> SinkFn##suffix; | ||||
|  | ||||
| #define FGS_TYPE_ALIASES(FImpl, suffix)\ | ||||
| FERM_TYPE_ALIASES(FImpl, suffix)\ | ||||
| GAUGE_TYPE_ALIASES(FImpl, suffix)\ | ||||
| SOLVER_TYPE_ALIASES(FImpl, suffix) | ||||
|  | ||||
| // logger | ||||
| class HadronsLogger: public Logger | ||||
| { | ||||
| public: | ||||
|     HadronsLogger(int on, std::string nm): Logger("Hadrons", on, nm, | ||||
|                                                   GridLogColours, "BLACK"){}; | ||||
| }; | ||||
|  | ||||
| #define LOG(channel) std::cout << HadronsLog##channel | ||||
| #define DEBUG_VAR(var) LOG(Debug) << #var << "= " << (var) << std::endl; | ||||
|  | ||||
| extern HadronsLogger HadronsLogError; | ||||
| extern HadronsLogger HadronsLogWarning; | ||||
| extern HadronsLogger HadronsLogMessage; | ||||
| extern HadronsLogger HadronsLogIterative; | ||||
| extern HadronsLogger HadronsLogDebug; | ||||
|  | ||||
| void initLogger(void); | ||||
|  | ||||
| // singleton pattern | ||||
| #define SINGLETON(name)\ | ||||
| public:\ | ||||
|     name(const name &e) = delete;\ | ||||
|     void operator=(const name &e) = delete;\ | ||||
|     static name & getInstance(void)\ | ||||
|     {\ | ||||
|         static name e;\ | ||||
|         return e;\ | ||||
|     }\ | ||||
| private:\ | ||||
|     name(void); | ||||
|  | ||||
| #define SINGLETON_DEFCTOR(name)\ | ||||
| public:\ | ||||
|     name(const name &e) = delete;\ | ||||
|     void operator=(const name &e) = delete;\ | ||||
|     static name & getInstance(void)\ | ||||
|     {\ | ||||
|         static name e;\ | ||||
|         return e;\ | ||||
|     }\ | ||||
| private:\ | ||||
|     name(void) = default; | ||||
|  | ||||
| // type utilities | ||||
| template <typename T> | ||||
| const std::type_info * typeIdPt(const T &x) | ||||
| { | ||||
|     return &typeid(x); | ||||
| } | ||||
|  | ||||
| std::string typeName(const std::type_info *info); | ||||
|  | ||||
| template <typename T> | ||||
| const std::type_info * typeIdPt(void) | ||||
| { | ||||
|     return &typeid(T); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| std::string typeName(const T &x) | ||||
| { | ||||
|     return typeName(typeIdPt(x)); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| std::string typeName(void) | ||||
| { | ||||
|     return typeName(typeIdPt<T>()); | ||||
| } | ||||
|  | ||||
| // default writers/readers | ||||
| extern const std::string resultFileExt; | ||||
|  | ||||
| #ifdef HAVE_HDF5 | ||||
| typedef Hdf5Reader ResultReader; | ||||
| typedef Hdf5Writer ResultWriter; | ||||
| #else | ||||
| typedef XmlReader ResultReader; | ||||
| typedef XmlWriter ResultWriter; | ||||
| #endif | ||||
|  | ||||
| #define RESULT_FILE_NAME(name) \ | ||||
| name + "." + std::to_string(vm().getTrajectory()) + "." + resultFileExt | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #include <Grid/Hadrons/Exceptions.hpp> | ||||
|  | ||||
| #endif // Hadrons_Global_hpp_ | ||||
							
								
								
									
										759
									
								
								extras/Hadrons/Graph.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										759
									
								
								extras/Hadrons/Graph.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,759 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Graph.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Graph_hpp_ | ||||
| #define Hadrons_Graph_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                          Oriented graph class                              * | ||||
|  ******************************************************************************/ | ||||
| // I/O for edges | ||||
| template <typename T> | ||||
| std::ostream & operator<<(std::ostream &out, const std::pair<T, T> &e) | ||||
| { | ||||
|     out << "\""  << e.first << "\" -> \"" << e.second << "\""; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // main class | ||||
| template <typename T> | ||||
| class Graph | ||||
| { | ||||
| public: | ||||
|     typedef std::pair<T, T> Edge; | ||||
| public: | ||||
|     // constructor | ||||
|     Graph(void); | ||||
|     // destructor | ||||
|     virtual ~Graph(void) = default; | ||||
|     // access | ||||
|     void           addVertex(const T &value); | ||||
|     void           addEdge(const Edge &e); | ||||
|     void           addEdge(const T &start, const T &end); | ||||
|     std::vector<T> getVertices(void) const; | ||||
|     void           removeVertex(const T &value); | ||||
|     void           removeEdge(const Edge &e); | ||||
|     void           removeEdge(const T &start, const T &end); | ||||
|     unsigned int   size(void) const; | ||||
|     // tests | ||||
|     bool gotValue(const T &value) const; | ||||
|     // graph topological manipulations | ||||
|     std::vector<T>              getAdjacentVertices(const T &value) const; | ||||
|     std::vector<T>              getChildren(const T &value) const; | ||||
|     std::vector<T>              getParents(const T &value) const; | ||||
|     std::vector<T>              getRoots(void) const; | ||||
|     std::vector<Graph<T>>       getConnectedComponents(void) const; | ||||
|     std::vector<T>              topoSort(void); | ||||
|     template <typename Gen> | ||||
|     std::vector<T>              topoSort(Gen &gen); | ||||
|     std::vector<std::vector<T>> allTopoSort(void); | ||||
|     // I/O | ||||
|     friend std::ostream & operator<<(std::ostream &out, const Graph<T> &g) | ||||
|     { | ||||
|         out << "{"; | ||||
|         for (auto &e: g.edgeSet_) | ||||
|         { | ||||
|             out << e << ", "; | ||||
|         } | ||||
|         if (g.edgeSet_.size() != 0) | ||||
|         { | ||||
|             out << "\b\b"; | ||||
|         } | ||||
|         out << "}"; | ||||
|          | ||||
|         return out; | ||||
|     } | ||||
| private: | ||||
|     // vertex marking | ||||
|     void      mark(const T &value, const bool doMark = true); | ||||
|     void      markAll(const bool doMark = true); | ||||
|     void      unmark(const T &value); | ||||
|     void      unmarkAll(void); | ||||
|     bool      isMarked(const T &value) const; | ||||
|     const T * getFirstMarked(const bool isMarked = true) const; | ||||
|     template <typename Gen> | ||||
|     const T * getRandomMarked(const bool isMarked, Gen &gen); | ||||
|     const T * getFirstUnmarked(void) const; | ||||
|     template <typename Gen> | ||||
|     const T * getRandomUnmarked(Gen &gen); | ||||
|     // prune marked/unmarked vertices | ||||
|     void removeMarked(const bool isMarked = true); | ||||
|     void removeUnmarked(void); | ||||
|     // depth-first search marking | ||||
|     void depthFirstSearch(void); | ||||
|     void depthFirstSearch(const T &root); | ||||
| private: | ||||
|     std::map<T, bool>  isMarked_; | ||||
|     std::set<Edge>     edgeSet_; | ||||
| }; | ||||
|  | ||||
| // build depedency matrix from topological sorts | ||||
| template <typename T> | ||||
| std::map<T, std::map<T, bool>> | ||||
| makeDependencyMatrix(const std::vector<std::vector<T>> &topSort); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       template implementation                              * | ||||
|  ****************************************************************************** | ||||
|  * in all the following V is the number of vertex and E is the number of edge | ||||
|  * in the worst case E = V^2 | ||||
|  */ | ||||
|  | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename T> | ||||
| Graph<T>::Graph(void) | ||||
| {} | ||||
|  | ||||
| // access ////////////////////////////////////////////////////////////////////// | ||||
| // complexity: log(V) | ||||
| template <typename T> | ||||
| void Graph<T>::addVertex(const T &value) | ||||
| { | ||||
|     isMarked_[value] = false; | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::addEdge(const Edge &e) | ||||
| { | ||||
|     addVertex(e.first); | ||||
|     addVertex(e.second); | ||||
|     edgeSet_.insert(e); | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::addEdge(const T &start, const T &end) | ||||
| { | ||||
|     addEdge(Edge(start, end)); | ||||
| } | ||||
|  | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::getVertices(void) const | ||||
| { | ||||
|     std::vector<T> vertex; | ||||
|      | ||||
|     for (auto &v: isMarked_) | ||||
|     { | ||||
|         vertex.push_back(v.first); | ||||
|     } | ||||
|      | ||||
|     return vertex; | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::removeVertex(const T &value) | ||||
| { | ||||
|     // remove vertex from the mark table | ||||
|     auto vIt = isMarked_.find(value); | ||||
|      | ||||
|     if (vIt != isMarked_.end()) | ||||
|     { | ||||
|         isMarked_.erase(vIt); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Range, "vertex does not exists"); | ||||
|     } | ||||
|  | ||||
|     // remove all edges containing the vertex | ||||
|     auto pred = [&value](const Edge &e) | ||||
|     { | ||||
|         return ((e.first == value) or (e.second == value)); | ||||
|     }; | ||||
|     auto eIt = find_if(edgeSet_.begin(), edgeSet_.end(), pred); | ||||
|      | ||||
|     while (eIt != edgeSet_.end()) | ||||
|     { | ||||
|         edgeSet_.erase(eIt); | ||||
|         eIt = find_if(edgeSet_.begin(), edgeSet_.end(), pred); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::removeEdge(const Edge &e) | ||||
| { | ||||
|     auto eIt = edgeSet_.find(e); | ||||
|      | ||||
|     if (eIt != edgeSet_.end()) | ||||
|     { | ||||
|         edgeSet_.erase(eIt); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Range, "edge does not exists"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::removeEdge(const T &start, const T &end) | ||||
| { | ||||
|     removeEdge(Edge(start, end)); | ||||
| } | ||||
|  | ||||
| // complexity: O(1) | ||||
| template <typename T> | ||||
| unsigned int Graph<T>::size(void) const | ||||
| { | ||||
|     return isMarked_.size(); | ||||
| } | ||||
|  | ||||
| // tests /////////////////////////////////////////////////////////////////////// | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| bool Graph<T>::gotValue(const T &value) const | ||||
| { | ||||
|     auto it = isMarked_.find(value); | ||||
|      | ||||
|     if (it == isMarked_.end()) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|  | ||||
| // vertex marking ////////////////////////////////////////////////////////////// | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::mark(const T &value, const bool doMark) | ||||
| { | ||||
|     if (gotValue(value)) | ||||
|     { | ||||
|         isMarked_[value] = doMark; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Range, "vertex does not exists"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::markAll(const bool doMark) | ||||
| { | ||||
|     for (auto &v: isMarked_) | ||||
|     { | ||||
|         mark(v.first, doMark); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::unmark(const T &value) | ||||
| { | ||||
|     mark(value, false); | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::unmarkAll(void) | ||||
| { | ||||
|     markAll(false); | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| bool Graph<T>::isMarked(const T &value) const | ||||
| { | ||||
|     if (gotValue(value)) | ||||
|     { | ||||
|         return isMarked_.at(value); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         HADRON_ERROR(Range, "vertex does not exists"); | ||||
|          | ||||
|         return false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| const T * Graph<T>::getFirstMarked(const bool isMarked) const | ||||
| { | ||||
|     auto pred = [&isMarked](const std::pair<T, bool> &v) | ||||
|     { | ||||
|         return (v.second == isMarked); | ||||
|     }; | ||||
|     auto vIt = std::find_if(isMarked_.begin(), isMarked_.end(), pred); | ||||
|      | ||||
|     if (vIt != isMarked_.end()) | ||||
|     { | ||||
|         return &(vIt->first); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         return nullptr; | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| template <typename Gen> | ||||
| const T * Graph<T>::getRandomMarked(const bool isMarked, Gen &gen) | ||||
| { | ||||
|     auto pred = [&isMarked](const std::pair<T, bool> &v) | ||||
|     { | ||||
|         return (v.second == isMarked); | ||||
|     }; | ||||
|     std::uniform_int_distribution<unsigned int> dis(0, size() - 1); | ||||
|     auto                                        rIt = isMarked_.begin(); | ||||
|      | ||||
|     std::advance(rIt, dis(gen)); | ||||
|     auto vIt = std::find_if(rIt, isMarked_.end(), pred); | ||||
|     if (vIt != isMarked_.end()) | ||||
|     { | ||||
|         return &(vIt->first); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         vIt = std::find_if(isMarked_.begin(), rIt, pred); | ||||
|         if (vIt != rIt) | ||||
|         { | ||||
|             return &(vIt->first); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             return nullptr; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| const T * Graph<T>::getFirstUnmarked(void) const | ||||
| { | ||||
|     return getFirstMarked(false); | ||||
| } | ||||
|  | ||||
| // complexity: O(log(V)) | ||||
| template <typename T> | ||||
| template <typename Gen> | ||||
| const T * Graph<T>::getRandomUnmarked(Gen &gen) | ||||
| { | ||||
|     return getRandomMarked(false, gen); | ||||
| } | ||||
|  | ||||
| // prune marked/unmarked vertices ////////////////////////////////////////////// | ||||
| // complexity: O(V^2*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::removeMarked(const bool isMarked) | ||||
| { | ||||
|     auto isMarkedCopy = isMarked_; | ||||
|      | ||||
|     for (auto &v: isMarkedCopy) | ||||
|     { | ||||
|         if (v.second == isMarked) | ||||
|         { | ||||
|             removeVertex(v.first); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| // complexity: O(V^2*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::removeUnmarked(void) | ||||
| { | ||||
|     removeMarked(false); | ||||
| } | ||||
|  | ||||
| // depth-first search marking ////////////////////////////////////////////////// | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::depthFirstSearch(void) | ||||
| { | ||||
|     depthFirstSearch(isMarked_.begin()->first); | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| void Graph<T>::depthFirstSearch(const T &root) | ||||
| { | ||||
|     std::vector<T> adjacentVertex; | ||||
|      | ||||
|     mark(root); | ||||
|     adjacentVertex = getAdjacentVertices(root); | ||||
|     for (auto &v: adjacentVertex) | ||||
|     { | ||||
|         if (!isMarked(v)) | ||||
|         { | ||||
|             depthFirstSearch(v); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| // graph topological manipulations ///////////////////////////////////////////// | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::getAdjacentVertices(const T &value) const | ||||
| { | ||||
|     std::vector<T> adjacentVertex; | ||||
|      | ||||
|     auto pred = [&value](const Edge &e) | ||||
|     { | ||||
|         return ((e.first == value) or (e.second == value)); | ||||
|     }; | ||||
|     auto eIt = std::find_if(edgeSet_.begin(), edgeSet_.end(), pred); | ||||
|      | ||||
|     while (eIt != edgeSet_.end()) | ||||
|     { | ||||
|         if (eIt->first == value) | ||||
|         { | ||||
|             adjacentVertex.push_back((*eIt).second); | ||||
|         } | ||||
|         else if (eIt->second == value) | ||||
|         { | ||||
|             adjacentVertex.push_back((*eIt).first); | ||||
|         } | ||||
|         eIt = std::find_if(++eIt, edgeSet_.end(), pred); | ||||
|     } | ||||
|      | ||||
|     return adjacentVertex; | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::getChildren(const T &value) const | ||||
| { | ||||
|     std::vector<T> child; | ||||
|      | ||||
|     auto pred = [&value](const Edge &e) | ||||
|     { | ||||
|         return (e.first == value); | ||||
|     }; | ||||
|     auto eIt = std::find_if(edgeSet_.begin(), edgeSet_.end(), pred); | ||||
|      | ||||
|     while (eIt != edgeSet_.end()) | ||||
|     { | ||||
|         child.push_back((*eIt).second); | ||||
|         eIt = std::find_if(++eIt, edgeSet_.end(), pred); | ||||
|     } | ||||
|      | ||||
|     return child; | ||||
| } | ||||
|  | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::getParents(const T &value) const | ||||
| { | ||||
|     std::vector<T> parent; | ||||
|      | ||||
|     auto pred = [&value](const Edge &e) | ||||
|     { | ||||
|         return (e.second == value); | ||||
|     }; | ||||
|     auto eIt = std::find_if(edgeSet_.begin(), edgeSet_.end(), pred); | ||||
|      | ||||
|     while (eIt != edgeSet_.end()) | ||||
|     { | ||||
|         parent.push_back((*eIt).first); | ||||
|         eIt = std::find_if(++eIt, edgeSet_.end(), pred); | ||||
|     } | ||||
|      | ||||
|     return parent; | ||||
| } | ||||
|  | ||||
| // complexity: O(V^2*log(V)) | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::getRoots(void) const | ||||
| { | ||||
|     std::vector<T> root; | ||||
|      | ||||
|     for (auto &v: isMarked_) | ||||
|     { | ||||
|         auto parent = getParents(v.first); | ||||
|          | ||||
|         if (parent.size() == 0) | ||||
|         { | ||||
|             root.push_back(v.first); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     return root; | ||||
| } | ||||
|  | ||||
| // complexity: O(V^2*log(V)) | ||||
| template <typename T> | ||||
| std::vector<Graph<T>> Graph<T>::getConnectedComponents(void) const | ||||
| { | ||||
|     std::vector<Graph<T>> res; | ||||
|     Graph<T>              copy(*this); | ||||
|      | ||||
|     while (copy.size() > 0) | ||||
|     { | ||||
|         copy.depthFirstSearch(); | ||||
|         res.push_back(copy); | ||||
|         res.back().removeUnmarked(); | ||||
|         res.back().unmarkAll(); | ||||
|         copy.removeMarked(); | ||||
|         copy.unmarkAll(); | ||||
|     } | ||||
|      | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| // topological sort using a directed DFS algorithm | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| std::vector<T> Graph<T>::topoSort(void) | ||||
| { | ||||
|     std::stack<T>     buf; | ||||
|     std::vector<T>    res; | ||||
|     const T           *vPt; | ||||
|     std::map<T, bool> tmpMarked(isMarked_); | ||||
|  | ||||
|     // visit function | ||||
|     std::function<void(const T &)> visit = [&](const T &v) | ||||
|     { | ||||
|         if (tmpMarked.at(v)) | ||||
|         { | ||||
|             HADRON_ERROR(Range, "cannot topologically sort a cyclic graph"); | ||||
|         } | ||||
|         if (!isMarked(v)) | ||||
|         { | ||||
|             std::vector<T> child = getChildren(v); | ||||
|  | ||||
|             tmpMarked[v] = true; | ||||
|             for (auto &c: child) | ||||
|             { | ||||
|                 visit(c); | ||||
|             } | ||||
|             mark(v); | ||||
|             tmpMarked[v] = false; | ||||
|             buf.push(v); | ||||
|         } | ||||
|     }; | ||||
|      | ||||
|     // reset temporary marks | ||||
|     for (auto &v: tmpMarked) | ||||
|     { | ||||
|         tmpMarked.at(v.first) = false; | ||||
|     } | ||||
|      | ||||
|     // loop on unmarked vertices | ||||
|     unmarkAll(); | ||||
|     vPt = getFirstUnmarked(); | ||||
|     while (vPt) | ||||
|     { | ||||
|         visit(*vPt); | ||||
|         vPt = getFirstUnmarked(); | ||||
|     } | ||||
|     unmarkAll(); | ||||
|      | ||||
|     // create result vector | ||||
|     while (!buf.empty()) | ||||
|     { | ||||
|         res.push_back(buf.top()); | ||||
|         buf.pop(); | ||||
|     } | ||||
|      | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| // random version of the topological sort | ||||
| // complexity: O(V*log(V)) | ||||
| template <typename T> | ||||
| template <typename Gen> | ||||
| std::vector<T> Graph<T>::topoSort(Gen &gen) | ||||
| { | ||||
|     std::stack<T>     buf; | ||||
|     std::vector<T>    res; | ||||
|     const T           *vPt; | ||||
|     std::map<T, bool> tmpMarked(isMarked_); | ||||
|      | ||||
|     // visit function | ||||
|     std::function<void(const T &)> visit = [&](const T &v) | ||||
|     { | ||||
|         if (tmpMarked.at(v)) | ||||
|         { | ||||
|             HADRON_ERROR(Range, "cannot topologically sort a cyclic graph"); | ||||
|         } | ||||
|         if (!isMarked(v)) | ||||
|         { | ||||
|             std::vector<T> child = getChildren(v); | ||||
|              | ||||
|             tmpMarked[v] = true; | ||||
|             std::shuffle(child.begin(), child.end(), gen); | ||||
|             for (auto &c: child) | ||||
|             { | ||||
|                 visit(c); | ||||
|             } | ||||
|             mark(v); | ||||
|             tmpMarked[v] = false; | ||||
|             buf.push(v); | ||||
|         } | ||||
|     }; | ||||
|      | ||||
|     // reset temporary marks | ||||
|     for (auto &v: tmpMarked) | ||||
|     { | ||||
|         tmpMarked.at(v.first) = false; | ||||
|     } | ||||
|      | ||||
|     // loop on unmarked vertices | ||||
|     unmarkAll(); | ||||
|     vPt = getRandomUnmarked(gen); | ||||
|     while (vPt) | ||||
|     { | ||||
|         visit(*vPt); | ||||
|         vPt = getRandomUnmarked(gen); | ||||
|     } | ||||
|     unmarkAll(); | ||||
|      | ||||
|     // create result vector | ||||
|     while (!buf.empty()) | ||||
|     { | ||||
|         res.push_back(buf.top()); | ||||
|         buf.pop(); | ||||
|     } | ||||
|      | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| // generate all possible topological sorts | ||||
| // Y. L. Varol & D. Rotem, Comput. J. 24(1), pp. 83–84, 1981 | ||||
| // http://comjnl.oupjournals.org/cgi/doi/10.1093/comjnl/24.1.83 | ||||
| // complexity: O(V*log(V)) (from the paper, but really ?) | ||||
| template <typename T> | ||||
| std::vector<std::vector<T>> Graph<T>::allTopoSort(void) | ||||
| { | ||||
|     std::vector<std::vector<T>>    res; | ||||
|     std::map<T, std::map<T, bool>> iMat; | ||||
|      | ||||
|     // create incidence matrix | ||||
|     for (auto &v1: isMarked_) | ||||
|     for (auto &v2: isMarked_) | ||||
|     { | ||||
|         iMat[v1.first][v2.first] = false; | ||||
|     } | ||||
|     for (auto &v: isMarked_) | ||||
|     { | ||||
|         auto cVec = getChildren(v.first); | ||||
|          | ||||
|         for (auto &c: cVec) | ||||
|         { | ||||
|             iMat[v.first][c] = true; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     // generate initial topological sort | ||||
|     res.push_back(topoSort()); | ||||
|      | ||||
|     // generate all other topological sorts by permutation | ||||
|     std::vector<T>            p = res[0]; | ||||
|     const unsigned int        n = size(); | ||||
|     std::vector<unsigned int> loc(n); | ||||
|     unsigned int              i, k, k1; | ||||
|     T                         obj_k, obj_k1; | ||||
|     bool                      isFinal; | ||||
|      | ||||
|     for (unsigned int j = 0; j < n; ++j) | ||||
|     { | ||||
|         loc[j] = j; | ||||
|     } | ||||
|     i = 0; | ||||
|     while (i < n-1) | ||||
|     { | ||||
|         k      = loc[i]; | ||||
|         k1     = k + 1; | ||||
|         obj_k  = p[k]; | ||||
|         if (k1 >= n) | ||||
|         { | ||||
|             isFinal = true; | ||||
|             obj_k1  = obj_k; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             isFinal = false; | ||||
|             obj_k1  = p[k1]; | ||||
|         } | ||||
|         if (iMat[res[0][i]][obj_k1] or isFinal) | ||||
|         { | ||||
|             for (unsigned int l = k; l >= i + 1; --l) | ||||
|             { | ||||
|                 p[l]   = p[l-1]; | ||||
|             } | ||||
|             p[i]   = obj_k; | ||||
|             loc[i] = i; | ||||
|             i++; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             p[k]   = obj_k1; | ||||
|             p[k1]  = obj_k; | ||||
|             loc[i] = k1; | ||||
|             i      = 0; | ||||
|             res.push_back(p); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| // build depedency matrix from topological sorts /////////////////////////////// | ||||
| // complexity: something like O(V^2*log(V!)) | ||||
| template <typename T> | ||||
| std::map<T, std::map<T, bool>> | ||||
| makeDependencyMatrix(const std::vector<std::vector<T>> &topSort) | ||||
| { | ||||
|     std::map<T, std::map<T, bool>> m; | ||||
|     const std::vector<T>           &vList = topSort[0]; | ||||
|      | ||||
|     for (auto &v1: vList) | ||||
|     for (auto &v2: vList) | ||||
|     { | ||||
|         bool dep = true; | ||||
|          | ||||
|         for (auto &t: topSort) | ||||
|         { | ||||
|             auto i1 = std::find(t.begin(), t.end(), v1); | ||||
|             auto i2 = std::find(t.begin(), t.end(), v2); | ||||
|              | ||||
|             dep = dep and (i1 - i2 > 0); | ||||
|             if (!dep) break; | ||||
|         } | ||||
|         m[v1][v2] = dep; | ||||
|     } | ||||
|      | ||||
|     return m; | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Graph_hpp_ | ||||
							
								
								
									
										73
									
								
								extras/Hadrons/HadronsXmlRun.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								extras/Hadrons/HadronsXmlRun.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/HadronsXmlRun.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Application.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|     // parse command line | ||||
|     std::string parameterFileName, scheduleFileName = ""; | ||||
|      | ||||
|     if (argc < 2) | ||||
|     { | ||||
|         std::cerr << "usage: " << argv[0] << " <parameter file> [<precomputed schedule>] [Grid options]"; | ||||
|         std::cerr << std::endl; | ||||
|         std::exit(EXIT_FAILURE); | ||||
|     } | ||||
|     parameterFileName = argv[1]; | ||||
|     if (argc > 2) | ||||
|     { | ||||
|         if (argv[2][0] != '-') | ||||
|         { | ||||
|             scheduleFileName = argv[2]; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     // initialization | ||||
|     Grid_init(&argc, &argv); | ||||
|      | ||||
|     // execution | ||||
|     Application application(parameterFileName); | ||||
|      | ||||
|     application.parseParameterFile(parameterFileName); | ||||
|     if (!scheduleFileName.empty()) | ||||
|     { | ||||
|         application.loadSchedule(scheduleFileName); | ||||
|     } | ||||
|     application.run(); | ||||
|      | ||||
|     // epilogue | ||||
|     LOG(Message) << "Grid is finalizing now" << std::endl; | ||||
|     Grid_finalize(); | ||||
|      | ||||
|     return EXIT_SUCCESS; | ||||
| } | ||||
							
								
								
									
										65
									
								
								extras/Hadrons/HadronsXmlSchedule.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								extras/Hadrons/HadronsXmlSchedule.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/HadronsXmlSchedule.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Application.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|     // parse command line | ||||
|     std::string parameterFileName, scheduleFileName; | ||||
|      | ||||
|     if (argc < 3) | ||||
|     { | ||||
|         std::cerr << "usage: " << argv[0] << " <parameter file> <schedule output> [Grid options]"; | ||||
|         std::cerr << std::endl; | ||||
|         std::exit(EXIT_FAILURE); | ||||
|     } | ||||
|     parameterFileName = argv[1]; | ||||
|     scheduleFileName  = argv[2]; | ||||
|      | ||||
|     // initialization | ||||
|     Grid_init(&argc, &argv); | ||||
|      | ||||
|     // execution | ||||
|     Application application; | ||||
|      | ||||
|     application.parseParameterFile(parameterFileName); | ||||
|     application.schedule(); | ||||
|     application.printSchedule(); | ||||
|     application.saveSchedule(scheduleFileName); | ||||
|      | ||||
|     // epilogue | ||||
|     LOG(Message) << "Grid is finalizing now" << std::endl; | ||||
|     Grid_finalize(); | ||||
|      | ||||
|     return EXIT_SUCCESS; | ||||
| } | ||||
							
								
								
									
										33
									
								
								extras/Hadrons/Makefile.am
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								extras/Hadrons/Makefile.am
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| lib_LIBRARIES = libHadrons.a | ||||
| bin_PROGRAMS  = HadronsXmlRun HadronsXmlSchedule | ||||
|  | ||||
| include modules.inc | ||||
|  | ||||
| libHadrons_a_SOURCES = \ | ||||
|     $(modules_cc)      \ | ||||
|     Application.cc     \ | ||||
|     Environment.cc     \ | ||||
| 	Exceptions.cc      \ | ||||
|     Global.cc          \ | ||||
|     Module.cc		   \ | ||||
| 	VirtualMachine.cc | ||||
| libHadrons_adir = $(pkgincludedir)/Hadrons | ||||
| nobase_libHadrons_a_HEADERS = \ | ||||
| 	$(modules_hpp)            \ | ||||
| 	Application.hpp           \ | ||||
| 	Environment.hpp           \ | ||||
| 	Exceptions.hpp            \ | ||||
| 	Factory.hpp               \ | ||||
| 	GeneticScheduler.hpp      \ | ||||
| 	Global.hpp                \ | ||||
| 	Graph.hpp                 \ | ||||
| 	Module.hpp                \ | ||||
| 	Modules.hpp               \ | ||||
| 	ModuleFactory.hpp         \ | ||||
| 	VirtualMachine.hpp | ||||
|  | ||||
| HadronsXmlRun_SOURCES = HadronsXmlRun.cc | ||||
| HadronsXmlRun_LDADD   = libHadrons.a -lGrid | ||||
|  | ||||
| HadronsXmlSchedule_SOURCES = HadronsXmlSchedule.cc | ||||
| HadronsXmlSchedule_LDADD   = libHadrons.a -lGrid | ||||
							
								
								
									
										61
									
								
								extras/Hadrons/Module.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								extras/Hadrons/Module.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Module.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace QCD; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       ModuleBase implementation                            * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| ModuleBase::ModuleBase(const std::string name) | ||||
| : name_(name) | ||||
| {} | ||||
|  | ||||
| // access ////////////////////////////////////////////////////////////////////// | ||||
| std::string ModuleBase::getName(void) const | ||||
| { | ||||
|     return name_; | ||||
| } | ||||
|  | ||||
| // get factory registration name if available | ||||
| std::string ModuleBase::getRegisteredName(void) | ||||
| { | ||||
|     HADRON_ERROR(Definition, "module '" + getName() + "' has no registered type" | ||||
|                  + " in the factory"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void ModuleBase::operator()(void) | ||||
| { | ||||
|     setup(); | ||||
|     execute(); | ||||
| } | ||||
							
								
								
									
										254
									
								
								extras/Hadrons/Module.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										254
									
								
								extras/Hadrons/Module.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,254 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Module.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_Module_hpp_ | ||||
| #define Hadrons_Module_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/VirtualMachine.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| // module registration macros | ||||
| #define MODULE_REGISTER(mod, base)\ | ||||
| class mod: public base\ | ||||
| {\ | ||||
| public:\ | ||||
|     typedef base Base;\ | ||||
|     using Base::Base;\ | ||||
|     virtual std::string getRegisteredName(void)\ | ||||
|     {\ | ||||
|         return std::string(#mod);\ | ||||
|     }\ | ||||
| };\ | ||||
| class mod##ModuleRegistrar\ | ||||
| {\ | ||||
| public:\ | ||||
|     mod##ModuleRegistrar(void)\ | ||||
|     {\ | ||||
|         ModuleFactory &modFac = ModuleFactory::getInstance();\ | ||||
|         modFac.registerBuilder(#mod, [&](const std::string name)\ | ||||
|                               {\ | ||||
|                                   return std::unique_ptr<mod>(new mod(name));\ | ||||
|                               });\ | ||||
|     }\ | ||||
| };\ | ||||
| static mod##ModuleRegistrar mod##ModuleRegistrarInstance; | ||||
|  | ||||
| #define MODULE_REGISTER_NS(mod, base, ns)\ | ||||
| class mod: public base\ | ||||
| {\ | ||||
| public:\ | ||||
|     typedef base Base;\ | ||||
|     using Base::Base;\ | ||||
|     virtual std::string getRegisteredName(void)\ | ||||
|     {\ | ||||
|         return std::string(#ns "::" #mod);\ | ||||
|     }\ | ||||
| };\ | ||||
| class ns##mod##ModuleRegistrar\ | ||||
| {\ | ||||
| public:\ | ||||
|     ns##mod##ModuleRegistrar(void)\ | ||||
|     {\ | ||||
|         ModuleFactory &modFac = ModuleFactory::getInstance();\ | ||||
|         modFac.registerBuilder(#ns "::" #mod, [&](const std::string name)\ | ||||
|                               {\ | ||||
|                                   return std::unique_ptr<ns::mod>(new ns::mod(name));\ | ||||
|                               });\ | ||||
|     }\ | ||||
| };\ | ||||
| static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance; | ||||
|  | ||||
| #define ARG(...) __VA_ARGS__ | ||||
| #define MACRO_REDIRECT(arg1, arg2, arg3, macro, ...) macro | ||||
|  | ||||
| #define envGet(type, name)\ | ||||
| *env().template getObject<type>(name) | ||||
|  | ||||
| #define envGetTmp(type, var)\ | ||||
| type &var = *env().template getObject<type>(getName() + "_tmp_" + #var) | ||||
|  | ||||
| #define envHasType(type, name)\ | ||||
| env().template isObjectOfType<type>(name) | ||||
|  | ||||
| #define envCreate(type, name, Ls, ...)\ | ||||
| env().template createObject<type>(name, Environment::Storage::object, Ls, __VA_ARGS__) | ||||
|  | ||||
| #define envCreateDerived(base, type, name, Ls, ...)\ | ||||
| env().template createDerivedObject<base, type>(name, Environment::Storage::object, Ls, __VA_ARGS__) | ||||
|  | ||||
| #define envCreateLat4(type, name)\ | ||||
| envCreate(type, name, 1, env().getGrid()) | ||||
|  | ||||
| #define envCreateLat5(type, name, Ls)\ | ||||
| envCreate(type, name, Ls, env().getGrid(Ls)) | ||||
|  | ||||
| #define envCreateLat(...)\ | ||||
| MACRO_REDIRECT(__VA_ARGS__, envCreateLat5, envCreateLat4)(__VA_ARGS__) | ||||
|  | ||||
| #define envCache(type, name, Ls, ...)\ | ||||
| env().template createObject<type>(name, Environment::Storage::cache, Ls, __VA_ARGS__) | ||||
|  | ||||
| #define envCacheLat4(type, name)\ | ||||
| envCache(type, name, 1, env().getGrid()) | ||||
|  | ||||
| #define envCacheLat5(type, name, Ls)\ | ||||
| envCache(type, name, Ls, env().getGrid(Ls)) | ||||
|  | ||||
| #define envCacheLat(...)\ | ||||
| MACRO_REDIRECT(__VA_ARGS__, envCacheLat5, envCacheLat4)(__VA_ARGS__) | ||||
|  | ||||
| #define envTmp(type, name, Ls, ...)\ | ||||
| env().template createObject<type>(getName() + "_tmp_" + name,         \ | ||||
|                                   Environment::Storage::temporary, Ls, __VA_ARGS__) | ||||
|  | ||||
| #define envTmpLat4(type, name)\ | ||||
| envTmp(type, name, 1, env().getGrid()) | ||||
|  | ||||
| #define envTmpLat5(type, name, Ls)\ | ||||
| envTmp(type, name, Ls, env().getGrid(Ls)) | ||||
|  | ||||
| #define envTmpLat(...)\ | ||||
| MACRO_REDIRECT(__VA_ARGS__, envTmpLat5, envTmpLat4)(__VA_ARGS__) | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                            Module class                                    * | ||||
|  ******************************************************************************/ | ||||
| // base class | ||||
| class ModuleBase | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     ModuleBase(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~ModuleBase(void) = default; | ||||
|     // access | ||||
|     std::string getName(void) const; | ||||
|     // get factory registration name if available | ||||
|     virtual std::string getRegisteredName(void); | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void) = 0; | ||||
|     virtual std::vector<std::string> getReference(void) | ||||
|     { | ||||
|         return std::vector<std::string>(0); | ||||
|     }; | ||||
|     virtual std::vector<std::string> getOutput(void) = 0; | ||||
|     // parse parameters | ||||
|     virtual void parseParameters(XmlReader &reader, const std::string name) = 0; | ||||
|     virtual void saveParameters(XmlWriter &writer, const std::string name) = 0; | ||||
|     // setup | ||||
|     virtual void setup(void) {}; | ||||
|     virtual void execute(void) = 0; | ||||
|     // execution | ||||
|     void operator()(void); | ||||
| protected: | ||||
|     // environment shortcut | ||||
|     DEFINE_ENV_ALIAS; | ||||
|     // virtual machine shortcut | ||||
|     DEFINE_VM_ALIAS; | ||||
| private: | ||||
|     std::string name_; | ||||
| }; | ||||
|  | ||||
| // derived class, templating the parameter class | ||||
| template <typename P> | ||||
| class Module: public ModuleBase | ||||
| { | ||||
| public: | ||||
|     typedef P Par; | ||||
| public: | ||||
|     // constructor | ||||
|     Module(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~Module(void) = default; | ||||
|     // parse parameters | ||||
|     virtual void parseParameters(XmlReader &reader, const std::string name); | ||||
|     virtual void saveParameters(XmlWriter &writer, const std::string name); | ||||
|     // parameter access | ||||
|     const P & par(void) const; | ||||
|     void      setPar(const P &par); | ||||
| private: | ||||
|     P par_; | ||||
| }; | ||||
|  | ||||
| // no parameter type | ||||
| class NoPar {}; | ||||
|  | ||||
| template <> | ||||
| class Module<NoPar>: public ModuleBase | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     Module(const std::string name): ModuleBase(name) {}; | ||||
|     // destructor | ||||
|     virtual ~Module(void) = default; | ||||
|     // parse parameters (do nothing) | ||||
|     virtual void parseParameters(XmlReader &reader, const std::string name) {}; | ||||
|     virtual void saveParameters(XmlWriter &writer, const std::string name) | ||||
|     { | ||||
|         push(writer, "options"); | ||||
|         pop(writer); | ||||
|     }; | ||||
| }; | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                           Template implementation                          * | ||||
|  ******************************************************************************/ | ||||
| template <typename P> | ||||
| Module<P>::Module(const std::string name) | ||||
| : ModuleBase(name) | ||||
| {} | ||||
|  | ||||
| template <typename P> | ||||
| void Module<P>::parseParameters(XmlReader &reader, const std::string name) | ||||
| { | ||||
|     read(reader, name, par_); | ||||
| } | ||||
|  | ||||
| template <typename P> | ||||
| void Module<P>::saveParameters(XmlWriter &writer, const std::string name) | ||||
| { | ||||
|     write(writer, name, par_); | ||||
| } | ||||
|  | ||||
| template <typename P> | ||||
| const P & Module<P>::par(void) const | ||||
| { | ||||
|     return par_; | ||||
| } | ||||
|  | ||||
| template <typename P> | ||||
| void Module<P>::setPar(const P &par) | ||||
| { | ||||
|     par_ = par; | ||||
| } | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Module_hpp_ | ||||
							
								
								
									
										48
									
								
								extras/Hadrons/ModuleFactory.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								extras/Hadrons/ModuleFactory.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/ModuleFactory.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_ModuleFactory_hpp_ | ||||
| #define Hadrons_ModuleFactory_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Factory.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                            ModuleFactory                                   * | ||||
|  ******************************************************************************/ | ||||
| class ModuleFactory: public Factory<ModuleBase> | ||||
| { | ||||
|     SINGLETON_DEFCTOR(ModuleFactory) | ||||
| }; | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_ModuleFactory_hpp_ | ||||
							
								
								
									
										65
									
								
								extras/Hadrons/Modules.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								extras/Hadrons/Modules.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #include <Grid/Hadrons/Modules/MContraction/Baryon.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/Meson.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/DiscLoop.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/Gamma3pt.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/WardIdentity.hpp> | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp> | ||||
| #include <Grid/Hadrons/Modules/MFermion/GaugeProp.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSource/SeqGamma.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSource/Point.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSource/Wall.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSource/Z2.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSource/SeqConserved.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSink/Smear.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSink/Point.hpp> | ||||
| #include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp> | ||||
| #include <Grid/Hadrons/Modules/MGauge/Unit.hpp> | ||||
| #include <Grid/Hadrons/Modules/MGauge/Random.hpp> | ||||
| #include <Grid/Hadrons/Modules/MGauge/StochEm.hpp> | ||||
| #include <Grid/Hadrons/Modules/MGauge/FundtoHirep.hpp> | ||||
| #include <Grid/Hadrons/Modules/MUtilities/TestSeqGamma.hpp> | ||||
| #include <Grid/Hadrons/Modules/MUtilities/TestSeqConserved.hpp> | ||||
| #include <Grid/Hadrons/Modules/MLoop/NoiseLoop.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalar/Scalar.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp> | ||||
| #include <Grid/Hadrons/Modules/MAction/DWF.hpp> | ||||
| #include <Grid/Hadrons/Modules/MAction/Wilson.hpp> | ||||
| #include <Grid/Hadrons/Modules/MAction/WilsonClover.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalarSUN/Div.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalarSUN/TrMag.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalarSUN/TwoPoint.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalarSUN/TrPhi.hpp> | ||||
| #include <Grid/Hadrons/Modules/MIO/LoadNersc.hpp> | ||||
| #include <Grid/Hadrons/Modules/MIO/LoadBinary.hpp> | ||||
							
								
								
									
										135
									
								
								extras/Hadrons/Modules/MAction/DWF.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										135
									
								
								extras/Hadrons/Modules/MAction/DWF.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,135 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MAction/DWF.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MAction_DWF_hpp_ | ||||
| #define Hadrons_MAction_DWF_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     Domain wall quark action                               * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MAction) | ||||
|  | ||||
| class DWFPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(DWFPar, | ||||
|                                     std::string, gauge, | ||||
|                                     unsigned int, Ls, | ||||
|                                     double      , mass, | ||||
|                                     double      , M5, | ||||
|                                     std::string , boundary); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TDWF: public Module<DWFPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TDWF(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TDWF(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(DWF, TDWF<FIMPL>, MAction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                        DWF template implementation                         * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TDWF<FImpl>::TDWF(const std::string name) | ||||
| : Module<DWFPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TDWF<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().gauge}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TDWF<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TDWF<FImpl>::setup(void) | ||||
| { | ||||
|     LOG(Message) << "Setting up domain wall fermion matrix with m= " | ||||
|                  << par().mass << ", M5= " << par().M5 << " and Ls= " | ||||
|                  << par().Ls << " using gauge field '" << par().gauge << "'" | ||||
|                  << std::endl; | ||||
|     LOG(Message) << "Fermion boundary conditions: " << par().boundary | ||||
|                  << std::endl; | ||||
|                   | ||||
|     env().createGrid(par().Ls); | ||||
|     auto &U    = envGet(LatticeGaugeField, par().gauge); | ||||
|     auto &g4   = *env().getGrid(); | ||||
|     auto &grb4 = *env().getRbGrid(); | ||||
|     auto &g5   = *env().getGrid(par().Ls); | ||||
|     auto &grb5 = *env().getRbGrid(par().Ls); | ||||
|     std::vector<Complex> boundary = strToVec<Complex>(par().boundary); | ||||
|     typename DomainWallFermion<FImpl>::ImplParams implParams(boundary); | ||||
|     envCreateDerived(FMat, DomainWallFermion<FImpl>, getName(), par().Ls, U, g5, | ||||
|                      grb5, g4, grb4, par().mass, par().M5, implParams); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TDWF<FImpl>::execute(void) | ||||
| {} | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MAction_DWF_hpp_ | ||||
							
								
								
									
										128
									
								
								extras/Hadrons/Modules/MAction/Wilson.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								extras/Hadrons/Modules/MAction/Wilson.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,128 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MAction/Wilson.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MAction_Wilson_hpp_ | ||||
| #define Hadrons_MAction_Wilson_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                            TWilson quark action                            * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MAction) | ||||
|  | ||||
| class WilsonPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonPar, | ||||
|                                     std::string, gauge, | ||||
|                                     double     , mass, | ||||
|                                     std::string, boundary); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TWilson: public Module<WilsonPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TWilson(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TWilson(void) = default; | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Wilson, TWilson<FIMPL>, MAction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     TWilson template implementation                        * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TWilson<FImpl>::TWilson(const std::string name) | ||||
| : Module<WilsonPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWilson<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().gauge}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWilson<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWilson<FImpl>::setup(void) | ||||
| { | ||||
|     LOG(Message) << "Setting up TWilson fermion matrix with m= " << par().mass | ||||
|                  << " using gauge field '" << par().gauge << "'" << std::endl; | ||||
|     LOG(Message) << "Fermion boundary conditions: " << par().boundary | ||||
|                  << std::endl; | ||||
|                   | ||||
|     auto &U      = envGet(LatticeGaugeField, par().gauge); | ||||
|     auto &grid   = *env().getGrid(); | ||||
|     auto &gridRb = *env().getRbGrid(); | ||||
|     std::vector<Complex> boundary = strToVec<Complex>(par().boundary); | ||||
|     typename WilsonFermion<FImpl>::ImplParams implParams(boundary); | ||||
|     envCreateDerived(FMat, WilsonFermion<FImpl>, getName(), 1, U, grid, gridRb, | ||||
|                      par().mass, implParams); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWilson<FImpl>::execute() | ||||
| {} | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_Wilson_hpp_ | ||||
							
								
								
									
										153
									
								
								extras/Hadrons/Modules/MAction/WilsonClover.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								extras/Hadrons/Modules/MAction/WilsonClover.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,153 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MAction/Wilson.hpp | ||||
|  | ||||
| Copyright (C) 2015 | ||||
| Copyright (C) 2016 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MAction_WilsonClover_hpp_ | ||||
| #define Hadrons_MAction_WilsonClover_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                            TWilson quark action                            * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MAction) | ||||
|  | ||||
| class WilsonCloverPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonCloverPar, | ||||
|                                     std::string, gauge, | ||||
|                                     double     , mass, | ||||
| 				                    double     , csw_r, | ||||
| 				                    double     , csw_t, | ||||
| 				                    WilsonAnisotropyCoefficients ,clover_anisotropy, | ||||
|                                     std::string, boundary | ||||
| 				    ); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TWilsonClover: public Module<WilsonCloverPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TWilsonClover(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TWilsonClover(void) = default; | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(WilsonClover, TWilsonClover<FIMPL>, MAction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     TWilsonClover template implementation                        * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TWilsonClover<FImpl>::TWilsonClover(const std::string name) | ||||
| : Module<WilsonCloverPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWilsonClover<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().gauge}; | ||||
|  | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWilsonClover<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|  | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWilsonClover<FImpl>::setup(void) | ||||
| { | ||||
|     //unsigned int size; | ||||
|  | ||||
|     // size = 2*env().template lattice4dSize<typename FImpl::DoubledGaugeField>(); | ||||
|     // env().registerObject(getName(), size); | ||||
|  | ||||
|  | ||||
|     LOG(Message) << "Setting up TWilsonClover fermion matrix with m= " << par().mass | ||||
|                  << " using gauge field '" << par().gauge << "'" << std::endl; | ||||
|     LOG(Message) << "Fermion boundary conditions: " << par().boundary  | ||||
|                  << std::endl; | ||||
|     LOG(Message) << "Clover term csw_r: " << par().csw_r | ||||
|                  << " csw_t: " << par().csw_t | ||||
|                  << std::endl; | ||||
|     auto &U      = envGet(LatticeGaugeField, par().gauge); | ||||
|     auto &grid   = *env().getGrid(); | ||||
|     auto &gridRb = *env().getRbGrid(); | ||||
|     std::vector<Complex> boundary = strToVec<Complex>(par().boundary); | ||||
|     typename WilsonCloverFermion<FImpl>::ImplParams implParams(boundary); | ||||
|     envCreateDerived(FMat, WilsonCloverFermion<FImpl>, getName(), 1, U, grid, gridRb, par().mass, | ||||
| 						  par().csw_r, | ||||
| 						  par().csw_t, | ||||
| 					      par().clover_anisotropy, | ||||
| 						  implParams);  | ||||
|  | ||||
|  | ||||
|     //FMat *fMatPt = new WilsonCloverFermion<FImpl>(U, grid, gridRb, par().mass, | ||||
| 	//					  par().csw_r, | ||||
| 	//					  par().csw_t, | ||||
| 	//				      par().clover_anisotropy, | ||||
| 	//					  implParams); | ||||
|     //env().setObject(getName(), fMatPt); | ||||
|  | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWilsonClover<FImpl>::execute() | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_WilsonClover_hpp_ | ||||
							
								
								
									
										141
									
								
								extras/Hadrons/Modules/MContraction/Baryon.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								extras/Hadrons/Modules/MContraction/Baryon.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,141 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/Baryon.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_Baryon_hpp_ | ||||
| #define Hadrons_MContraction_Baryon_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                               Baryon                                       * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| class BaryonPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(BaryonPar, | ||||
|                                     std::string, q1, | ||||
|                                     std::string, q2, | ||||
|                                     std::string, q3, | ||||
|                                     std::string, output); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| class TBaryon: public Module<BaryonPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl1, 1); | ||||
|     FERM_TYPE_ALIASES(FImpl2, 2); | ||||
|     FERM_TYPE_ALIASES(FImpl3, 3); | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         std::vector<std::vector<std::vector<Complex>>>, corr); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TBaryon(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TBaryon(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Baryon, ARG(TBaryon<FIMPL, FIMPL, FIMPL>), MContraction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         TBaryon implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| TBaryon<FImpl1, FImpl2, FImpl3>::TBaryon(const std::string name) | ||||
| : Module<BaryonPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| std::vector<std::string> TBaryon<FImpl1, FImpl2, FImpl3>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> input = {par().q1, par().q2, par().q3}; | ||||
|      | ||||
|     return input; | ||||
| } | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| std::vector<std::string> TBaryon<FImpl1, FImpl2, FImpl3>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| void TBaryon<FImpl1, FImpl2, FImpl3>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing baryon contractions '" << getName() << "' using" | ||||
|                  << " quarks '" << par().q1 << "', '" << par().q2 << "', and '" | ||||
|                  << par().q3 << "'" << std::endl; | ||||
|      | ||||
|     ResultWriter writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto       &q1 = envGet(PropagatorField1, par().q1); | ||||
|     auto       &q2 = envGet(PropagatorField2, par().q2); | ||||
|     auto       &q3 = envGet(PropagatorField3, par().q2); | ||||
|     envGetTmp(LatticeComplex, c); | ||||
|     Result     result; | ||||
|      | ||||
|     // FIXME: do contractions | ||||
|      | ||||
|     // write(writer, "meson", result); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_Baryon_hpp_ | ||||
							
								
								
									
										146
									
								
								extras/Hadrons/Modules/MContraction/DiscLoop.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								extras/Hadrons/Modules/MContraction/DiscLoop.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,146 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/DiscLoop.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_DiscLoop_hpp_ | ||||
| #define Hadrons_MContraction_DiscLoop_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                DiscLoop                                    * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| class DiscLoopPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(DiscLoopPar, | ||||
|                                     std::string,    q_loop, | ||||
|                                     Gamma::Algebra, gamma, | ||||
|                                     std::string,    output); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TDiscLoop: public Module<DiscLoopPar> | ||||
| { | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         Gamma::Algebra, gamma, | ||||
|                                         std::vector<Complex>, corr); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TDiscLoop(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TDiscLoop(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(DiscLoop, TDiscLoop<FIMPL>, MContraction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       TDiscLoop implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TDiscLoop<FImpl>::TDiscLoop(const std::string name) | ||||
| : Module<DiscLoopPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TDiscLoop<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q_loop}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TDiscLoop<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TDiscLoop<FImpl>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TDiscLoop<FImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing disconnected loop contraction '" << getName()  | ||||
|                  << "' using '" << par().q_loop << "' with " << par().gamma  | ||||
|                  << " insertion." << std::endl; | ||||
|  | ||||
|     ResultWriter          writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                  &q_loop = envGet(PropagatorField, par().q_loop); | ||||
|     Gamma                 gamma(par().gamma); | ||||
|     std::vector<TComplex> buf; | ||||
|     Result                result; | ||||
|  | ||||
|     envGetTmp(LatticeComplex, c); | ||||
|     c = trace(gamma*q_loop); | ||||
|     sliceSum(c, buf, Tp); | ||||
|  | ||||
|     result.gamma = par().gamma; | ||||
|     result.corr.resize(buf.size()); | ||||
|     for (unsigned int t = 0; t < buf.size(); ++t) | ||||
|     { | ||||
|         result.corr[t] = TensorRemove(buf[t]); | ||||
|     } | ||||
|  | ||||
|     write(writer, "disc", result); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_DiscLoop_hpp_ | ||||
							
								
								
									
										186
									
								
								extras/Hadrons/Modules/MContraction/Gamma3pt.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								extras/Hadrons/Modules/MContraction/Gamma3pt.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,186 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/Gamma3pt.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_Gamma3pt_hpp_ | ||||
| #define Hadrons_MContraction_Gamma3pt_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|  * 3pt contraction with gamma matrix insertion. | ||||
|  * | ||||
|  * Schematic: | ||||
|  * | ||||
|  *             q2           q3 | ||||
|  *        /----<------*------<----¬ | ||||
|  *       /          gamma          \ | ||||
|  *      /                           \ | ||||
|  *   i *                            * f | ||||
|  *      \                          / | ||||
|  *       \                        / | ||||
|  *        \----------->----------/ | ||||
|  *                   q1 | ||||
|  * | ||||
|  *      trace(g5*q1*adj(q2)*g5*gamma*q3) | ||||
|  *  | ||||
|  *  options: | ||||
|  *   - q1: sink smeared propagator, source at i | ||||
|  *   - q2: propagator, source at i | ||||
|  *   - q3: propagator, source at f | ||||
|  *   - gamma: gamma matrix to insert | ||||
|  *   - tSnk: sink position for propagator q1. | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                               Gamma3pt                                     * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| class Gamma3ptPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(Gamma3ptPar, | ||||
|                                     std::string,    q1, | ||||
|                                     std::string,    q2, | ||||
|                                     std::string,    q3, | ||||
|                                     Gamma::Algebra, gamma, | ||||
|                                     unsigned int,   tSnk, | ||||
|                                     std::string,    output); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| class TGamma3pt: public Module<Gamma3ptPar> | ||||
| { | ||||
|     FERM_TYPE_ALIASES(FImpl1, 1); | ||||
|     FERM_TYPE_ALIASES(FImpl2, 2); | ||||
|     FERM_TYPE_ALIASES(FImpl3, 3); | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         Gamma::Algebra, gamma, | ||||
|                                         std::vector<Complex>, corr); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TGamma3pt(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TGamma3pt(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Gamma3pt, ARG(TGamma3pt<FIMPL, FIMPL, FIMPL>), MContraction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       TGamma3pt implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| TGamma3pt<FImpl1, FImpl2, FImpl3>::TGamma3pt(const std::string name) | ||||
| : Module<Gamma3ptPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| std::vector<std::string> TGamma3pt<FImpl1, FImpl2, FImpl3>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q1, par().q2, par().q3}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| std::vector<std::string> TGamma3pt<FImpl1, FImpl2, FImpl3>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| void TGamma3pt<FImpl1, FImpl2, FImpl3>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2, typename FImpl3> | ||||
| void TGamma3pt<FImpl1, FImpl2, FImpl3>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing 3pt contractions '" << getName() << "' using" | ||||
|                  << " quarks '" << par().q1 << "', '" << par().q2 << "' and '" | ||||
|                  << par().q3 << "', with " << par().gamma << " insertion."  | ||||
|                  << std::endl; | ||||
|  | ||||
|     // Initialise variables. q2 and q3 are normal propagators, q1 may be  | ||||
|     // sink smeared. | ||||
|     ResultWriter          writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                  &q1 = envGet(SlicedPropagator1, par().q1); | ||||
|     auto                  &q2 = envGet(PropagatorField2, par().q2); | ||||
|     auto                  &q3 = envGet(PropagatorField2, par().q3); | ||||
|     Gamma                 g5(Gamma::Algebra::Gamma5); | ||||
|     Gamma                 gamma(par().gamma); | ||||
|     std::vector<TComplex> buf; | ||||
|     Result                result; | ||||
|      | ||||
|     // Extract relevant timeslice of sinked propagator q1, then contract & | ||||
|     // sum over all spacial positions of gamma insertion. | ||||
|     SitePropagator1 q1Snk = q1[par().tSnk]; | ||||
|     envGetTmp(LatticeComplex, c); | ||||
|     c = trace(g5*q1Snk*adj(q2)*(g5*gamma)*q3); | ||||
|     sliceSum(c, buf, Tp); | ||||
|  | ||||
|     result.gamma = par().gamma; | ||||
|     result.corr.resize(buf.size()); | ||||
|     for (unsigned int t = 0; t < buf.size(); ++t) | ||||
|     { | ||||
|         result.corr[t] = TensorRemove(buf[t]); | ||||
|     } | ||||
|  | ||||
|     write(writer, "gamma3pt", result); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_Gamma3pt_hpp_ | ||||
							
								
								
									
										249
									
								
								extras/Hadrons/Modules/MContraction/Meson.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								extras/Hadrons/Modules/MContraction/Meson.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,249 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/Meson.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_Meson_hpp_ | ||||
| #define Hadrons_MContraction_Meson_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Meson contractions | ||||
|  ----------------------------- | ||||
|   | ||||
|  * options: | ||||
|  - q1: input propagator 1 (string) | ||||
|  - q2: input propagator 2 (string) | ||||
|  - gammas: gamma products to insert at sink & source, pairs of gamma matrices  | ||||
|            (space-separated strings) in angled brackets (i.e. <g_sink g_src>), | ||||
|            in a sequence (e.g. "<Gamma5 Gamma5><Gamma5 GammaT>"). | ||||
|  | ||||
|            Special values: "all" - perform all possible contractions. | ||||
|  - sink: module to compute the sink to use in contraction (string). | ||||
| */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                TMeson                                       * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| typedef std::pair<Gamma::Algebra, Gamma::Algebra> GammaPair; | ||||
|  | ||||
| class MesonPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar, | ||||
|                                     std::string, q1, | ||||
|                                     std::string, q2, | ||||
|                                     std::string, gammas, | ||||
|                                     std::string, sink, | ||||
|                                     std::string, output); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| class TMeson: public Module<MesonPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl1, 1); | ||||
|     FERM_TYPE_ALIASES(FImpl2, 2); | ||||
|     FERM_TYPE_ALIASES(ScalarImplCR, Scalar); | ||||
|     SINK_TYPE_ALIASES(Scalar); | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         Gamma::Algebra, gamma_snk, | ||||
|                                         Gamma::Algebra, gamma_src, | ||||
|                                         std::vector<Complex>, corr); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TMeson(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TMeson(void) = default; | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     virtual void parseGammaString(std::vector<GammaPair> &gammaList); | ||||
| protected: | ||||
|     // execution | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Meson, ARG(TMeson<FIMPL, FIMPL>), MContraction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                           TMeson implementation                            * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| TMeson<FImpl1, FImpl2>::TMeson(const std::string name) | ||||
| : Module<MesonPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| std::vector<std::string> TMeson<FImpl1, FImpl2>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> input = {par().q1, par().q2, par().sink}; | ||||
|      | ||||
|     return input; | ||||
| } | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| std::vector<std::string> TMeson<FImpl1, FImpl2>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> output = {}; | ||||
|      | ||||
|     return output; | ||||
| } | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| void TMeson<FImpl1, FImpl2>::parseGammaString(std::vector<GammaPair> &gammaList) | ||||
| { | ||||
|     gammaList.clear(); | ||||
|     // Determine gamma matrices to insert at source/sink. | ||||
|     if (par().gammas.compare("all") == 0) | ||||
|     { | ||||
|         // Do all contractions. | ||||
|         for (unsigned int i = 1; i < Gamma::nGamma; i += 2) | ||||
|         { | ||||
|             for (unsigned int j = 1; j < Gamma::nGamma; j += 2) | ||||
|             { | ||||
|                 gammaList.push_back(std::make_pair((Gamma::Algebra)i,  | ||||
|                                                    (Gamma::Algebra)j)); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         // Parse individual contractions from input string. | ||||
|         gammaList = strToVec<GammaPair>(par().gammas); | ||||
|     }  | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| void TMeson<FImpl1, FImpl2>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| #define mesonConnected(q1, q2, gSnk, gSrc) \ | ||||
| (g5*(gSnk))*(q1)*(adj(gSrc)*g5)*adj(q2) | ||||
|  | ||||
| template <typename FImpl1, typename FImpl2> | ||||
| void TMeson<FImpl1, FImpl2>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing meson contractions '" << getName() << "' using" | ||||
|                  << " quarks '" << par().q1 << "' and '" << par().q2 << "'" | ||||
|                  << std::endl; | ||||
|      | ||||
|     ResultWriter           writer(RESULT_FILE_NAME(par().output)); | ||||
|     std::vector<TComplex>  buf; | ||||
|     std::vector<Result>    result; | ||||
|     Gamma                  g5(Gamma::Algebra::Gamma5); | ||||
|     std::vector<GammaPair> gammaList; | ||||
|     int                    nt = env().getDim(Tp); | ||||
|      | ||||
|     parseGammaString(gammaList); | ||||
|     result.resize(gammaList.size()); | ||||
|     for (unsigned int i = 0; i < result.size(); ++i) | ||||
|     { | ||||
|         result[i].gamma_snk = gammaList[i].first; | ||||
|         result[i].gamma_src = gammaList[i].second; | ||||
|         result[i].corr.resize(nt); | ||||
|     } | ||||
|     if (envHasType(SlicedPropagator1, par().q1) and | ||||
|         envHasType(SlicedPropagator2, par().q2)) | ||||
|     { | ||||
|         auto &q1 = envGet(SlicedPropagator1, par().q1); | ||||
|         auto &q2 = envGet(SlicedPropagator2, par().q2); | ||||
|          | ||||
|         LOG(Message) << "(propagator already sinked)" << std::endl; | ||||
|         for (unsigned int i = 0; i < result.size(); ++i) | ||||
|         { | ||||
|             Gamma gSnk(gammaList[i].first); | ||||
|             Gamma gSrc(gammaList[i].second); | ||||
|              | ||||
|             for (unsigned int t = 0; t < buf.size(); ++t) | ||||
|             { | ||||
|                 result[i].corr[t] = TensorRemove(trace(mesonConnected(q1[t], q2[t], gSnk, gSrc))); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         auto &q1 = envGet(PropagatorField1, par().q1); | ||||
|         auto &q2 = envGet(PropagatorField2, par().q2); | ||||
|          | ||||
|         envGetTmp(LatticeComplex, c); | ||||
|         LOG(Message) << "(using sink '" << par().sink << "')" << std::endl; | ||||
|         for (unsigned int i = 0; i < result.size(); ++i) | ||||
|         { | ||||
|             Gamma       gSnk(gammaList[i].first); | ||||
|             Gamma       gSrc(gammaList[i].second); | ||||
|             std::string ns; | ||||
|                  | ||||
|             ns = vm().getModuleNamespace(env().getObjectModule(par().sink)); | ||||
|             if (ns == "MSource") | ||||
|             { | ||||
|                 PropagatorField1 &sink = envGet(PropagatorField1, par().sink); | ||||
|                  | ||||
|                 c = trace(mesonConnected(q1, q2, gSnk, gSrc)*sink); | ||||
|                 sliceSum(c, buf, Tp); | ||||
|             } | ||||
|             else if (ns == "MSink") | ||||
|             { | ||||
|                 SinkFnScalar &sink = envGet(SinkFnScalar, par().sink); | ||||
|                  | ||||
|                 c   = trace(mesonConnected(q1, q2, gSnk, gSrc)); | ||||
|                 buf = sink(c); | ||||
|             } | ||||
|             for (unsigned int t = 0; t < buf.size(); ++t) | ||||
|             { | ||||
|                 result[i].corr[t] = TensorRemove(buf[t]); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     write(writer, "meson", result); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_Meson_hpp_ | ||||
							
								
								
									
										224
									
								
								extras/Hadrons/Modules/MContraction/WardIdentity.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										224
									
								
								extras/Hadrons/Modules/MContraction/WardIdentity.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,224 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WardIdentity.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_WardIdentity_hpp_ | ||||
| #define Hadrons_MContraction_WardIdentity_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   Ward Identity contractions | ||||
|  ----------------------------- | ||||
|   | ||||
|  * options: | ||||
|  - q:          propagator, 5D if available (string) | ||||
|  - action:     action module used for propagator solution (string) | ||||
|  - mass:       mass of quark (double) | ||||
|  - test_axial: whether or not to test PCAC relation. | ||||
| */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                              WardIdentity                                  * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| class WardIdentityPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(WardIdentityPar, | ||||
|                                     std::string, q, | ||||
|                                     std::string, action, | ||||
|                                     double,      mass, | ||||
|                                     bool,        test_axial); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TWardIdentity: public Module<WardIdentityPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TWardIdentity(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TWardIdentity(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     unsigned int Ls_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(WardIdentity, TWardIdentity<FIMPL>, MContraction); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     TWardIdentity implementation                           * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TWardIdentity<FImpl>::TWardIdentity(const std::string name) | ||||
| : Module<WardIdentityPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWardIdentity<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().action}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWardIdentity<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWardIdentity<FImpl>::setup(void) | ||||
| { | ||||
|     Ls_ = env().getObjectLs(par().q); | ||||
|     if (Ls_ != env().getObjectLs(par().action)) | ||||
|     { | ||||
|         HADRON_ERROR(Size, "Ls mismatch between quark action and propagator"); | ||||
|     } | ||||
|     envTmpLat(PropagatorField, "tmp"); | ||||
|     envTmpLat(PropagatorField, "vector_WI"); | ||||
|     if (par().test_axial) | ||||
|     { | ||||
|         envTmpLat(PropagatorField, "psi"); | ||||
|         envTmpLat(LatticeComplex,  "PP"); | ||||
|         envTmpLat(LatticeComplex,  "axial_defect"); | ||||
|         envTmpLat(LatticeComplex,  "PJ5q"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWardIdentity<FImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Performing Ward Identity checks for quark '" << par().q | ||||
|                  << "'." << std::endl; | ||||
|  | ||||
|     auto  &q   = envGet(PropagatorField, par().q); | ||||
|     auto  &act = envGet(FMat, par().action); | ||||
|     Gamma g5(Gamma::Algebra::Gamma5); | ||||
|  | ||||
|     // Compute D_mu V_mu, D here is backward derivative. | ||||
|     envGetTmp(PropagatorField, tmp); | ||||
|     envGetTmp(PropagatorField, vector_WI); | ||||
|     vector_WI    = zero; | ||||
|     for (unsigned int mu = 0; mu < Nd; ++mu) | ||||
|     { | ||||
|         act.ContractConservedCurrent(q, q, tmp, Current::Vector, mu); | ||||
|         tmp -= Cshift(tmp, mu, -1); | ||||
|         vector_WI += tmp; | ||||
|     } | ||||
|  | ||||
|     // Test ward identity D_mu V_mu = 0; | ||||
|     LOG(Message) << "Vector Ward Identity check Delta_mu V_mu = "  | ||||
|                  << norm2(vector_WI) << std::endl; | ||||
|  | ||||
|     if (par().test_axial) | ||||
|     { | ||||
|         envGetTmp(PropagatorField, psi); | ||||
|         envGetTmp(LatticeComplex, PP); | ||||
|         envGetTmp(LatticeComplex, axial_defect); | ||||
|         envGetTmp(LatticeComplex, PJ5q); | ||||
|         std::vector<TComplex> axial_buf; | ||||
|  | ||||
|         // Compute <P|D_mu A_mu>, D is backwards derivative. | ||||
|         axial_defect = zero; | ||||
|         for (unsigned int mu = 0; mu < Nd; ++mu) | ||||
|         { | ||||
|             act.ContractConservedCurrent(q, q, tmp, Current::Axial, mu); | ||||
|             tmp -= Cshift(tmp, mu, -1); | ||||
|             axial_defect += trace(g5*tmp); | ||||
|         } | ||||
|  | ||||
|         // Get <P|J5q> for 5D (zero for 4D) and <P|P>. | ||||
|         PJ5q = zero; | ||||
|         if (Ls_ > 1) | ||||
|         { | ||||
|             // <P|P> | ||||
|             ExtractSlice(tmp, q, 0, 0); | ||||
|             psi  = 0.5 * (tmp - g5*tmp); | ||||
|             ExtractSlice(tmp, q, Ls_ - 1, 0); | ||||
|             psi += 0.5 * (tmp + g5*tmp); | ||||
|             PP = trace(adj(psi)*psi); | ||||
|  | ||||
|             // <P|5Jq> | ||||
|             ExtractSlice(tmp, q, Ls_/2 - 1, 0); | ||||
|             psi  = 0.5 * (tmp + g5*tmp); | ||||
|             ExtractSlice(tmp, q, Ls_/2, 0); | ||||
|             psi += 0.5 * (tmp - g5*tmp); | ||||
|             PJ5q = trace(adj(psi)*psi); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             PP = trace(adj(q)*q); | ||||
|         } | ||||
|  | ||||
|         // Test ward identity <P|D_mu A_mu> = 2m<P|P> + 2<P|J5q> | ||||
|         LOG(Message) << "|D_mu A_mu|^2 = " << norm2(axial_defect) << std::endl; | ||||
|         LOG(Message) << "|PP|^2        = " << norm2(PP) << std::endl; | ||||
|         LOG(Message) << "|PJ5q|^2      = " << norm2(PJ5q) << std::endl; | ||||
|         LOG(Message) << "Axial Ward Identity defect Delta_mu A_mu = " | ||||
|                      << norm2(axial_defect) << std::endl; | ||||
|      | ||||
|         // Axial defect by timeslice. | ||||
|         axial_defect -= 2.*(par().mass*PP + PJ5q); | ||||
|         LOG(Message) << "Check Axial defect by timeslice" << std::endl; | ||||
|         sliceSum(axial_defect, axial_buf, Tp); | ||||
|         for (int t = 0; t < axial_buf.size(); ++t) | ||||
|         { | ||||
|             LOG(Message) << "t = " << t << ": "  | ||||
|                          << TensorRemove(axial_buf[t]) << std::endl; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_WardIdentity_hpp_ | ||||
							
								
								
									
										118
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,118 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_WeakHamiltonian_hpp_ | ||||
| #define Hadrons_MContraction_WeakHamiltonian_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         WeakHamiltonian                                    * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| /******************************************************************************* | ||||
|  * Utilities for contractions involving the Weak Hamiltonian. | ||||
|  ******************************************************************************/ | ||||
| //// Sum and store correlator. | ||||
| #define MAKE_DIAG(exp, buf, res, n)\ | ||||
| sliceSum(exp, buf, Tp);\ | ||||
| res.name = (n);\ | ||||
| res.corr.resize(buf.size());\ | ||||
| for (unsigned int t = 0; t < buf.size(); ++t)\ | ||||
| {\ | ||||
|     res.corr[t] = TensorRemove(buf[t]);\ | ||||
| } | ||||
|  | ||||
| //// Contraction of mu index: use 'mu' variable in exp. | ||||
| #define SUM_MU(buf,exp)\ | ||||
| buf = zero;\ | ||||
| for (unsigned int mu = 0; mu < ndim; ++mu)\ | ||||
| {\ | ||||
|     buf += exp;\ | ||||
| } | ||||
|  | ||||
| enum  | ||||
| { | ||||
|   i_V = 0, | ||||
|   i_A = 1, | ||||
|   n_i = 2 | ||||
| }; | ||||
|  | ||||
| class WeakHamiltonianPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(WeakHamiltonianPar, | ||||
|                                     std::string, q1, | ||||
|                                     std::string, q2, | ||||
|                                     std::string, q3, | ||||
|                                     std::string, q4, | ||||
|                                     unsigned int, tSnk, | ||||
|                                     std::string, output); | ||||
| }; | ||||
|  | ||||
| #define MAKE_WEAK_MODULE(modname)\ | ||||
| class T##modname: public Module<WeakHamiltonianPar>\ | ||||
| {\ | ||||
| public:\ | ||||
|     FERM_TYPE_ALIASES(FIMPL,)\ | ||||
|     class Result: Serializable\ | ||||
|     {\ | ||||
|     public:\ | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result,\ | ||||
|                                         std::string, name,\ | ||||
|                                         std::vector<Complex>, corr);\ | ||||
|     };\ | ||||
| public:\ | ||||
|     /* constructor */ \ | ||||
|     T##modname(const std::string name);\ | ||||
|     /* destructor */ \ | ||||
|     virtual ~T##modname(void) = default;\ | ||||
|     /* dependency relation */ \ | ||||
|     virtual std::vector<std::string> getInput(void);\ | ||||
|     virtual std::vector<std::string> getOutput(void);\ | ||||
| public:\ | ||||
|     std::vector<std::string> VA_label = {"V", "A"};\ | ||||
| protected:\ | ||||
|     /* setup */ \ | ||||
|     virtual void setup(void);\ | ||||
|     /* execution */ \ | ||||
|     virtual void execute(void);\ | ||||
| };\ | ||||
| MODULE_REGISTER_NS(modname, T##modname, MContraction); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_WeakHamiltonian_hpp_ | ||||
							
								
								
									
										151
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,151 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MContraction; | ||||
|  | ||||
| /* | ||||
|  * Weak Hamiltonian current-current contractions, Eye-type. | ||||
|  *  | ||||
|  * These contractions are generated by the Q1 and Q2 operators in the physical | ||||
|  * basis (see e.g. Fig 3 of arXiv:1507.03094). | ||||
|  *  | ||||
|  * Schematics:        q4                 |                   | ||||
|  *                  /-<-¬                |                              | ||||
|  *                 /     \               |             q2           q3 | ||||
|  *                 \     /               |        /----<------*------<----¬                         | ||||
|  *            q2    \   /    q3          |       /          /-*-¬          \ | ||||
|  *       /-----<-----* *-----<----¬      |      /          /     \          \ | ||||
|  *    i *            H_W           * f   |   i *           \     /  q4      * f | ||||
|  *       \                        /      |      \           \->-/          /    | ||||
|  *        \                      /       |       \                        /        | ||||
|  *         \---------->---------/        |        \----------->----------/         | ||||
|  *                   q1                  |                   q1                   | ||||
|  *                                       | | ||||
|  *                Saucer (S)             |                  Eye (E) | ||||
|  *  | ||||
|  * S: trace(q3*g5*q1*adj(q2)*g5*gL[mu][p_1]*q4*gL[mu][p_2]) | ||||
|  * E: trace(q3*g5*q1*adj(q2)*g5*gL[mu][p_1])*trace(q4*gL[mu][p_2]) | ||||
|  *  | ||||
|  * Note q1 must be sink smeared. | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                  TWeakHamiltonianEye implementation                        * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TWeakHamiltonianEye::TWeakHamiltonianEye(const std::string name) | ||||
| : Module<WeakHamiltonianPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TWeakHamiltonianEye::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TWeakHamiltonianEye::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TWeakHamiltonianEye::setup(void) | ||||
| { | ||||
|     unsigned int ndim = env().getNd(); | ||||
|  | ||||
|     envTmpLat(LatticeComplex,  "expbuf"); | ||||
|     envTmpLat(PropagatorField, "tmp1"); | ||||
|     envTmpLat(LatticeComplex,  "tmp2"); | ||||
|     envTmp(std::vector<PropagatorField>, "S_body", 1, ndim, PropagatorField(env().getGrid())); | ||||
|     envTmp(std::vector<PropagatorField>, "S_loop", 1, ndim, PropagatorField(env().getGrid())); | ||||
|     envTmp(std::vector<LatticeComplex>,  "E_body", 1, ndim, LatticeComplex(env().getGrid())); | ||||
|     envTmp(std::vector<LatticeComplex>,  "E_loop", 1, ndim, LatticeComplex(env().getGrid())); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TWeakHamiltonianEye::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing Weak Hamiltonian (Eye type) contractions '"  | ||||
|                  << getName() << "' using quarks '" << par().q1 << "', '"  | ||||
|                  << par().q2 << ", '" << par().q3 << "' and '" << par().q4  | ||||
|                  << "'." << std::endl; | ||||
|  | ||||
|     ResultWriter           writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                   &q1 = envGet(SlicedPropagator, par().q1); | ||||
|     auto                   &q2 = envGet(PropagatorField, par().q2); | ||||
|     auto                   &q3 = envGet(PropagatorField, par().q3); | ||||
|     auto                   &q4 = envGet(PropagatorField, par().q4); | ||||
|     Gamma                  g5  = Gamma(Gamma::Algebra::Gamma5); | ||||
|     std::vector<TComplex>  corrbuf; | ||||
|     std::vector<Result>    result(n_eye_diag); | ||||
|     unsigned int ndim    = env().getNd(); | ||||
|  | ||||
|     envGetTmp(LatticeComplex,               expbuf);  | ||||
|     envGetTmp(PropagatorField,              tmp1); | ||||
|     envGetTmp(LatticeComplex,               tmp2); | ||||
|     envGetTmp(std::vector<PropagatorField>, S_body); | ||||
|     envGetTmp(std::vector<PropagatorField>, S_loop); | ||||
|     envGetTmp(std::vector<LatticeComplex>,  E_body); | ||||
|     envGetTmp(std::vector<LatticeComplex>,  E_loop); | ||||
|  | ||||
|     // Get sink timeslice of q1. | ||||
|     SitePropagator q1Snk = q1[par().tSnk]; | ||||
|  | ||||
|     // Setup for S-type contractions. | ||||
|     for (int mu = 0; mu < ndim; ++mu) | ||||
|     { | ||||
|         S_body[mu] = MAKE_SE_BODY(q1Snk, q2, q3, GammaL(Gamma::gmu[mu])); | ||||
|         S_loop[mu] = MAKE_SE_LOOP(q4, GammaL(Gamma::gmu[mu])); | ||||
|     } | ||||
|  | ||||
|     // Perform S-type contractions.     | ||||
|     SUM_MU(expbuf, trace(S_body[mu]*S_loop[mu])) | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[S_diag], "HW_S") | ||||
|  | ||||
|     // Recycle sub-expressions for E-type contractions. | ||||
|     for (unsigned int mu = 0; mu < ndim; ++mu) | ||||
|     { | ||||
|         E_body[mu] = trace(S_body[mu]); | ||||
|         E_loop[mu] = trace(S_loop[mu]); | ||||
|     } | ||||
|  | ||||
|     // Perform E-type contractions. | ||||
|     SUM_MU(expbuf, E_body[mu]*E_loop[mu]) | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[E_diag], "HW_E") | ||||
|  | ||||
|     write(writer, "HW_Eye", result); | ||||
| } | ||||
							
								
								
									
										59
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,59 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_WeakHamiltonianEye_hpp_ | ||||
| #define Hadrons_MContraction_WeakHamiltonianEye_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         WeakHamiltonianEye                                 * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| enum | ||||
| { | ||||
|     S_diag = 0, | ||||
|     E_diag = 1, | ||||
|     n_eye_diag = 2 | ||||
| }; | ||||
|  | ||||
| // Saucer and Eye subdiagram contractions. | ||||
| #define MAKE_SE_BODY(Q_1, Q_2, Q_3, gamma) (Q_3*g5*Q_1*adj(Q_2)*g5*gamma) | ||||
| #define MAKE_SE_LOOP(Q_loop, gamma) (Q_loop*gamma) | ||||
|  | ||||
| MAKE_WEAK_MODULE(WeakHamiltonianEye) | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_WeakHamiltonianEye_hpp_ | ||||
							
								
								
									
										148
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,148 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MContraction; | ||||
|  | ||||
| /* | ||||
|  * Weak Hamiltonian current-current contractions, Non-Eye-type. | ||||
|  *  | ||||
|  * These contractions are generated by the Q1 and Q2 operators in the physical | ||||
|  * basis (see e.g. Fig 3 of arXiv:1507.03094). | ||||
|  *  | ||||
|  * Schematic:      | ||||
|  *            q2             q3          |           q2              q3 | ||||
|  *          /--<--¬       /--<--¬        |        /--<--¬         /--<--¬        | ||||
|  *         /       \     /       \       |       /       \       /       \       | ||||
|  *        /         \   /         \      |      /         \     /         \      | ||||
|  *       /           \ /           \     |     /           \   /           \     | ||||
|  *    i *             * H_W         *  f |  i *             * * H_W         * f  | ||||
|  *      \             *             |    |     \           /   \           / | ||||
|  *       \           / \           /     |      \         /     \         /     | ||||
|  *        \         /   \         /      |       \       /       \       /   | ||||
|  *         \       /     \       /       |        \-->--/         \-->--/       | ||||
|  *          \-->--/       \-->--/        |          q1               q4  | ||||
|  *            q1             q4          | | ||||
|  *                Connected (C)          |                 Wing (W) | ||||
|  * | ||||
|  * C: trace(q1*adj(q2)*g5*gL[mu]*q3*adj(q4)*g5*gL[mu]) | ||||
|  * W: trace(q1*adj(q2)*g5*gL[mu])*trace(q3*adj(q4)*g5*gL[mu]) | ||||
|  *  | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                  TWeakHamiltonianNonEye implementation                     * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TWeakHamiltonianNonEye::TWeakHamiltonianNonEye(const std::string name) | ||||
| : Module<WeakHamiltonianPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TWeakHamiltonianNonEye::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TWeakHamiltonianNonEye::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TWeakHamiltonianNonEye::setup(void) | ||||
| { | ||||
|     unsigned int ndim = env().getNd(); | ||||
|  | ||||
|     envTmpLat(LatticeComplex,  "expbuf"); | ||||
|     envTmpLat(PropagatorField, "tmp1"); | ||||
|     envTmpLat(LatticeComplex,  "tmp2"); | ||||
|     envTmp(std::vector<PropagatorField>, "C_i_side_loop", 1, ndim, PropagatorField(env().getGrid())); | ||||
|     envTmp(std::vector<PropagatorField>, "C_f_side_loop", 1, ndim, PropagatorField(env().getGrid())); | ||||
|     envTmp(std::vector<LatticeComplex>,  "W_i_side_loop", 1, ndim, LatticeComplex(env().getGrid())); | ||||
|     envTmp(std::vector<LatticeComplex>,  "W_f_side_loop", 1, ndim, LatticeComplex(env().getGrid())); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TWeakHamiltonianNonEye::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing Weak Hamiltonian (Non-Eye type) contractions '"  | ||||
|                  << getName() << "' using quarks '" << par().q1 << "', '"  | ||||
|                  << par().q2 << ", '" << par().q3 << "' and '" << par().q4  | ||||
|                  << "'." << std::endl; | ||||
|      | ||||
|     ResultWriter          writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                  &q1 = envGet(PropagatorField, par().q1); | ||||
|     auto                  &q2 = envGet(PropagatorField, par().q2); | ||||
|     auto                  &q3 = envGet(PropagatorField, par().q3); | ||||
|     auto                  &q4 = envGet(PropagatorField, par().q4); | ||||
|     Gamma                 g5  = Gamma(Gamma::Algebra::Gamma5); | ||||
|     std::vector<TComplex> corrbuf; | ||||
|     std::vector<Result>   result(n_noneye_diag);  | ||||
|     unsigned int          ndim = env().getNd(); | ||||
|  | ||||
|     envGetTmp(LatticeComplex,               expbuf);  | ||||
|     envGetTmp(PropagatorField,              tmp1); | ||||
|     envGetTmp(LatticeComplex,               tmp2); | ||||
|     envGetTmp(std::vector<PropagatorField>, C_i_side_loop); | ||||
|     envGetTmp(std::vector<PropagatorField>, C_f_side_loop); | ||||
|     envGetTmp(std::vector<LatticeComplex>,  W_i_side_loop); | ||||
|     envGetTmp(std::vector<LatticeComplex>,  W_f_side_loop); | ||||
|  | ||||
|     // Setup for C-type contractions. | ||||
|     for (int mu = 0; mu < ndim; ++mu) | ||||
|     { | ||||
|         C_i_side_loop[mu] = MAKE_CW_SUBDIAG(q1, q2, GammaL(Gamma::gmu[mu])); | ||||
|         C_f_side_loop[mu] = MAKE_CW_SUBDIAG(q3, q4, GammaL(Gamma::gmu[mu])); | ||||
|     } | ||||
|  | ||||
|     // Perform C-type contractions.     | ||||
|     SUM_MU(expbuf, trace(C_i_side_loop[mu]*C_f_side_loop[mu])) | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[C_diag], "HW_C") | ||||
|  | ||||
|     // Recycle sub-expressions for W-type contractions. | ||||
|     for (unsigned int mu = 0; mu < ndim; ++mu) | ||||
|     { | ||||
|         W_i_side_loop[mu] = trace(C_i_side_loop[mu]); | ||||
|         W_f_side_loop[mu] = trace(C_f_side_loop[mu]); | ||||
|     } | ||||
|  | ||||
|     // Perform W-type contractions. | ||||
|     SUM_MU(expbuf, W_i_side_loop[mu]*W_f_side_loop[mu]) | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[W_diag], "HW_W") | ||||
|  | ||||
|     write(writer, "HW_NonEye", result); | ||||
| } | ||||
| @@ -0,0 +1,58 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ | ||||
| #define Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         WeakHamiltonianNonEye                              * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| enum | ||||
| { | ||||
|     W_diag = 0, | ||||
|     C_diag = 1, | ||||
|     n_noneye_diag = 2 | ||||
| }; | ||||
|  | ||||
| // Wing and Connected subdiagram contractions | ||||
| #define MAKE_CW_SUBDIAG(Q_1, Q_2, gamma) (Q_1*adj(Q_2)*g5*gamma) | ||||
|  | ||||
| MAKE_WEAK_MODULE(WeakHamiltonianNonEye) | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ | ||||
							
								
								
									
										142
									
								
								extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,142 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MContraction; | ||||
|  | ||||
| /* | ||||
|  * Weak Hamiltonian + current contractions, disconnected topology for neutral  | ||||
|  * mesons. | ||||
|  *  | ||||
|  * These contractions are generated by operators Q_1,...,10 of the dS=1 Weak | ||||
|  * Hamiltonian in the physical basis and an additional current J (see e.g.  | ||||
|  * Fig 11 of arXiv:1507.03094). | ||||
|  *  | ||||
|  * Schematic: | ||||
|  *                         | ||||
|  *           q2          q4             q3 | ||||
|  *       /--<--¬     /---<--¬       /---<--¬ | ||||
|  *     /         \ /         \     /        \ | ||||
|  *  i *           * H_W      |  J *          * f | ||||
|  *     \         / \         /     \        / | ||||
|  *      \--->---/   \-------/       \------/ | ||||
|  *          q1  | ||||
|  *  | ||||
|  * options | ||||
|  * - q1: input propagator 1 (string) | ||||
|  * - q2: input propagator 2 (string) | ||||
|  * - q3: input propagator 3 (string), assumed to be sequential propagator  | ||||
|  * - q4: input propagator 4 (string), assumed to be a loop | ||||
|  *  | ||||
|  * type 1: trace(q1*adj(q2)*g5*gL[mu])*trace(loop*gL[mu])*trace(q3*g5) | ||||
|  * type 2: trace(q1*adj(q2)*g5*gL[mu]*loop*gL[mu])*trace(q3*g5) | ||||
|  */ | ||||
|  | ||||
| /******************************************************************************* | ||||
|  *                  TWeakNeutral4ptDisc implementation                         * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TWeakNeutral4ptDisc::TWeakNeutral4ptDisc(const std::string name) | ||||
| : Module<WeakHamiltonianPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TWeakNeutral4ptDisc::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q1, par().q2, par().q3, par().q4}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TWeakNeutral4ptDisc::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TWeakNeutral4ptDisc::setup(void) | ||||
| { | ||||
|     unsigned int ndim = env().getNd(); | ||||
|  | ||||
|     envTmpLat(LatticeComplex,  "expbuf"); | ||||
|     envTmpLat(PropagatorField, "tmp"); | ||||
|     envTmpLat(LatticeComplex,  "curr"); | ||||
|     envTmp(std::vector<PropagatorField>, "meson", 1, ndim, PropagatorField(env().getGrid())); | ||||
|     envTmp(std::vector<PropagatorField>, "loop", 1, ndim,  PropagatorField(env().getGrid())); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TWeakNeutral4ptDisc::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing Weak Hamiltonian neutral disconnected contractions '"  | ||||
|                  << getName() << "' using quarks '" << par().q1 << "', '"  | ||||
|                  << par().q2 << ", '" << par().q3 << "' and '" << par().q4  | ||||
|                  << "'." << std::endl; | ||||
|  | ||||
|     ResultWriter          writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                  &q1 = envGet(PropagatorField, par().q1); | ||||
|     auto                  &q2 = envGet(PropagatorField, par().q2); | ||||
|     auto                  &q3 = envGet(PropagatorField, par().q3); | ||||
|     auto                  &q4 = envGet(PropagatorField, par().q4); | ||||
|     Gamma                 g5  = Gamma(Gamma::Algebra::Gamma5); | ||||
|     std::vector<TComplex> corrbuf; | ||||
|     std::vector<Result>   result(n_neut_disc_diag); | ||||
|     unsigned int          ndim = env().getNd(); | ||||
|  | ||||
|     envGetTmp(LatticeComplex,               expbuf);  | ||||
|     envGetTmp(PropagatorField,              tmp); | ||||
|     envGetTmp(LatticeComplex,               curr); | ||||
|     envGetTmp(std::vector<PropagatorField>, meson); | ||||
|     envGetTmp(std::vector<PropagatorField>, loop); | ||||
|  | ||||
|     // Setup for type 1 contractions. | ||||
|     for (int mu = 0; mu < ndim; ++mu) | ||||
|     { | ||||
|         meson[mu] = MAKE_DISC_MESON(q1, q2, GammaL(Gamma::gmu[mu])); | ||||
|         loop[mu] = MAKE_DISC_LOOP(q4, GammaL(Gamma::gmu[mu])); | ||||
|     } | ||||
|     curr = MAKE_DISC_CURR(q3, GammaL(Gamma::Algebra::Gamma5)); | ||||
|  | ||||
|     // Perform type 1 contractions.     | ||||
|     SUM_MU(expbuf, trace(meson[mu]*loop[mu])) | ||||
|     expbuf *= curr; | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[neut_disc_1_diag], "HW_disc0_1") | ||||
|  | ||||
|     // Perform type 2 contractions. | ||||
|     SUM_MU(expbuf, trace(meson[mu])*trace(loop[mu])) | ||||
|     expbuf *= curr; | ||||
|     MAKE_DIAG(expbuf, corrbuf, result[neut_disc_2_diag], "HW_disc0_2") | ||||
|  | ||||
|     write(writer, "HW_disc0", result); | ||||
| } | ||||
							
								
								
									
										60
									
								
								extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ | ||||
| #define Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MContraction/WeakHamiltonian.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         WeakNeutral4ptDisc                                 * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MContraction) | ||||
|  | ||||
| enum | ||||
| { | ||||
|     neut_disc_1_diag = 0, | ||||
|     neut_disc_2_diag = 1, | ||||
|     n_neut_disc_diag = 2 | ||||
| }; | ||||
|  | ||||
| // Neutral 4pt disconnected subdiagram contractions. | ||||
| #define MAKE_DISC_MESON(Q_1, Q_2, gamma) (Q_1*adj(Q_2)*g5*gamma) | ||||
| #define MAKE_DISC_LOOP(Q_LOOP, gamma) (Q_LOOP*gamma) | ||||
| #define MAKE_DISC_CURR(Q_c, gamma) (trace(Q_c*gamma)) | ||||
|  | ||||
| MAKE_WEAK_MODULE(WeakNeutral4ptDisc) | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ | ||||
							
								
								
									
										202
									
								
								extras/Hadrons/Modules/MFermion/GaugeProp.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								extras/Hadrons/Modules/MFermion/GaugeProp.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,202 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MFermion/GaugeProp.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MFermion_GaugeProp_hpp_ | ||||
| #define Hadrons_MFermion_GaugeProp_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  * 5D -> 4D and 4D -> 5D conversions.                                         * | ||||
|  ******************************************************************************/ | ||||
| template<class vobj> // Note that 5D object is modified. | ||||
| inline void make_4D(Lattice<vobj> &in_5d, Lattice<vobj> &out_4d, int Ls) | ||||
| { | ||||
|     axpby_ssp_pminus(in_5d, 0., in_5d, 1., in_5d, 0, 0); | ||||
|     axpby_ssp_pplus(in_5d, 1., in_5d, 1., in_5d, 0, Ls-1); | ||||
|     ExtractSlice(out_4d, in_5d, 0, 0); | ||||
| } | ||||
|  | ||||
| template<class vobj> | ||||
| inline void make_5D(Lattice<vobj> &in_4d, Lattice<vobj> &out_5d, int Ls) | ||||
| { | ||||
|     out_5d = zero; | ||||
|     InsertSlice(in_4d, out_5d, 0, 0); | ||||
|     InsertSlice(in_4d, out_5d, Ls-1, 0); | ||||
|     axpby_ssp_pplus(out_5d, 0., out_5d, 1., out_5d, 0, 0); | ||||
|     axpby_ssp_pminus(out_5d, 0., out_5d, 1., out_5d, Ls-1, Ls-1); | ||||
| } | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                GaugeProp                                   * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MFermion) | ||||
|  | ||||
| class GaugePropPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(GaugePropPar, | ||||
|                                     std::string, source, | ||||
|                                     std::string, solver); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TGaugeProp: public Module<GaugePropPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TGaugeProp(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TGaugeProp(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     unsigned int Ls_; | ||||
|     SolverFn     *solver_{nullptr}; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(GaugeProp, TGaugeProp<FIMPL>, MFermion); | ||||
| /****************************************************************************** | ||||
|  *                      TGaugeProp implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TGaugeProp<FImpl>::TGaugeProp(const std::string name) | ||||
| : Module<GaugePropPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TGaugeProp<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().source, par().solver}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TGaugeProp<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName(), getName() + "_5d"}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TGaugeProp<FImpl>::setup(void) | ||||
| { | ||||
|     Ls_ = env().getObjectLs(par().solver); | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
|     envTmpLat(FermionField, "source", Ls_); | ||||
|     envTmpLat(FermionField, "sol", Ls_); | ||||
|     envTmpLat(FermionField, "tmp"); | ||||
|     if (Ls_ > 1) | ||||
|     { | ||||
|         envCreateLat(PropagatorField, getName() + "_5d", Ls_); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TGaugeProp<FImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing quark propagator '" << getName() << "'" | ||||
|                  << std::endl; | ||||
|      | ||||
|     std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d"); | ||||
|     auto        &prop    = envGet(PropagatorField, propName); | ||||
|     auto        &fullSrc = envGet(PropagatorField, par().source); | ||||
|     auto        &solver  = envGet(SolverFn, par().solver); | ||||
|      | ||||
|     envGetTmp(FermionField, source); | ||||
|     envGetTmp(FermionField, sol); | ||||
|     envGetTmp(FermionField, tmp); | ||||
|     LOG(Message) << "Inverting using solver '" << par().solver | ||||
|                  << "' on source '" << par().source << "'" << std::endl; | ||||
|     for (unsigned int s = 0; s < Ns; ++s) | ||||
|       for (unsigned int c = 0; c < FImpl::Dimension; ++c) | ||||
|     { | ||||
|         LOG(Message) << "Inversion for spin= " << s << ", color= " << c | ||||
|                      << std::endl; | ||||
|         // source conversion for 4D sources | ||||
|         if (!env().isObject5d(par().source)) | ||||
|         { | ||||
|             if (Ls_ == 1) | ||||
|             { | ||||
|                PropToFerm<FImpl>(source, fullSrc, s, c); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 PropToFerm<FImpl>(tmp, fullSrc, s, c); | ||||
|                 make_5D(tmp, source, Ls_); | ||||
|             } | ||||
|         } | ||||
|         // source conversion for 5D sources | ||||
|         else | ||||
|         { | ||||
|             if (Ls_ != env().getObjectLs(par().source)) | ||||
|             { | ||||
|                 HADRON_ERROR(Size, "Ls mismatch between quark action and source"); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 PropToFerm<FImpl>(source, fullSrc, s, c); | ||||
|             } | ||||
|         } | ||||
|         sol = zero; | ||||
|         solver(sol, source); | ||||
|         FermToProp<FImpl>(prop, sol, s, c); | ||||
|         // create 4D propagators from 5D one if necessary | ||||
|         if (Ls_ > 1) | ||||
|         { | ||||
|             PropagatorField &p4d = envGet(PropagatorField, getName()); | ||||
|             make_4D(sol, tmp, Ls_); | ||||
|             FermToProp<FImpl>(p4d, tmp, s, c); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MFermion_GaugeProp_hpp_ | ||||
							
								
								
									
										75
									
								
								extras/Hadrons/Modules/MGauge/FundtoHirep.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								extras/Hadrons/Modules/MGauge/FundtoHirep.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/FundtoHirep.cc | ||||
|  | ||||
| Copyright (C) 2015 | ||||
| Copyright (C) 2016 | ||||
|  | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MGauge/FundtoHirep.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MGauge; | ||||
|  | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <class Rep> | ||||
| TFundtoHirep<Rep>::TFundtoHirep(const std::string name) | ||||
| : Module<FundtoHirepPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <class Rep> | ||||
| std::vector<std::string> TFundtoHirep<Rep>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <class Rep> | ||||
| std::vector<std::string> TFundtoHirep<Rep>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename Rep> | ||||
| void TFundtoHirep<Rep>::setup(void) | ||||
| { | ||||
|     envCreateLat(typename Rep::LatticeField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <class Rep> | ||||
| void TFundtoHirep<Rep>::execute(void) | ||||
| { | ||||
|     auto &U      = *env().template getObject<LatticeGaugeField>(par().gaugeconf); | ||||
|     LOG(Message) << "Transforming Representation" << std::endl; | ||||
|  | ||||
|     Rep TargetRepresentation(U._grid); | ||||
|     TargetRepresentation.update_representation(U); | ||||
|  | ||||
|     auto &URep = envGet(typename Rep::LatticeField, getName()); | ||||
|     URep = TargetRepresentation.U; | ||||
| } | ||||
							
								
								
									
										77
									
								
								extras/Hadrons/Modules/MGauge/FundtoHirep.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								extras/Hadrons/Modules/MGauge/FundtoHirep.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/FundtoHirep.hpp | ||||
|  | ||||
| Copyright (C) 2015 | ||||
| Copyright (C) 2016 | ||||
|  | ||||
| Author: David Preti <david.preti@to.infn.it> | ||||
| 	Guido Cossu <guido.cossu@ed.ac.uk> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MGauge_FundtoHirep_hpp_ | ||||
| #define Hadrons_MGauge_FundtoHirep_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Load a NERSC configuration                         * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MGauge) | ||||
|  | ||||
| class FundtoHirepPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(FundtoHirepPar, | ||||
|                                     std::string, gaugeconf); | ||||
| }; | ||||
|  | ||||
| template <class Rep> | ||||
| class TFundtoHirep: public Module<FundtoHirepPar> | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     TFundtoHirep(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TFundtoHirep(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     void setup(void); | ||||
|     // execution | ||||
|     void execute(void); | ||||
| }; | ||||
|  | ||||
| //MODULE_REGISTER_NS(FundtoAdjoint,   TFundtoHirep<AdjointRepresentation>, MGauge); | ||||
| //MODULE_REGISTER_NS(FundtoTwoIndexSym, TFundtoHirep<TwoIndexSymmetricRepresentation>, MGauge); | ||||
| //MODULE_REGISTER_NS(FundtoTwoIndexAsym, TFundtoHirep<TwoIndexAntiSymmetricRepresentation>, MGauge); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MGauge_FundtoHirep_hpp_ | ||||
							
								
								
									
										71
									
								
								extras/Hadrons/Modules/MGauge/Random.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								extras/Hadrons/Modules/MGauge/Random.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/Random.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MGauge/Random.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MGauge; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                           TRandom implementation                            * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TRandom::TRandom(const std::string name) | ||||
| : Module<NoPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TRandom::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TRandom::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TRandom::setup(void) | ||||
| { | ||||
|     envCreateLat(LatticeGaugeField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TRandom::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Generating random gauge configuration" << std::endl; | ||||
|      | ||||
|     auto &U = envGet(LatticeGaugeField, getName()); | ||||
|     SU3::HotConfiguration(*env().get4dRng(), U); | ||||
| } | ||||
							
								
								
									
										66
									
								
								extras/Hadrons/Modules/MGauge/Random.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								extras/Hadrons/Modules/MGauge/Random.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/Random.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MGauge_Random_hpp_ | ||||
| #define Hadrons_MGauge_Random_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                             Random gauge                                   * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MGauge) | ||||
|  | ||||
| class TRandom: public Module<NoPar> | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     TRandom(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TRandom(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Random, TRandom, MGauge); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MGauge_Random_hpp_ | ||||
							
								
								
									
										84
									
								
								extras/Hadrons/Modules/MGauge/StochEm.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								extras/Hadrons/Modules/MGauge/StochEm.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/StochEm.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #include <Grid/Hadrons/Modules/MGauge/StochEm.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MGauge; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                  TStochEm implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TStochEm::TStochEm(const std::string name) | ||||
| : Module<StochEmPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TStochEm::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TStochEm::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TStochEm::setup(void) | ||||
| { | ||||
|     if (!env().hasCreatedObject("_" + getName() + "_weight")) | ||||
|     { | ||||
|         envCacheLat(EmComp, "_" + getName() + "_weight"); | ||||
|     } | ||||
|     envCreateLat(EmField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TStochEm::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Generating stochatic EM potential..." << std::endl; | ||||
|  | ||||
|     PhotonR photon(par().gauge, par().zmScheme); | ||||
|     auto    &a = envGet(EmField, getName()); | ||||
|     auto    &w = envGet(EmComp, "_" + getName() + "_weight"); | ||||
|      | ||||
|     if (!env().hasCreatedObject("_" + getName() + "_weight")) | ||||
|     { | ||||
|         LOG(Message) << "Caching stochatic EM potential weight (gauge: " | ||||
|                      << par().gauge << ", zero-mode scheme: " | ||||
|                      << par().zmScheme << ")..." << std::endl; | ||||
|         photon.StochasticWeight(w); | ||||
|     } | ||||
|     photon.StochasticField(a, *env().get4dRng(), w); | ||||
| } | ||||
							
								
								
									
										76
									
								
								extras/Hadrons/Modules/MGauge/StochEm.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								extras/Hadrons/Modules/MGauge/StochEm.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,76 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/StochEm.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MGauge_StochEm_hpp_ | ||||
| #define Hadrons_MGauge_StochEm_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         StochEm                                 * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MGauge) | ||||
|  | ||||
| class StochEmPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(StochEmPar, | ||||
|                                     PhotonR::Gauge,    gauge, | ||||
|                                     PhotonR::ZmScheme, zmScheme); | ||||
| }; | ||||
|  | ||||
| class TStochEm: public Module<StochEmPar> | ||||
| { | ||||
| public: | ||||
|     typedef PhotonR::GaugeField     EmField; | ||||
|     typedef PhotonR::GaugeLinkField EmComp; | ||||
| public: | ||||
|     // constructor | ||||
|     TStochEm(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TStochEm(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(StochEm, TStochEm, MGauge); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MGauge_StochEm_hpp_ | ||||
							
								
								
									
										69
									
								
								extras/Hadrons/Modules/MGauge/Unit.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								extras/Hadrons/Modules/MGauge/Unit.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/Unit.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #include <Grid/Hadrons/Modules/MGauge/Unit.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MGauge; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                            TUnit implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TUnit::TUnit(const std::string name) | ||||
| : Module<NoPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TUnit::getInput(void) | ||||
| { | ||||
|     return std::vector<std::string>(); | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TUnit::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TUnit::setup(void) | ||||
| { | ||||
|     envCreateLat(LatticeGaugeField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TUnit::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Creating unit gauge configuration" << std::endl; | ||||
|      | ||||
|     auto &U = envGet(LatticeGaugeField, getName()); | ||||
|     SU3::ColdConfiguration(*env().get4dRng(), U); | ||||
| } | ||||
							
								
								
									
										66
									
								
								extras/Hadrons/Modules/MGauge/Unit.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								extras/Hadrons/Modules/MGauge/Unit.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MGauge/Unit.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MGauge_Unit_hpp_ | ||||
| #define Hadrons_MGauge_Unit_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                              Unit gauge                                    * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MGauge) | ||||
|  | ||||
| class TUnit: public Module<NoPar> | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     TUnit(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TUnit(void) = default; | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Unit, TUnit, MGauge); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MGauge_Unit_hpp_ | ||||
							
								
								
									
										140
									
								
								extras/Hadrons/Modules/MIO/LoadBinary.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								extras/Hadrons/Modules/MIO/LoadBinary.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,140 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MIO/LoadBinary.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MIO_LoadBinary_hpp_ | ||||
| #define Hadrons_MIO_LoadBinary_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Load a binary configurations                         * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MIO) | ||||
|  | ||||
| class LoadBinaryPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(LoadBinaryPar, | ||||
|                                     std::string, file, | ||||
|                                     std::string, format); | ||||
| }; | ||||
|  | ||||
| template <typename Impl> | ||||
| class TLoadBinary: public Module<LoadBinaryPar> | ||||
| { | ||||
| public: | ||||
|     typedef typename Impl::Field                  Field; | ||||
|     typedef typename Impl::Simd                   Simd; | ||||
|     typedef typename Field::vector_object         vobj; | ||||
|     typedef typename vobj::scalar_object          sobj; | ||||
|     typedef typename sobj::DoublePrecision        sobj_double; | ||||
|     typedef BinarySimpleMunger<sobj_double, sobj> Munger; | ||||
| public: | ||||
|     // constructor | ||||
|     TLoadBinary(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TLoadBinary(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(LoadBinary, TLoadBinary<GIMPL>, MIO); | ||||
| MODULE_REGISTER_NS(LoadBinaryScalarSU2, TLoadBinary<ScalarNxNAdjImplR<2>>, MIO); | ||||
| MODULE_REGISTER_NS(LoadBinaryScalarSU3, TLoadBinary<ScalarNxNAdjImplR<3>>, MIO); | ||||
| MODULE_REGISTER_NS(LoadBinaryScalarSU4, TLoadBinary<ScalarNxNAdjImplR<4>>, MIO); | ||||
| MODULE_REGISTER_NS(LoadBinaryScalarSU5, TLoadBinary<ScalarNxNAdjImplR<5>>, MIO); | ||||
| MODULE_REGISTER_NS(LoadBinaryScalarSU6, TLoadBinary<ScalarNxNAdjImplR<6>>, MIO); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         TLoadBinary implementation                         * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename Impl> | ||||
| TLoadBinary<Impl>::TLoadBinary(const std::string name) | ||||
| : Module<LoadBinaryPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename Impl> | ||||
| std::vector<std::string> TLoadBinary<Impl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename Impl> | ||||
| std::vector<std::string> TLoadBinary<Impl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename Impl> | ||||
| void TLoadBinary<Impl>::setup(void) | ||||
| { | ||||
|     envCreateLat(Field, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename Impl> | ||||
| void TLoadBinary<Impl>::execute(void) | ||||
| { | ||||
|     Munger      munge; | ||||
|     uint32_t    nersc_csum, scidac_csuma, scidac_csumb; | ||||
|     auto        &U = envGet(Field, getName()); | ||||
|     std::string filename = par().file + "." | ||||
|                            + std::to_string(vm().getTrajectory()); | ||||
|  | ||||
|     LOG(Message) << "Loading " << par().format  | ||||
|                  << " binary configuration from file '" << filename | ||||
|                  << "'" << std::endl; | ||||
|     BinaryIO::readLatticeObject<vobj, sobj_double>(U, filename, munge, 0,  | ||||
|                                                    par().format, nersc_csum, | ||||
|                                                    scidac_csuma, scidac_csumb); | ||||
|     LOG(Message) << "Checksums:" << std::endl; | ||||
|     LOG(Message) << "  NERSC    " << nersc_csum << std::endl; | ||||
|     LOG(Message) << "  SciDAC A " << scidac_csuma << std::endl; | ||||
|     LOG(Message) << "  SciDAC B " << scidac_csumb << std::endl; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MIO_LoadBinary_hpp_ | ||||
							
								
								
									
										76
									
								
								extras/Hadrons/Modules/MIO/LoadNersc.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								extras/Hadrons/Modules/MIO/LoadNersc.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,76 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MIO/LoadNersc.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #include <Grid/Hadrons/Modules/MIO/LoadNersc.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MIO; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                       TLoadNersc implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TLoadNersc::TLoadNersc(const std::string name) | ||||
| : Module<LoadNerscPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TLoadNersc::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TLoadNersc::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TLoadNersc::setup(void) | ||||
| { | ||||
|     envCreateLat(LatticeGaugeField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TLoadNersc::execute(void) | ||||
| { | ||||
|     FieldMetaData header; | ||||
|     std::string   fileName = par().file + "." | ||||
|                              + std::to_string(vm().getTrajectory()); | ||||
|     LOG(Message) << "Loading NERSC configuration from file '" << fileName | ||||
|                  << "'" << std::endl; | ||||
|  | ||||
|     auto &U = envGet(LatticeGaugeField, getName()); | ||||
|     NerscIO::readConfiguration(U, header, fileName); | ||||
|     LOG(Message) << "NERSC header:" << std::endl; | ||||
|     dump_meta_data(header, LOG(Message)); | ||||
| } | ||||
							
								
								
									
										71
									
								
								extras/Hadrons/Modules/MIO/LoadNersc.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								extras/Hadrons/Modules/MIO/LoadNersc.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MIO/LoadNersc.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MIO_LoadNersc_hpp_ | ||||
| #define Hadrons_MIO_LoadNersc_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Load a NERSC configuration                           * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MIO) | ||||
|  | ||||
| class LoadNerscPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(LoadNerscPar, | ||||
|                                     std::string, file); | ||||
| }; | ||||
|  | ||||
| class TLoadNersc: public Module<LoadNerscPar> | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     TLoadNersc(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TLoadNersc(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(LoadNersc, TLoadNersc, MIO); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MIO_LoadNersc_hpp_ | ||||
							
								
								
									
										134
									
								
								extras/Hadrons/Modules/MLoop/NoiseLoop.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								extras/Hadrons/Modules/MLoop/NoiseLoop.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,134 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MLoop/NoiseLoop.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MLoop_NoiseLoop_hpp_ | ||||
| #define Hadrons_MLoop_NoiseLoop_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Noise loop propagator | ||||
|  ----------------------------- | ||||
|  * loop_x = q_x * adj(eta_x) | ||||
|   | ||||
|  * options: | ||||
|  - q = Result of inversion on noise source. | ||||
|  - eta = noise source. | ||||
|  | ||||
|  */ | ||||
|  | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         NoiseLoop                                          * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MLoop) | ||||
|  | ||||
| class NoiseLoopPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(NoiseLoopPar, | ||||
|                                     std::string, q, | ||||
|                                     std::string, eta); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TNoiseLoop: public Module<NoiseLoopPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TNoiseLoop(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TNoiseLoop(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(NoiseLoop, TNoiseLoop<FIMPL>, MLoop); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                 TNoiseLoop implementation                                  * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TNoiseLoop<FImpl>::TNoiseLoop(const std::string name) | ||||
| : Module<NoiseLoopPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TNoiseLoop<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().eta}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TNoiseLoop<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TNoiseLoop<FImpl>::setup(void) | ||||
| { | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TNoiseLoop<FImpl>::execute(void) | ||||
| { | ||||
|     auto &loop = envGet(PropagatorField, getName()); | ||||
|     auto &q    = envGet(PropagatorField, par().q); | ||||
|     auto &eta  = envGet(PropagatorField, par().eta); | ||||
|     loop = q*adj(eta); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MLoop_NoiseLoop_hpp_ | ||||
							
								
								
									
										249
									
								
								extras/Hadrons/Modules/MScalar/ChargedProp.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										249
									
								
								extras/Hadrons/Modules/MScalar/ChargedProp.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,249 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalar/ChargedProp.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: James Harrison <jch1g10@soton.ac.uk> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #include <Grid/Hadrons/Modules/MScalar/ChargedProp.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalar/Scalar.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MScalar; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                     TChargedProp implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TChargedProp::TChargedProp(const std::string name) | ||||
| : Module<ChargedPropPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TChargedProp::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().source, par().emField}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TChargedProp::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TChargedProp::setup(void) | ||||
| { | ||||
|     freeMomPropName_ = FREEMOMPROP(par().mass); | ||||
|     phaseName_.clear(); | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         phaseName_.push_back("_shiftphase_" + std::to_string(mu)); | ||||
|     } | ||||
|     GFSrcName_ = getName() + "_DinvSrc"; | ||||
|     fftName_   = getName() + "_fft"; | ||||
|  | ||||
|     freeMomPropDone_ = env().hasCreatedObject(freeMomPropName_); | ||||
|     GFSrcDone_       = env().hasCreatedObject(GFSrcName_); | ||||
|     phasesDone_      = env().hasCreatedObject(phaseName_[0]); | ||||
|     envCacheLat(ScalarField, freeMomPropName_); | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         envCacheLat(ScalarField, phaseName_[mu]); | ||||
|     } | ||||
|     envCacheLat(ScalarField, GFSrcName_); | ||||
|     envCreateLat(ScalarField, getName()); | ||||
|     envTmpLat(ScalarField, "buf"); | ||||
|     envTmpLat(ScalarField, "result"); | ||||
|     envTmpLat(ScalarField, "Amu"); | ||||
|     envCache(FFT, fftName_, 1, env().getGrid()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TChargedProp::execute(void) | ||||
| { | ||||
|     // CACHING ANALYTIC EXPRESSIONS | ||||
|     makeCaches(); | ||||
|  | ||||
|     // PROPAGATOR CALCULATION | ||||
|     LOG(Message) << "Computing charged scalar propagator" | ||||
|                  << " (mass= " << par().mass | ||||
|                  << ", charge= " << par().charge << ")..." << std::endl; | ||||
|      | ||||
|     auto   &prop  = envGet(ScalarField, getName()); | ||||
|     auto   &GFSrc = envGet(ScalarField, GFSrcName_); | ||||
|     auto   &G     = envGet(ScalarField, freeMomPropName_); | ||||
|     auto   &fft   = envGet(FFT, fftName_); | ||||
|     double q      = par().charge; | ||||
|     envGetTmp(ScalarField, result);  | ||||
|     envGetTmp(ScalarField, buf);  | ||||
|  | ||||
|     // G*F*Src | ||||
|     prop = GFSrc; | ||||
|  | ||||
|     // - q*G*momD1*G*F*Src (momD1 = F*D1*Finv) | ||||
|     buf = GFSrc; | ||||
|     momD1(buf, fft); | ||||
|     buf = G*buf; | ||||
|     prop = prop - q*buf; | ||||
|  | ||||
|     // + q^2*G*momD1*G*momD1*G*F*Src (here buf = G*momD1*G*F*Src) | ||||
|     momD1(buf, fft); | ||||
|     prop = prop + q*q*G*buf; | ||||
|  | ||||
|     // - q^2*G*momD2*G*F*Src (momD2 = F*D2*Finv) | ||||
|     buf = GFSrc; | ||||
|     momD2(buf, fft); | ||||
|     prop = prop - q*q*G*buf; | ||||
|  | ||||
|     // final FT | ||||
|     fft.FFT_all_dim(prop, prop, FFT::backward); | ||||
|      | ||||
|     // OUTPUT IF NECESSARY | ||||
|     if (!par().output.empty()) | ||||
|     { | ||||
|         std::string           filename = par().output + "." + | ||||
|                                          std::to_string(vm().getTrajectory()); | ||||
|          | ||||
|         LOG(Message) << "Saving zero-momentum projection to '" | ||||
|                      << filename << "'..." << std::endl; | ||||
|          | ||||
|         ResultWriter          writer(RESULT_FILE_NAME(par().output)); | ||||
|         std::vector<TComplex> vecBuf; | ||||
|         std::vector<Complex>  result; | ||||
|          | ||||
|         sliceSum(prop, vecBuf, Tp); | ||||
|         result.resize(vecBuf.size()); | ||||
|         for (unsigned int t = 0; t < vecBuf.size(); ++t) | ||||
|         { | ||||
|             result[t] = TensorRemove(vecBuf[t]); | ||||
|         } | ||||
|         write(writer, "charge", q); | ||||
|         write(writer, "prop", result); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void TChargedProp::makeCaches(void) | ||||
| { | ||||
|     auto &freeMomProp = envGet(ScalarField, freeMomPropName_); | ||||
|     auto &GFSrc       = envGet(ScalarField, GFSrcName_); | ||||
|     auto &fft         = envGet(FFT, fftName_); | ||||
|  | ||||
|     if (!freeMomPropDone_) | ||||
|     { | ||||
|         LOG(Message) << "Caching momentum space free scalar propagator" | ||||
|                      << " (mass= " << par().mass << ")..." << std::endl; | ||||
|         SIMPL::MomentumSpacePropagator(freeMomProp, par().mass); | ||||
|     } | ||||
|     if (!GFSrcDone_) | ||||
|     {    | ||||
|         FFT  fft(env().getGrid()); | ||||
|         auto &source = envGet(ScalarField, par().source); | ||||
|  | ||||
|         LOG(Message) << "Caching G*F*src..." << std::endl; | ||||
|         fft.FFT_all_dim(GFSrc, source, FFT::forward); | ||||
|         GFSrc = freeMomProp*GFSrc; | ||||
|     } | ||||
|     if (!phasesDone_) | ||||
|     { | ||||
|         std::vector<int> &l = env().getGrid()->_fdimensions; | ||||
|         Complex          ci(0.0,1.0); | ||||
|          | ||||
|         LOG(Message) << "Caching shift phases..." << std::endl; | ||||
|         for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|         { | ||||
|             Real twoPiL = M_PI*2./l[mu]; | ||||
|             auto &phmu  = envGet(ScalarField, phaseName_[mu]); | ||||
|              | ||||
|             LatticeCoordinate(phmu, mu); | ||||
|             phmu = exp(ci*twoPiL*phmu); | ||||
|             phase_.push_back(&phmu); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| void TChargedProp::momD1(ScalarField &s, FFT &fft) | ||||
| { | ||||
|     auto        &A = envGet(EmField, par().emField); | ||||
|     Complex     ci(0.0,1.0); | ||||
|  | ||||
|     envGetTmp(ScalarField, buf); | ||||
|     envGetTmp(ScalarField, result); | ||||
|     envGetTmp(ScalarField, Amu); | ||||
|  | ||||
|     result = zero; | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         Amu = peekLorentz(A, mu); | ||||
|         buf = (*phase_[mu])*s; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::backward); | ||||
|         buf = Amu*buf; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::forward); | ||||
|         result = result - ci*buf; | ||||
|     } | ||||
|     fft.FFT_all_dim(s, s, FFT::backward); | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         Amu = peekLorentz(A, mu); | ||||
|         buf = Amu*s; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::forward); | ||||
|         result = result + ci*adj(*phase_[mu])*buf; | ||||
|     } | ||||
|  | ||||
|     s = result; | ||||
| } | ||||
|  | ||||
| void TChargedProp::momD2(ScalarField &s, FFT &fft) | ||||
| { | ||||
|     auto &A = envGet(EmField, par().emField); | ||||
|  | ||||
|     envGetTmp(ScalarField, buf); | ||||
|     envGetTmp(ScalarField, result); | ||||
|     envGetTmp(ScalarField, Amu); | ||||
|  | ||||
|     result = zero; | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         Amu = peekLorentz(A, mu); | ||||
|         buf = (*phase_[mu])*s; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::backward); | ||||
|         buf = Amu*Amu*buf; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::forward); | ||||
|         result = result + .5*buf; | ||||
|     } | ||||
|     fft.FFT_all_dim(s, s, FFT::backward); | ||||
|     for (unsigned int mu = 0; mu < env().getNd(); ++mu) | ||||
|     { | ||||
|         Amu = peekLorentz(A, mu);         | ||||
|         buf = Amu*Amu*s; | ||||
|         fft.FFT_all_dim(buf, buf, FFT::forward); | ||||
|         result = result + .5*adj(*phase_[mu])*buf; | ||||
|     } | ||||
|  | ||||
|     s = result; | ||||
| } | ||||
							
								
								
									
										89
									
								
								extras/Hadrons/Modules/MScalar/ChargedProp.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								extras/Hadrons/Modules/MScalar/ChargedProp.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalar/ChargedProp.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalar_ChargedProp_hpp_ | ||||
| #define Hadrons_MScalar_ChargedProp_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Charged scalar propagator                            * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalar) | ||||
|  | ||||
| class ChargedPropPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(ChargedPropPar, | ||||
|                                     std::string, emField, | ||||
|                                     std::string, source, | ||||
|                                     double,      mass, | ||||
|                                     double,      charge, | ||||
|                                     std::string, output); | ||||
| }; | ||||
|  | ||||
| class TChargedProp: public Module<ChargedPropPar> | ||||
| { | ||||
| public: | ||||
|     SCALAR_TYPE_ALIASES(SIMPL,); | ||||
|     typedef PhotonR::GaugeField     EmField; | ||||
|     typedef PhotonR::GaugeLinkField EmComp; | ||||
| public: | ||||
|     // constructor | ||||
|     TChargedProp(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TChargedProp(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     void makeCaches(void); | ||||
|     void momD1(ScalarField &s, FFT &fft); | ||||
|     void momD2(ScalarField &s, FFT &fft); | ||||
| private: | ||||
|     bool                       freeMomPropDone_, GFSrcDone_, phasesDone_; | ||||
|     std::string                freeMomPropName_, GFSrcName_, fftName_; | ||||
|     std::vector<std::string>   phaseName_; | ||||
|     std::vector<ScalarField *> phase_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(ChargedProp, TChargedProp, MScalar); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalar_ChargedProp_hpp_ | ||||
							
								
								
									
										99
									
								
								extras/Hadrons/Modules/MScalar/FreeProp.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								extras/Hadrons/Modules/MScalar/FreeProp.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalar/FreeProp.cc | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #include <Grid/Hadrons/Modules/MScalar/FreeProp.hpp> | ||||
| #include <Grid/Hadrons/Modules/MScalar/Scalar.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace MScalar; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                        TFreeProp implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| TFreeProp::TFreeProp(const std::string name) | ||||
| : Module<FreePropPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> TFreeProp::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().source}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> TFreeProp::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void TFreeProp::setup(void) | ||||
| { | ||||
|     freeMomPropName_ = FREEMOMPROP(par().mass); | ||||
|      | ||||
|     freePropDone_ = env().hasCreatedObject(freeMomPropName_); | ||||
|     envCacheLat(ScalarField, freeMomPropName_); | ||||
|     envCreateLat(ScalarField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void TFreeProp::execute(void) | ||||
| { | ||||
|     auto &freeMomProp = envGet(ScalarField, freeMomPropName_); | ||||
|     auto &prop        = envGet(ScalarField, getName()); | ||||
|     auto &source      = envGet(ScalarField, par().source); | ||||
|  | ||||
|     if (!freePropDone_) | ||||
|     { | ||||
|         LOG(Message) << "Caching momentum space free scalar propagator" | ||||
|                      << " (mass= " << par().mass << ")..." << std::endl; | ||||
|         SIMPL::MomentumSpacePropagator(freeMomProp, par().mass); | ||||
|     } | ||||
|     LOG(Message) << "Computing free scalar propagator..." << std::endl; | ||||
|     SIMPL::FreePropagator(source, prop, freeMomProp); | ||||
|      | ||||
|     if (!par().output.empty()) | ||||
|     { | ||||
|         TextWriter            writer(par().output + "." + | ||||
|                                      std::to_string(vm().getTrajectory())); | ||||
|         std::vector<TComplex> buf; | ||||
|         std::vector<Complex>  result; | ||||
|          | ||||
|         sliceSum(prop, buf, Tp); | ||||
|         result.resize(buf.size()); | ||||
|         for (unsigned int t = 0; t < buf.size(); ++t) | ||||
|         { | ||||
|             result[t] = TensorRemove(buf[t]); | ||||
|         } | ||||
|         write(writer, "prop", result); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										79
									
								
								extras/Hadrons/Modules/MScalar/FreeProp.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								extras/Hadrons/Modules/MScalar/FreeProp.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,79 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalar/FreeProp.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalar_FreeProp_hpp_ | ||||
| #define Hadrons_MScalar_FreeProp_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                               FreeProp                                     * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalar) | ||||
|  | ||||
| class FreePropPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(FreePropPar, | ||||
|                                     std::string, source, | ||||
|                                     double,      mass, | ||||
|                                     std::string, output); | ||||
| }; | ||||
|  | ||||
| class TFreeProp: public Module<FreePropPar> | ||||
| { | ||||
| public: | ||||
|     SCALAR_TYPE_ALIASES(SIMPL,); | ||||
| public: | ||||
|     // constructor | ||||
|     TFreeProp(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TFreeProp(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     std::string freeMomPropName_; | ||||
|     bool        freePropDone_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(FreeProp, TFreeProp, MScalar); | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalar_FreeProp_hpp_ | ||||
							
								
								
									
										33
									
								
								extras/Hadrons/Modules/MScalar/Scalar.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								extras/Hadrons/Modules/MScalar/Scalar.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalar/Scalar.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_Scalar_hpp_ | ||||
| #define Hadrons_Scalar_hpp_ | ||||
|  | ||||
| #define FREEMOMPROP(m) "_scalar_mom_prop_" + std::to_string(m) | ||||
|  | ||||
| #endif // Hadrons_Scalar_hpp_ | ||||
							
								
								
									
										166
									
								
								extras/Hadrons/Modules/MScalarSUN/Div.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										166
									
								
								extras/Hadrons/Modules/MScalarSUN/Div.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,166 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalarSUN/Div.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalarSUN_Div_hpp_ | ||||
| #define Hadrons_MScalarSUN_Div_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Div                                 * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalarSUN) | ||||
|  | ||||
| class DivPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_ENUM(DiffType, undef, forward, 1, backward, 2, central, 3); | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(DivPar, | ||||
|                                     std::vector<std::string>, op, | ||||
|                                     DiffType,                 type, | ||||
|                                     std::string,              output); | ||||
| }; | ||||
|  | ||||
| template <typename SImpl> | ||||
| class TDiv: public Module<DivPar> | ||||
| { | ||||
| public: | ||||
|     typedef typename SImpl::Field        Field; | ||||
|     typedef typename SImpl::ComplexField ComplexField; | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         DivPar::DiffType, type, | ||||
|                                         Complex,          value); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TDiv(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TDiv(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(DivSU2, TDiv<ScalarNxNAdjImplR<2>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(DivSU3, TDiv<ScalarNxNAdjImplR<3>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(DivSU4, TDiv<ScalarNxNAdjImplR<4>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(DivSU5, TDiv<ScalarNxNAdjImplR<5>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(DivSU6, TDiv<ScalarNxNAdjImplR<6>>, MScalarSUN); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                 TDiv implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| TDiv<SImpl>::TDiv(const std::string name) | ||||
| : Module<DivPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TDiv<SImpl>::getInput(void) | ||||
| { | ||||
|     return par().op; | ||||
| } | ||||
|  | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TDiv<SImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|  | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TDiv<SImpl>::setup(void) | ||||
| { | ||||
|     if (par().op.size() != env().getNd()) | ||||
|     { | ||||
|         HADRON_ERROR(Size, "the number of components differs from number of dimensions"); | ||||
|     } | ||||
|     envCreateLat(ComplexField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TDiv<SImpl>::execute(void) | ||||
| { | ||||
|     const auto nd = env().getNd(); | ||||
|  | ||||
|     LOG(Message) << "Computing the " << par().type << " divergence of ["; | ||||
|     for (unsigned int mu = 0; mu < nd; ++mu) | ||||
|     { | ||||
|         std::cout << par().op[mu] << ((mu == nd - 1) ? "]" : ", "); | ||||
|     } | ||||
|     std::cout << std::endl; | ||||
|  | ||||
|     auto &div = envGet(ComplexField, getName()); | ||||
|     div = zero; | ||||
|     for (unsigned int mu = 0; mu < nd; ++mu) | ||||
|     { | ||||
|         auto &op = envGet(ComplexField, par().op[mu]); | ||||
|         switch(par().type) | ||||
|         { | ||||
|             case DivPar::DiffType::backward: | ||||
|                 div += op - Cshift(op, mu, -1); | ||||
|                 break; | ||||
|             case DivPar::DiffType::forward: | ||||
|                 div += Cshift(op, mu, 1) - op; | ||||
|                 break; | ||||
|             case DivPar::DiffType::central: | ||||
|                 div += 0.5*(Cshift(op, mu, 1) - Cshift(op, mu, -1)); | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
|     if (!par().output.empty()) | ||||
|     { | ||||
|         Result       r; | ||||
|         ResultWriter writer(RESULT_FILE_NAME(par().output)); | ||||
|  | ||||
|         r.type  = par().type; | ||||
|         r.value = TensorRemove(sum(div)); | ||||
|         write(writer, "div", r); | ||||
|     } | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalarSUN_Div_hpp_ | ||||
							
								
								
									
										146
									
								
								extras/Hadrons/Modules/MScalarSUN/TrMag.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								extras/Hadrons/Modules/MScalarSUN/TrMag.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,146 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalarSUN/TrMag.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalarSUN_TrMag_hpp_ | ||||
| #define Hadrons_MScalarSUN_TrMag_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       Module to compute tr(mag^n)                          * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalarSUN) | ||||
|  | ||||
| class TrMagPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(TrMagPar, | ||||
|                                     std::string,  field, | ||||
|                                     unsigned int, maxPow, | ||||
|                                     std::string,  output); | ||||
| }; | ||||
|  | ||||
| template <typename SImpl> | ||||
| class TTrMag: public Module<TrMagPar> | ||||
| { | ||||
| public: | ||||
|     typedef typename SImpl::Field        Field; | ||||
|     typedef typename SImpl::ComplexField ComplexField; | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         std::string, op, | ||||
|                                         Real,        value); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TTrMag(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TTrMag(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(TrMagSU2, TTrMag<ScalarNxNAdjImplR<2>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrMagSU3, TTrMag<ScalarNxNAdjImplR<3>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrMagSU4, TTrMag<ScalarNxNAdjImplR<4>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrMagSU5, TTrMag<ScalarNxNAdjImplR<5>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrMagSU6, TTrMag<ScalarNxNAdjImplR<6>>, MScalarSUN); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         TTrMag implementation                              * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| TTrMag<SImpl>::TTrMag(const std::string name) | ||||
| : Module<TrMagPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTrMag<SImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().field}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTrMag<SImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTrMag<SImpl>::setup(void) | ||||
| {} | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTrMag<SImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing tr(mag^n) for n even up to " << par().maxPow | ||||
|                  << "..." << std::endl; | ||||
|  | ||||
|     std::vector<Result> result; | ||||
|     ResultWriter        writer(RESULT_FILE_NAME(par().output)); | ||||
|     auto                &phi = envGet(Field, par().field); | ||||
|  | ||||
|     auto m2 = sum(phi), mn = m2; | ||||
|  | ||||
|     m2 = -m2*m2; | ||||
|     mn = 1.; | ||||
|     for (unsigned int n = 2; n <= par().maxPow; n += 2) | ||||
|     { | ||||
|         Result r; | ||||
|  | ||||
|         mn = mn*m2; | ||||
|         r.op    = "tr(mag^" + std::to_string(n) + ")"; | ||||
|         r.value = TensorRemove(trace(mn)).real(); | ||||
|         result.push_back(r); | ||||
|     } | ||||
|     write(writer, "trmag", result); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalarSUN_TrMag_hpp_ | ||||
							
								
								
									
										182
									
								
								extras/Hadrons/Modules/MScalarSUN/TrPhi.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								extras/Hadrons/Modules/MScalarSUN/TrPhi.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,182 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalarSUN/TrPhi.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalarSUN_TrPhi_hpp_ | ||||
| #define Hadrons_MScalarSUN_TrPhi_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Module to compute tr(phi^n)                        * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalarSUN) | ||||
|  | ||||
| class TrPhiPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(TrPhiPar, | ||||
|                                     std::string,  field, | ||||
|                                     unsigned int, maxPow, | ||||
|                                     std::string,  output); | ||||
| }; | ||||
|  | ||||
| template <typename SImpl> | ||||
| class TTrPhi: public Module<TrPhiPar> | ||||
| { | ||||
| public: | ||||
|     typedef typename SImpl::Field        Field; | ||||
|     typedef typename SImpl::ComplexField ComplexField; | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         std::string, op, | ||||
|                                         Real,        value); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TTrPhi(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TTrPhi(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     // output name generator | ||||
|     std::string outName(const unsigned int n); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(TrPhiSU2, TTrPhi<ScalarNxNAdjImplR<2>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrPhiSU3, TTrPhi<ScalarNxNAdjImplR<3>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrPhiSU4, TTrPhi<ScalarNxNAdjImplR<4>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrPhiSU5, TTrPhi<ScalarNxNAdjImplR<5>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TrPhiSU6, TTrPhi<ScalarNxNAdjImplR<6>>, MScalarSUN); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                          TTrPhi implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| TTrPhi<SImpl>::TTrPhi(const std::string name) | ||||
| : Module<TrPhiPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTrPhi<SImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().field}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTrPhi<SImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out; | ||||
|  | ||||
|     for (unsigned int n = 2; n <= par().maxPow; n += 2) | ||||
|     { | ||||
|         out.push_back(outName(n)); | ||||
|     } | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTrPhi<SImpl>::setup(void) | ||||
| { | ||||
|     if (par().maxPow < 2) | ||||
|     { | ||||
|         HADRON_ERROR(Size, "'maxPow' should be at least equal to 2"); | ||||
|     } | ||||
|     envTmpLat(Field, "phi2"); | ||||
|     envTmpLat(Field, "buf"); | ||||
|     for (unsigned int n = 2; n <= par().maxPow; n += 2) | ||||
|     { | ||||
|         envCreateLat(ComplexField, outName(n)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTrPhi<SImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing tr(phi^n) for n even up to " << par().maxPow | ||||
|                  << "..." << std::endl;  | ||||
|  | ||||
|     std::vector<Result> result; | ||||
|     auto                &phi = envGet(Field, par().field); | ||||
|  | ||||
|     envGetTmp(Field, phi2); | ||||
|     envGetTmp(Field, buf); | ||||
|     buf  = 1.; | ||||
|     phi2 = -phi*phi;  | ||||
|     for (unsigned int n = 2; n <= par().maxPow; n += 2) | ||||
|     { | ||||
|         auto &phin = envGet(ComplexField, outName(n)); | ||||
|  | ||||
|         buf  = buf*phi2; | ||||
|         phin = trace(buf); | ||||
|         if (!par().output.empty()) | ||||
|         { | ||||
|             Result r; | ||||
|  | ||||
|             r.op    = "tr(phi^" + std::to_string(n) + ")"; | ||||
|             r.value = TensorRemove(sum(phin)).real(); | ||||
|             result.push_back(r); | ||||
|         } | ||||
|     } | ||||
|     if (result.size() > 0) | ||||
|     { | ||||
|         ResultWriter writer(RESULT_FILE_NAME(par().output)); | ||||
|  | ||||
|         write(writer, "trphi", result); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // output name generator /////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| std::string TTrPhi<SImpl>::outName(const unsigned int n) | ||||
| { | ||||
|     return getName() + "_" + std::to_string(n); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalarSUN_TrPhi_hpp_ | ||||
							
								
								
									
										184
									
								
								extras/Hadrons/Modules/MScalarSUN/TwoPoint.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								extras/Hadrons/Modules/MScalarSUN/TwoPoint.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,184 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MScalarSUN/TwoPoint.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
| #ifndef Hadrons_MScalarSUN_TwoPoint_hpp_ | ||||
| #define Hadrons_MScalarSUN_TwoPoint_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                 2-pt functions for a given set of operators                * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MScalarSUN) | ||||
|  | ||||
| class TwoPointPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(TwoPointPar, | ||||
|                                     std::vector<std::string>, op, | ||||
|                                     std::string,              output); | ||||
| }; | ||||
|  | ||||
| template <typename SImpl> | ||||
| class TTwoPoint: public Module<TwoPointPar> | ||||
| { | ||||
| public: | ||||
|     typedef typename SImpl::Field        Field; | ||||
|     typedef typename SImpl::ComplexField ComplexField; | ||||
|     class Result: Serializable | ||||
|     { | ||||
|     public: | ||||
|         GRID_SERIALIZABLE_CLASS_MEMBERS(Result, | ||||
|                                         std::string, sink, | ||||
|                                         std::string, source, | ||||
|                                         std::vector<Complex>, data); | ||||
|     }; | ||||
| public: | ||||
|     // constructor | ||||
|     TTwoPoint(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TTwoPoint(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     // make 2-pt function | ||||
|     template <class SinkSite, class SourceSite> | ||||
|     std::vector<Complex> makeTwoPoint(const std::vector<SinkSite>   &sink, | ||||
|                                       const std::vector<SourceSite> &source); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(TwoPointSU2, TTwoPoint<ScalarNxNAdjImplR<2>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TwoPointSU3, TTwoPoint<ScalarNxNAdjImplR<3>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TwoPointSU4, TTwoPoint<ScalarNxNAdjImplR<4>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TwoPointSU5, TTwoPoint<ScalarNxNAdjImplR<5>>, MScalarSUN); | ||||
| MODULE_REGISTER_NS(TwoPointSU6, TTwoPoint<ScalarNxNAdjImplR<6>>, MScalarSUN); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                 TTwoPoint implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| TTwoPoint<SImpl>::TTwoPoint(const std::string name) | ||||
| : Module<TwoPointPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTwoPoint<SImpl>::getInput(void) | ||||
| {    | ||||
|     return par().op; | ||||
| } | ||||
|  | ||||
| template <typename SImpl> | ||||
| std::vector<std::string> TTwoPoint<SImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {}; | ||||
|  | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTwoPoint<SImpl>::setup(void) | ||||
| { | ||||
|     const unsigned int nt = env().getDim().back(); | ||||
|     envTmp(std::vector<std::vector<TComplex>>, "slicedOp", 1, par().op.size(),  | ||||
|            std::vector<TComplex>(nt)); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename SImpl> | ||||
| void TTwoPoint<SImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Computing 2-point functions for operators:" << std::endl; | ||||
|     for (auto &o: par().op) | ||||
|     { | ||||
|         LOG(Message) << "  '" << o << "'" << std::endl; | ||||
|     } | ||||
|  | ||||
|     ResultWriter        writer(RESULT_FILE_NAME(par().output)); | ||||
|     const unsigned int  nd = env().getDim().size(); | ||||
|     std::vector<Result> result; | ||||
|      | ||||
|     envGetTmp(std::vector<std::vector<TComplex>>, slicedOp); | ||||
|     for (unsigned int i = 0; i < par().op.size(); ++i) | ||||
|     { | ||||
|         auto &op = envGet(ComplexField, par().op[i]); | ||||
|  | ||||
|         sliceSum(op, slicedOp[i], nd - 1); | ||||
|     } | ||||
|     for (unsigned int i = 0; i < par().op.size(); ++i) | ||||
|     for (unsigned int j = 0; j < par().op.size(); ++j) | ||||
|     { | ||||
|         Result r; | ||||
|  | ||||
|         r.sink   = par().op[i]; | ||||
|         r.source = par().op[j]; | ||||
|         r.data   = makeTwoPoint(slicedOp[i], slicedOp[j]); | ||||
|         result.push_back(r); | ||||
|     } | ||||
|     write(writer, "twopt", result); | ||||
| } | ||||
|  | ||||
| // make 2-pt function ////////////////////////////////////////////////////////// | ||||
| template <class SImpl> | ||||
| template <class SinkSite, class SourceSite> | ||||
| std::vector<Complex> TTwoPoint<SImpl>::makeTwoPoint( | ||||
|                                   const std::vector<SinkSite>   &sink, | ||||
|                                   const std::vector<SourceSite> &source) | ||||
| { | ||||
|     assert(sink.size() == source.size()); | ||||
|      | ||||
|     unsigned int         nt = sink.size(); | ||||
|     std::vector<Complex> res(nt, 0.); | ||||
|      | ||||
|     for (unsigned int dt = 0; dt < nt; ++dt) | ||||
|     { | ||||
|         for (unsigned int t  = 0; t < nt; ++t) | ||||
|         { | ||||
|             res[dt] += TensorRemove(trace(sink[(t+dt)%nt]*source[t])); | ||||
|         } | ||||
|         res[dt] *= 1./static_cast<double>(nt); | ||||
|     } | ||||
|      | ||||
|     return res; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MScalarSUN_TwoPoint_hpp_ | ||||
							
								
								
									
										155
									
								
								extras/Hadrons/Modules/MSink/Point.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								extras/Hadrons/Modules/MSink/Point.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,155 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSink/Point.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSink_Point_hpp_ | ||||
| #define Hadrons_MSink_Point_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                   Point                                    * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSink) | ||||
|  | ||||
| class PointPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar, | ||||
|                                     std::string, mom); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TPoint: public Module<PointPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
|     SINK_TYPE_ALIASES(); | ||||
| public: | ||||
|     // constructor | ||||
|     TPoint(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TPoint(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     bool        hasPhase_{false};  | ||||
|     std::string momphName_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Point,       TPoint<FIMPL>,        MSink); | ||||
| MODULE_REGISTER_NS(ScalarPoint, TPoint<ScalarImplCR>, MSink); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                          TPoint implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TPoint<FImpl>::TPoint(const std::string name) | ||||
| : Module<PointPar>(name) | ||||
| , momphName_ (name + "_momph") | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TPoint<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TPoint<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TPoint<FImpl>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "coor"); | ||||
|     envCacheLat(LatticeComplex, momphName_); | ||||
|     envCreate(SinkFn, getName(), 1, nullptr); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TPoint<FImpl>::execute(void) | ||||
| {    | ||||
|     LOG(Message) << "Setting up point sink function for momentum [" | ||||
|                  << par().mom << "]" << std::endl; | ||||
|  | ||||
|     auto &ph = envGet(LatticeComplex, momphName_); | ||||
|      | ||||
|     if (!hasPhase_) | ||||
|     { | ||||
|         Complex           i(0.0,1.0); | ||||
|         std::vector<Real> p; | ||||
|  | ||||
|         envGetTmp(LatticeComplex, coor); | ||||
|         p  = strToVec<Real>(par().mom); | ||||
|         ph = zero; | ||||
|         for(unsigned int mu = 0; mu < env().getNd(); mu++) | ||||
|         { | ||||
|             LatticeCoordinate(coor, mu); | ||||
|             ph = ph + (p[mu]/env().getGrid()->_fdimensions[mu])*coor; | ||||
|         } | ||||
|         ph = exp((Real)(2*M_PI)*i*ph); | ||||
|         hasPhase_ = true; | ||||
|     } | ||||
|     auto sink = [&ph](const PropagatorField &field) | ||||
|     { | ||||
|         SlicedPropagator res; | ||||
|         PropagatorField  tmp = ph*field; | ||||
|          | ||||
|         sliceSum(tmp, res, Tp); | ||||
|          | ||||
|         return res; | ||||
|     }; | ||||
|     envGet(SinkFn, getName()) = sink; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSink_Point_hpp_ | ||||
							
								
								
									
										127
									
								
								extras/Hadrons/Modules/MSink/Smear.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								extras/Hadrons/Modules/MSink/Smear.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,127 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSink/Smear.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSink_Smear_hpp_ | ||||
| #define Hadrons_MSink_Smear_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                 Smear                                      * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSink) | ||||
|  | ||||
| class SmearPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(SmearPar, | ||||
|                                     std::string, q, | ||||
|                                     std::string, sink); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TSmear: public Module<SmearPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
|     SINK_TYPE_ALIASES(); | ||||
| public: | ||||
|     // constructor | ||||
|     TSmear(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TSmear(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Smear, TSmear<FIMPL>, MSink); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                          TSmear implementation                             * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TSmear<FImpl>::TSmear(const std::string name) | ||||
| : Module<SmearPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSmear<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().sink}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSmear<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSmear<FImpl>::setup(void) | ||||
| { | ||||
|     envCreate(SlicedPropagator, getName(), 1, env().getDim(Tp)); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSmear<FImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Sink smearing propagator '" << par().q | ||||
|                  << "' using sink function '" << par().sink << "'." | ||||
|                  << std::endl; | ||||
|  | ||||
|     auto &sink = envGet(SinkFn, par().sink); | ||||
|     auto &q    = envGet(PropagatorField, par().q); | ||||
|     auto &out  = envGet(SlicedPropagator, getName()); | ||||
|      | ||||
|     out = sink(q); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSink_Smear_hpp_ | ||||
							
								
								
									
										137
									
								
								extras/Hadrons/Modules/MSolver/RBPrecCG.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								extras/Hadrons/Modules/MSolver/RBPrecCG.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSolver/RBPrecCG.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSolver_RBPrecCG_hpp_ | ||||
| #define Hadrons_MSolver_RBPrecCG_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     Schur red-black preconditioned CG                      * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSolver) | ||||
|  | ||||
| class RBPrecCGPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(RBPrecCGPar, | ||||
|                                     std::string, action, | ||||
|                                     double     , residual); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TRBPrecCG: public Module<RBPrecCGPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TRBPrecCG(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TRBPrecCG(void) = default; | ||||
|     // dependencies/products | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getReference(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(RBPrecCG, TRBPrecCG<FIMPL>, MSolver); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                      TRBPrecCG template implementation                     * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TRBPrecCG<FImpl>::TRBPrecCG(const std::string name) | ||||
| : Module(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TRBPrecCG<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TRBPrecCG<FImpl>::getReference(void) | ||||
| { | ||||
|     std::vector<std::string> ref = {par().action}; | ||||
|      | ||||
|     return ref; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TRBPrecCG<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TRBPrecCG<FImpl>::setup(void) | ||||
| { | ||||
|     LOG(Message) << "setting up Schur red-black preconditioned CG for" | ||||
|                  << " action '" << par().action << "' with residual " | ||||
|                  << par().residual << std::endl; | ||||
|  | ||||
|     auto Ls     = env().getObjectLs(par().action); | ||||
|     auto &mat   = envGet(FMat, par().action); | ||||
|     auto solver = [&mat, this](FermionField &sol, const FermionField &source) | ||||
|     { | ||||
|         ConjugateGradient<FermionField>           cg(par().residual, 10000); | ||||
|         SchurRedBlackDiagMooeeSolve<FermionField> schurSolver(cg); | ||||
|          | ||||
|         schurSolver(mat, source, sol); | ||||
|     }; | ||||
|     envCreate(SolverFn, getName(), Ls, solver); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TRBPrecCG<FImpl>::execute(void) | ||||
| {} | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSolver_RBPrecCG_hpp_ | ||||
							
								
								
									
										138
									
								
								extras/Hadrons/Modules/MSource/Point.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								extras/Hadrons/Modules/MSource/Point.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,138 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSource/Point.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSource_Point_hpp_ | ||||
| #define Hadrons_MSource_Point_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Point source | ||||
|  ------------ | ||||
|  * src_x = delta_x,position | ||||
|   | ||||
|  * options: | ||||
|  - position: space-separated integer sequence (e.g. "0 1 1 0") | ||||
|   | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                                  TPoint                                     * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSource) | ||||
|  | ||||
| class PointPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar, | ||||
|                                     std::string, position); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TPoint: public Module<PointPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TPoint(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TPoint(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Point,       TPoint<FIMPL>,        MSource); | ||||
| MODULE_REGISTER_NS(ScalarPoint, TPoint<ScalarImplCR>, MSource); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       TPoint template implementation                       * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TPoint<FImpl>::TPoint(const std::string name) | ||||
| : Module<PointPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TPoint<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TPoint<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TPoint<FImpl>::setup(void) | ||||
| { | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TPoint<FImpl>::execute(void) | ||||
| { | ||||
|     LOG(Message) << "Creating point source at position [" << par().position | ||||
|                 << "]" << std::endl; | ||||
|  | ||||
|     std::vector<int> position = strToVec<int>(par().position); | ||||
|     auto             &src     = envGet(PropagatorField, getName()); | ||||
|     SitePropagator   id; | ||||
|      | ||||
|     id  = 1.; | ||||
|     src = zero; | ||||
|     pokeSite(id, src, position); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSource_Point_hpp_ | ||||
							
								
								
									
										160
									
								
								extras/Hadrons/Modules/MSource/SeqConserved.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										160
									
								
								extras/Hadrons/Modules/MSource/SeqConserved.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,160 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSource/SeqConserved.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSource_SeqConserved_hpp_ | ||||
| #define Hadrons_MSource_SeqConserved_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Sequential source | ||||
|  ----------------------------- | ||||
|  * src_x = q_x * theta(x_3 - tA) * theta(tB - x_3) * J_mu * exp(i x.mom) | ||||
|   | ||||
|  * options: | ||||
|  - q: input propagator (string) | ||||
|  - action: fermion action used for propagator q (string) | ||||
|  - tA: begin timeslice (integer) | ||||
|  - tB: end timesilce (integer) | ||||
|  - curr_type: type of conserved current to insert (Current) | ||||
|  - mu: Lorentz index of current to insert (integer) | ||||
|  - mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.") | ||||
|   | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                              SeqConserved                                  * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSource) | ||||
|  | ||||
| class SeqConservedPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(SeqConservedPar, | ||||
|                                     std::string,  q, | ||||
|                                     std::string,  action, | ||||
|                                     unsigned int, tA, | ||||
|                                     unsigned int, tB, | ||||
|                                     Current,      curr_type, | ||||
|                                     unsigned int, mu, | ||||
|                                     std::string,  mom); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TSeqConserved: public Module<SeqConservedPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TSeqConserved(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TSeqConserved(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(SeqConserved, TSeqConserved<FIMPL>, MSource); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                      TSeqConserved implementation                          * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TSeqConserved<FImpl>::TSeqConserved(const std::string name) | ||||
| : Module<SeqConservedPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSeqConserved<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().action}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSeqConserved<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSeqConserved<FImpl>::setup(void) | ||||
| { | ||||
|     auto Ls_ = env().getObjectLs(par().action); | ||||
|     envCreateLat(PropagatorField, getName(), Ls_); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSeqConserved<FImpl>::execute(void) | ||||
| { | ||||
|     if (par().tA == par().tB) | ||||
|     { | ||||
|         LOG(Message) << "Generating sequential source with conserved " | ||||
|                      << par().curr_type << " current insertion (mu = "  | ||||
|                      << par().mu << ") at " << "t = " << par().tA << std::endl; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         LOG(Message) << "Generating sequential source with conserved " | ||||
|                      << par().curr_type << " current insertion (mu = "  | ||||
|                      << par().mu << ") for " << par().tA << " <= t <= "  | ||||
|                      << par().tB << std::endl; | ||||
|     } | ||||
|     auto &src = envGet(PropagatorField, getName()); | ||||
|     auto &q   = envGet(PropagatorField, par().q); | ||||
|     auto &mat = envGet(FMat, par().action); | ||||
|  | ||||
|     std::vector<Real> mom = strToVec<Real>(par().mom); | ||||
|     mat.SeqConservedCurrent(q, src, par().curr_type, par().mu,  | ||||
|                             mom, par().tA, par().tB); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_SeqConserved_hpp_ | ||||
							
								
								
									
										178
									
								
								extras/Hadrons/Modules/MSource/SeqGamma.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								extras/Hadrons/Modules/MSource/SeqGamma.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,178 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSource/SeqGamma.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSource_SeqGamma_hpp_ | ||||
| #define Hadrons_MSource_SeqGamma_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Sequential source | ||||
|  ----------------------------- | ||||
|  * src_x = q_x * theta(x_3 - tA) * theta(tB - x_3) * gamma * exp(i x.mom) | ||||
|   | ||||
|  * options: | ||||
|  - q: input propagator (string) | ||||
|  - tA: begin timeslice (integer) | ||||
|  - tB: end timesilce (integer) | ||||
|  - gamma: gamma product to insert (integer) | ||||
|  - mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.") | ||||
|   | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         SeqGamma                                 * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSource) | ||||
|  | ||||
| class SeqGammaPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(SeqGammaPar, | ||||
|                                     std::string,    q, | ||||
|                                     unsigned int,   tA, | ||||
|                                     unsigned int,   tB, | ||||
|                                     Gamma::Algebra, gamma, | ||||
|                                     std::string,    mom); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TSeqGamma: public Module<SeqGammaPar> | ||||
| { | ||||
| public: | ||||
|     FGS_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TSeqGamma(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TSeqGamma(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     bool        hasPhase_{false}; | ||||
|     std::string momphName_, tName_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(SeqGamma, TSeqGamma<FIMPL>, MSource); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         TSeqGamma implementation                           * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TSeqGamma<FImpl>::TSeqGamma(const std::string name) | ||||
| : Module<SeqGammaPar>(name) | ||||
| , momphName_ (name + "_momph") | ||||
| , tName_ (name + "_t") | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSeqGamma<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TSeqGamma<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSeqGamma<FImpl>::setup(void) | ||||
| { | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
|     envCacheLat(Lattice<iScalar<vInteger>>, tName_); | ||||
|     envCacheLat(LatticeComplex, momphName_); | ||||
|     envTmpLat(LatticeComplex, "coor"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TSeqGamma<FImpl>::execute(void) | ||||
| { | ||||
|     if (par().tA == par().tB) | ||||
|     { | ||||
|         LOG(Message) << "Generating gamma_" << par().gamma | ||||
|                      << " sequential source at t= " << par().tA << std::endl; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         LOG(Message) << "Generating gamma_" << par().gamma | ||||
|                      << " sequential source for " | ||||
|                      << par().tA << " <= t <= " << par().tB << std::endl; | ||||
|     } | ||||
|     auto  &src = envGet(PropagatorField, getName()); | ||||
|     auto  &q   = envGet(PropagatorField, par().q); | ||||
|     auto  &ph  = envGet(LatticeComplex, momphName_); | ||||
|     auto  &t   = envGet(Lattice<iScalar<vInteger>>, tName_); | ||||
|     Gamma g(par().gamma); | ||||
|      | ||||
|     if (!hasPhase_) | ||||
|     { | ||||
|         Complex           i(0.0,1.0); | ||||
|         std::vector<Real> p; | ||||
|  | ||||
|         envGetTmp(LatticeComplex, coor); | ||||
|         p  = strToVec<Real>(par().mom); | ||||
|         ph = zero; | ||||
|         for(unsigned int mu = 0; mu < env().getNd(); mu++) | ||||
|         { | ||||
|             LatticeCoordinate(coor, mu); | ||||
|             ph = ph + (p[mu]/env().getGrid()->_fdimensions[mu])*coor; | ||||
|         } | ||||
|         ph = exp((Real)(2*M_PI)*i*ph); | ||||
|         LatticeCoordinate(t, Tp); | ||||
|         hasPhase_ = true; | ||||
|     } | ||||
|     src = where((t >= par().tA) and (t <= par().tB), ph*(g*q), 0.*q); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSource_SeqGamma_hpp_ | ||||
							
								
								
									
										161
									
								
								extras/Hadrons/Modules/MSource/Wall.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								extras/Hadrons/Modules/MSource/Wall.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,161 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSource/Wall.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSource_WallSource_hpp_ | ||||
| #define Hadrons_MSource_WallSource_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Wall source | ||||
|  ----------------------------- | ||||
|  * src_x = delta(x_3 - tW) * exp(i x.mom) | ||||
|   | ||||
|  * options: | ||||
|  - tW: source timeslice (integer) | ||||
|  - mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0.") | ||||
|   | ||||
|  */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         Wall                                               * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSource) | ||||
|  | ||||
| class WallPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(WallPar, | ||||
|                                     unsigned int, tW, | ||||
|                                     std::string, mom); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TWall: public Module<WallPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TWall(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TWall(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     bool        hasPhase_{false}; | ||||
|     std::string momphName_, tName_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Wall, TWall<FIMPL>, MSource); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                 TWall implementation                                       * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TWall<FImpl>::TWall(const std::string name) | ||||
| : Module<WallPar>(name) | ||||
| , momphName_ (name + "_momph") | ||||
| , tName_ (name + "_t") | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWall<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TWall<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWall<FImpl>::setup(void) | ||||
| { | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TWall<FImpl>::execute(void) | ||||
| {     | ||||
|     LOG(Message) << "Generating wall source at t = " << par().tW  | ||||
|                  << " with momentum " << par().mom << std::endl; | ||||
|      | ||||
|     auto  &src = envGet(PropagatorField, getName()); | ||||
|     auto  &ph  = envGet(LatticeComplex, momphName_); | ||||
|     auto  &t   = envGet(Lattice<iScalar<vInteger>>, tName_); | ||||
|      | ||||
|     if (!hasPhase_) | ||||
|     { | ||||
|         Complex           i(0.0,1.0); | ||||
|         std::vector<Real> p; | ||||
|  | ||||
|         envGetTmp(LatticeComplex, coor); | ||||
|         p  = strToVec<Real>(par().mom); | ||||
|         ph = zero; | ||||
|         for(unsigned int mu = 0; mu < env().getNd(); mu++) | ||||
|         { | ||||
|             LatticeCoordinate(coor, mu); | ||||
|             ph = ph + (p[mu]/env().getGrid()->_fdimensions[mu])*coor; | ||||
|         } | ||||
|         ph = exp((Real)(2*M_PI)*i*ph); | ||||
|         LatticeCoordinate(t, Tp); | ||||
|         hasPhase_ = true; | ||||
|     } | ||||
|  | ||||
|     src = 1.; | ||||
|     src = where((t == par().tW), src*ph, 0.*src); | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSource_WallSource_hpp_ | ||||
							
								
								
									
										163
									
								
								extras/Hadrons/Modules/MSource/Z2.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										163
									
								
								extras/Hadrons/Modules/MSource/Z2.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,163 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MSource/Z2.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MSource_Z2_hpp_ | ||||
| #define Hadrons_MSource_Z2_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   | ||||
|  Z_2 stochastic source | ||||
|  ----------------------------- | ||||
|  * src_x = eta_x * theta(x_3 - tA) * theta(tB - x_3) | ||||
|   | ||||
|  the eta_x are independent uniform random numbers in {+/- 1 +/- i} | ||||
|   | ||||
|  * options: | ||||
|  - tA: begin timeslice (integer) | ||||
|  - tB: end timesilce (integer) | ||||
|   | ||||
|  */ | ||||
|   | ||||
| /****************************************************************************** | ||||
|  *                          Z2 stochastic source                              * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MSource) | ||||
|  | ||||
| class Z2Par: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(Z2Par, | ||||
|                                     unsigned int, tA, | ||||
|                                     unsigned int, tB); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TZ2: public Module<Z2Par> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TZ2(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TZ2(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| private: | ||||
|     bool        hasT_{false}; | ||||
|     std::string tName_; | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(Z2,       TZ2<FIMPL>,        MSource); | ||||
| MODULE_REGISTER_NS(ScalarZ2, TZ2<ScalarImplCR>, MSource); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                       TZ2 template implementation                          * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TZ2<FImpl>::TZ2(const std::string name) | ||||
| : Module<Z2Par>(name) | ||||
| , tName_ (name + "_t") | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TZ2<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TZ2<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TZ2<FImpl>::setup(void) | ||||
| { | ||||
|     envCreateLat(PropagatorField, getName()); | ||||
|     envCacheLat(Lattice<iScalar<vInteger>>, tName_); | ||||
|     envTmpLat(LatticeComplex, "eta"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TZ2<FImpl>::execute(void) | ||||
| { | ||||
|     if (par().tA == par().tB) | ||||
|     { | ||||
|         LOG(Message) << "Generating Z_2 wall source at t= " << par().tA | ||||
|                      << std::endl; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         LOG(Message) << "Generating Z_2 band for " << par().tA << " <= t <= " | ||||
|                      << par().tB << std::endl; | ||||
|     } | ||||
|      | ||||
|     auto    &src = envGet(PropagatorField, getName()); | ||||
|     auto    &t   = envGet(Lattice<iScalar<vInteger>>, tName_); | ||||
|     Complex shift(1., 1.); | ||||
|  | ||||
|     if (!hasT_) | ||||
|     { | ||||
|         LatticeCoordinate(t, Tp); | ||||
|         hasT_ = true; | ||||
|     } | ||||
|     envGetTmp(LatticeComplex, eta); | ||||
|     bernoulli(*env().get4dRng(), eta); | ||||
|     eta = (2.*eta - shift)*(1./::sqrt(2.)); | ||||
|     eta = where((t >= par().tA) and (t <= par().tB), eta, 0.*eta); | ||||
|     src = 1.; | ||||
|     src = src*eta; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_MSource_Z2_hpp_ | ||||
							
								
								
									
										186
									
								
								extras/Hadrons/Modules/MUtilities/TestSeqConserved.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										186
									
								
								extras/Hadrons/Modules/MUtilities/TestSeqConserved.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,186 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MUtilities/TestSeqConserved.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MUtilities_TestSeqConserved_hpp_ | ||||
| #define Hadrons_MUtilities_TestSeqConserved_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /* | ||||
|   Ward Identity contractions using sequential propagators. | ||||
|  ----------------------------- | ||||
|   | ||||
|  * options: | ||||
|  - q:      point source propagator, 5D if available (string) | ||||
|  - qSeq:   result of sequential insertion of conserved current using q (string) | ||||
|  - action: action used for computation of q (string) | ||||
|  - origin: string giving point source origin of q (string) | ||||
|  - t_J:    time at which sequential current is inserted (int) | ||||
|  - mu:     Lorentz index of current inserted (int) | ||||
|  - curr:   current type, e.g. vector/axial (Current) | ||||
| */ | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                            TestSeqConserved                                * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MUtilities) | ||||
|  | ||||
| class TestSeqConservedPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(TestSeqConservedPar, | ||||
|                                     std::string,  q, | ||||
|                                     std::string,  qSeq, | ||||
|                                     std::string,  action, | ||||
|                                     std::string,  origin, | ||||
|                                     unsigned int, t_J, | ||||
|                                     unsigned int, mu, | ||||
|                                     Current,      curr); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TTestSeqConserved: public Module<TestSeqConservedPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TTestSeqConserved(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TTestSeqConserved(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(TestSeqConserved, TTestSeqConserved<FIMPL>, MUtilities); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                     TTestSeqConserved implementation                       * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TTestSeqConserved<FImpl>::TTestSeqConserved(const std::string name) | ||||
| : Module<TestSeqConservedPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TTestSeqConserved<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().qSeq, par().action}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TTestSeqConserved<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TTestSeqConserved<FImpl>::setup(void) | ||||
| { | ||||
|     auto Ls = env().getObjectLs(par().q); | ||||
|     if (Ls != env().getObjectLs(par().action)) | ||||
|     { | ||||
|         HADRON_ERROR(Size, "Ls mismatch between quark action and propagator"); | ||||
|     } | ||||
|     envTmpLat(PropagatorField, "tmp"); | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TTestSeqConserved<FImpl>::execute(void) | ||||
| { | ||||
|     // Check sequential insertion of current gives same result as conserved  | ||||
|     // current sink upon contraction. Assume q uses a point source. | ||||
|  | ||||
|     auto                  &q    = envGet(PropagatorField, par().q); | ||||
|     auto                  &qSeq = envGet(PropagatorField, par().qSeq); | ||||
|     auto                  &act  = envGet(FMat, par().action); | ||||
|     Gamma                 g5(Gamma::Algebra::Gamma5); | ||||
|     Gamma::Algebra        gA = (par().curr == Current::Axial) ? | ||||
|                                   Gamma::Algebra::Gamma5 : | ||||
|                                   Gamma::Algebra::Identity; | ||||
|     Gamma                 g(gA); | ||||
|     SitePropagator        qSite; | ||||
|     Complex               test_S, test_V, check_S, check_V; | ||||
|     std::vector<TComplex> check_buf; | ||||
|     std::vector<int>      siteCoord; | ||||
|  | ||||
|     envGetTmp(PropagatorField, tmp); | ||||
|     envGetTmp(LatticeComplex, c); | ||||
|     siteCoord = strToVec<int>(par().origin); | ||||
|     peekSite(qSite, qSeq, siteCoord); | ||||
|     test_S = trace(qSite*g); | ||||
|     test_V = trace(qSite*g*Gamma::gmu[par().mu]); | ||||
|     act.ContractConservedCurrent(q, q, tmp, par().curr, par().mu); | ||||
|     c = trace(tmp*g); | ||||
|     sliceSum(c, check_buf, Tp); | ||||
|     check_S = TensorRemove(check_buf[par().t_J]); | ||||
|  | ||||
|     c = trace(tmp*g*Gamma::gmu[par().mu]); | ||||
|     sliceSum(c, check_buf, Tp); | ||||
|     check_V = TensorRemove(check_buf[par().t_J]); | ||||
|  | ||||
|     LOG(Message) << "Test S  = " << abs(test_S)   << std::endl; | ||||
|     LOG(Message) << "Test V  = " << abs(test_V) << std::endl; | ||||
|     LOG(Message) << "Check S = " << abs(check_S) << std::endl; | ||||
|     LOG(Message) << "Check V = " << abs(check_V) << std::endl; | ||||
|  | ||||
|     // Check difference = 0 | ||||
|     check_S -= test_S; | ||||
|     check_V -= test_V; | ||||
|  | ||||
|     LOG(Message) << "Consistency check for sequential conserved "  | ||||
|                  << par().curr << " current insertion: " << std::endl;  | ||||
|     LOG(Message) << "Diff S  = " << abs(check_S) << std::endl; | ||||
|     LOG(Message) << "Diff V  = " << abs(check_V) << std::endl; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_TestSeqConserved_hpp_ | ||||
							
								
								
									
										150
									
								
								extras/Hadrons/Modules/MUtilities/TestSeqGamma.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								extras/Hadrons/Modules/MUtilities/TestSeqGamma.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,150 @@ | ||||
| /************************************************************************************* | ||||
|  | ||||
| Grid physics library, www.github.com/paboyle/Grid  | ||||
|  | ||||
| Source file: extras/Hadrons/Modules/MUtilities/TestSeqGamma.hpp | ||||
|  | ||||
| Copyright (C) 2015-2018 | ||||
|  | ||||
| Author: Antonin Portelli <antonin.portelli@me.com> | ||||
| Author: Lanny91 <andrew.lawson@gmail.com> | ||||
|  | ||||
| This program is free software; you can redistribute it and/or modify | ||||
| it under the terms of the GNU General Public License as published by | ||||
| the Free Software Foundation; either version 2 of the License, or | ||||
| (at your option) any later version. | ||||
|  | ||||
| This program is distributed in the hope that it will be useful, | ||||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| GNU General Public License for more details. | ||||
|  | ||||
| You should have received a copy of the GNU General Public License along | ||||
| with this program; if not, write to the Free Software Foundation, Inc., | ||||
| 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
|  | ||||
| See the full license in the file "LICENSE" in the top level distribution directory | ||||
| *************************************************************************************/ | ||||
| /*  END LEGAL */ | ||||
|  | ||||
| #ifndef Hadrons_MUtilities_TestSeqGamma_hpp_ | ||||
| #define Hadrons_MUtilities_TestSeqGamma_hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                              TestSeqGamma                                  * | ||||
|  ******************************************************************************/ | ||||
| BEGIN_MODULE_NAMESPACE(MUtilities) | ||||
|  | ||||
| class TestSeqGammaPar: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(TestSeqGammaPar, | ||||
|                                     std::string,    q, | ||||
|                                     std::string,    qSeq, | ||||
|                                     std::string,    origin, | ||||
|                                     Gamma::Algebra, gamma, | ||||
|                                     unsigned int,   t_g); | ||||
| }; | ||||
|  | ||||
| template <typename FImpl> | ||||
| class TTestSeqGamma: public Module<TestSeqGammaPar> | ||||
| { | ||||
| public: | ||||
|     FERM_TYPE_ALIASES(FImpl,); | ||||
| public: | ||||
|     // constructor | ||||
|     TTestSeqGamma(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~TTestSeqGamma(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
| protected: | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER_NS(TestSeqGamma, TTestSeqGamma<FIMPL>, MUtilities); | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                      TTestSeqGamma implementation                          * | ||||
|  ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| TTestSeqGamma<FImpl>::TTestSeqGamma(const std::string name) | ||||
| : Module<TestSeqGammaPar>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TTestSeqGamma<FImpl>::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in = {par().q, par().qSeq}; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| template <typename FImpl> | ||||
| std::vector<std::string> TTestSeqGamma<FImpl>::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TTestSeqGamma<FImpl>::setup(void) | ||||
| { | ||||
|     envTmpLat(LatticeComplex, "c"); | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| template <typename FImpl> | ||||
| void TTestSeqGamma<FImpl>::execute(void) | ||||
| { | ||||
|     auto                  &q    = envGet(PropagatorField, par().q); | ||||
|     auto                  &qSeq = envGet(PropagatorField, par().qSeq); | ||||
|     Gamma                 g5(Gamma::Algebra::Gamma5); | ||||
|     Gamma                 g(par().gamma); | ||||
|     SitePropagator        qSite; | ||||
|     Complex               test, check; | ||||
|     std::vector<TComplex> check_buf; | ||||
|     std::vector<int>      siteCoord; | ||||
|  | ||||
|     // Check sequential insertion of gamma matrix gives same result as  | ||||
|     // insertion of gamma at sink upon contraction. Assume q uses a point  | ||||
|     // source. | ||||
|      | ||||
|     envGetTmp(LatticeComplex, c); | ||||
|     siteCoord = strToVec<int>(par().origin); | ||||
|     peekSite(qSite, qSeq, siteCoord); | ||||
|     test = trace(g*qSite); | ||||
|  | ||||
|     c = trace(adj(g)*g5*adj(q)*g5*g*q); | ||||
|     sliceSum(c, check_buf, Tp); | ||||
|     check = TensorRemove(check_buf[par().t_g]); | ||||
|  | ||||
|     LOG(Message) << "Seq Result = " << abs(test)  << std::endl; | ||||
|     LOG(Message) << "Reference  = " << abs(check) << std::endl; | ||||
|  | ||||
|     // Check difference = 0 | ||||
|     check -= test; | ||||
|  | ||||
|     LOG(Message) << "Consistency check for sequential " << par().gamma   | ||||
|                  << " insertion = " << abs(check) << std::endl; | ||||
| } | ||||
|  | ||||
| END_MODULE_NAMESPACE | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons_TestSeqGamma_hpp_ | ||||
							
								
								
									
										39
									
								
								extras/Hadrons/Modules/templates/Module.cc.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								extras/Hadrons/Modules/templates/Module.cc.template
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| #include <Grid/Hadrons/Modules/___FILEBASENAME___.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                  T___FILEBASENAME___ implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| T___FILEBASENAME___::T___FILEBASENAME___(const std::string name) | ||||
| : Module<___FILEBASENAME___Par>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> T___FILEBASENAME___::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> T___FILEBASENAME___::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void T___FILEBASENAME___::setup(void) | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void T___FILEBASENAME___::execute(void) | ||||
| { | ||||
|  | ||||
| } | ||||
							
								
								
									
										40
									
								
								extras/Hadrons/Modules/templates/Module.hpp.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								extras/Hadrons/Modules/templates/Module.hpp.template
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| #ifndef Hadrons____FILEBASENAME____hpp_ | ||||
| #define Hadrons____FILEBASENAME____hpp_ | ||||
|  | ||||
| #include <Grid/Hadrons/Global.hpp> | ||||
| #include <Grid/Hadrons/Module.hpp> | ||||
| #include <Grid/Hadrons/ModuleFactory.hpp> | ||||
|  | ||||
| BEGIN_HADRONS_NAMESPACE | ||||
|  | ||||
| /****************************************************************************** | ||||
|  *                         ___FILEBASENAME___                                 * | ||||
|  ******************************************************************************/ | ||||
| class ___FILEBASENAME___Par: Serializable | ||||
| { | ||||
| public: | ||||
|     GRID_SERIALIZABLE_CLASS_MEMBERS(___FILEBASENAME___Par,  | ||||
|                                     unsigned int, i); | ||||
| }; | ||||
|  | ||||
| class T___FILEBASENAME___: public Module<___FILEBASENAME___Par> | ||||
| { | ||||
| public: | ||||
|     // constructor | ||||
|     T___FILEBASENAME___(const std::string name); | ||||
|     // destructor | ||||
|     virtual ~T___FILEBASENAME___(void) = default; | ||||
|     // dependency relation | ||||
|     virtual std::vector<std::string> getInput(void); | ||||
|     virtual std::vector<std::string> getOutput(void); | ||||
|     // setup | ||||
|     virtual void setup(void); | ||||
|     // execution | ||||
|     virtual void execute(void); | ||||
| }; | ||||
|  | ||||
| MODULE_REGISTER(___FILEBASENAME___, T___FILEBASENAME___); | ||||
|  | ||||
| END_HADRONS_NAMESPACE | ||||
|  | ||||
| #endif // Hadrons____FILEBASENAME____hpp_ | ||||
							
								
								
									
										40
									
								
								extras/Hadrons/Modules/templates/Module_in_NS.cc.template
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								extras/Hadrons/Modules/templates/Module_in_NS.cc.template
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| #include <Grid/Hadrons/Modules/___NAMESPACE___/___FILEBASENAME___.hpp> | ||||
|  | ||||
| using namespace Grid; | ||||
| using namespace Hadrons; | ||||
| using namespace ___NAMESPACE___; | ||||
|  | ||||
| /****************************************************************************** | ||||
| *                  T___FILEBASENAME___ implementation                             * | ||||
| ******************************************************************************/ | ||||
| // constructor ///////////////////////////////////////////////////////////////// | ||||
| T___FILEBASENAME___::T___FILEBASENAME___(const std::string name) | ||||
| : Module<___FILEBASENAME___Par>(name) | ||||
| {} | ||||
|  | ||||
| // dependencies/products /////////////////////////////////////////////////////// | ||||
| std::vector<std::string> T___FILEBASENAME___::getInput(void) | ||||
| { | ||||
|     std::vector<std::string> in; | ||||
|      | ||||
|     return in; | ||||
| } | ||||
|  | ||||
| std::vector<std::string> T___FILEBASENAME___::getOutput(void) | ||||
| { | ||||
|     std::vector<std::string> out = {getName()}; | ||||
|      | ||||
|     return out; | ||||
| } | ||||
|  | ||||
| // setup /////////////////////////////////////////////////////////////////////// | ||||
| void T___FILEBASENAME___::setup(void) | ||||
| { | ||||
|  | ||||
| } | ||||
|  | ||||
| // execution /////////////////////////////////////////////////////////////////// | ||||
| void T___FILEBASENAME___::execute(void) | ||||
| { | ||||
|  | ||||
| } | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user