OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-CompactHash commits / 524a543

Adding C definitions
524a54384f5db40492b84dfe893bf65953ceb550
by Bob Robey <brobey@lanl.gov> · 2015-10-25T04:37:41.000Z

Changed files (2) +54 -10

HashFactory/HashFactory.c +40 -5
……@@ -684,6 +684,10 @@ intintHash_Factory *intintHash_CreateFactory(int hashTypes, int *emptyValue,
684684 intintIdentityPerfectCLHash_CreateFactory(factory,
685685 hashIndex);
686686 break;
687 case IDENTITY_PERFECT_OPENMP_HASH_ID:
688 intintIdentityPerfectOpenMPHash_CreateFactory(factory,
689 hashIndex);
690 break;
687691 case IDENTITY_SENTINEL_PERFECT_HASH_ID:
688692 intintIdentitySentinelPerfectHash_CreateFactory(factory,
689693 hashIndex);
……@@ -692,6 +696,10 @@ intintHash_Factory *intintHash_CreateFactory(int hashTypes, int *emptyValue,
692696 intintIdentitySentinelPerfectCLHash_CreateFactory
693697 (factory, hashIndex);
694698 break;
699 case IDENTITY_SENTINEL_PERFECT_OPENMP_HASH_ID:
700 intintIdentitySentinelPerfectOpenMPHash_CreateFactory
701 (factory, hashIndex);
702 break;
695703 case LCG_LINEAR_OPEN_COMPACT_HASH_ID:
696704 intintLCGLinearOpenCompactHash_CreateFactory(factory,
697705 hashIndex);
……@@ -700,6 +708,10 @@ intintHash_Factory *intintHash_CreateFactory(int hashTypes, int *emptyValue,
700708 intintLCGLinearOpenCompactCLHash_CreateFactory(factory,
701709 hashIndex);
702710 break;
711 case LCG_LINEAR_OPEN_COMPACT_OPENMP_HASH_ID:
712 intintLCGLinearOpenCompactOpenMPHash_CreateFactory
713 (factory, hashIndex);
714 break;
703715 case LCG_QUADRATIC_OPEN_COMPACT_HASH_ID:
704716 intintLCGQuadraticOpenCompactHash_CreateFactory(factory,
705717 hashIndex);
……@@ -708,14 +720,18 @@ intintHash_Factory *intintHash_CreateFactory(int hashTypes, int *emptyValue,
708720 intintLCGQuadraticOpenCompactCLHash_CreateFactory
709721 (factory, hashIndex);
710722 break;
723 case LCG_QUADRATIC_OPEN_COMPACT_OPENMP_HASH_ID:
724 intintLCGQuadraticOpenCompactOpenMPHash_CreateFactory
725 (factory, hashIndex);
726 break;
711727 }
712728 }
713729 return factory;
714730}
715731int intintHash_DestroyFactory(intintHash_Factory * factory) {
716 int hashType;
717 for (int hashIndex = 0; hashIndex < HASH_NUM_HASHES;
718 hashType = 1 << hashIndex) {
732 int hashType = 1;
733 for (int hashIndex = 0; hashIndex < HASH_NUM_HASHES; hashIndex++) {
734 hashType = 1 << hashIndex;
719735 switch (hashType & factory->hashTypesAvailable) {
720736 case IDENTITY_PERFECT_HASH_ID:
721737 intintIdentityPerfectHash_DestroyFactory(factory,
……@@ -725,6 +741,10 @@ int intintHash_DestroyFactory(intintHash_Factory * factory) {
725741 intintIdentityPerfectCLHash_DestroyFactory(factory,
726742 hashIndex);
727743 break;
744 case IDENTITY_PERFECT_OPENMP_HASH_ID:
745 intintIdentityPerfectOpenMPHash_DestroyFactory(factory,
746 hashIndex);
747 break;
728748 case IDENTITY_SENTINEL_PERFECT_HASH_ID:
729749 intintIdentitySentinelPerfectHash_DestroyFactory
730750 (factory, hashIndex);
……@@ -733,6 +753,10 @@ int intintHash_DestroyFactory(intintHash_Factory * factory) {
733753 intintIdentitySentinelPerfectCLHash_DestroyFactory
734754 (factory, hashIndex);
735755 break;
756 case IDENTITY_SENTINEL_PERFECT_OPENMP_HASH_ID:
757 intintIdentitySentinelPerfectOpenMPHash_DestroyFactory
758 (factory, hashIndex);
759 break;
736760 case LCG_LINEAR_OPEN_COMPACT_HASH_ID:
737761 intintLCGLinearOpenCompactHash_DestroyFactory(factory,
738762 hashIndex);
……@@ -741,6 +765,10 @@ int intintHash_DestroyFactory(intintHash_Factory * factory) {
741765 intintLCGLinearOpenCompactCLHash_DestroyFactory(factory,
742766 hashIndex);
743767 break;
768 case LCG_LINEAR_OPEN_COMPACT_OPENMP_HASH_ID:
769 intintLCGLinearOpenCompactOpenMPHash_DestroyFactory
770 (factory, hashIndex);
771 break;
744772 case LCG_QUADRATIC_OPEN_COMPACT_HASH_ID:
745773 intintLCGQuadraticOpenCompactHash_DestroyFactory
746774 (factory, hashIndex);
……@@ -749,6 +777,10 @@ int intintHash_DestroyFactory(intintHash_Factory * factory) {
749777 intintLCGQuadraticOpenCompactCLHash_DestroyFactory
750778 (factory, hashIndex);
751779 break;
780 case LCG_QUADRATIC_OPEN_COMPACT_OPENMP_HASH_ID:
781 intintLCGQuadraticOpenCompactOpenMPHash_DestroyFactory
782 (factory, hashIndex);
783 break;
752784 }
753785 hashIndex++;
754786 }
……@@ -769,6 +801,7 @@ intintHash_Table *intintHash_CreateTable(intintHash_Factory * factory,
769801 if (hashTypes == 0) {
770802 hashTypes = factory->hashTypesAvailable;
771803 if ((hashTypes & HASH_ALL_CL_HASHES)
804 && (hashTypes & HASH_ALL_OPENMP_HASHES)
772805 && (hashTypes & HASH_ALL_C_HASHES)) {
773806 hashTypes &= HASH_ALL_C_HASHES;
774807 }
……@@ -779,8 +812,10 @@ intintHash_Table *intintHash_CreateTable(intintHash_Factory * factory,
779812 exit(1);
780813 }
781814 hashTypes &= factory->hashTypesAvailable;
782 if ((hashTypes & HASH_ALL_CL_HASHES) && (hashTypes & HASH_ALL_C_HASHES)) {
783 printf("Please decide between OpenCL or C hash.\n");
815 if ((hashTypes & HASH_ALL_CL_HASHES)
816 && (hashTypes & HASH_ALL_OPENMP_HASHES)
817 && (hashTypes & HASH_ALL_C_HASHES)) {
818 printf("Please decide between OpenCL, OpenMP or C hash.\n");
784819 exit(1);
785820 }
786821 if ((hashTypes & HASH_PERFECT_HASHES) == hashTypes && keyRange == 0) {
HashFactory/HashFactory.cm +14 -5
……@@ -129,29 +129,38 @@
129129 switch(hashType & hashTypes){\
130130 case IDENTITY_PERFECT_HASH_ID: NAME##IdentityPerfectHash_CreateFactory(factory, hashIndex); break;\
131131 case IDENTITY_PERFECT_CL_HASH_ID: NAME##IdentityPerfectCLHash_CreateFactory(factory, hashIndex); break;\
132 case IDENTITY_PERFECT_OPENMP_HASH_ID: NAME##IdentityPerfectOpenMPHash_CreateFactory(factory, hashIndex); break;\
132133 case IDENTITY_SENTINEL_PERFECT_HASH_ID: NAME##IdentitySentinelPerfectHash_CreateFactory(factory, hashIndex); break;\
133134 case IDENTITY_SENTINEL_PERFECT_CL_HASH_ID: NAME##IdentitySentinelPerfectCLHash_CreateFactory(factory, hashIndex); break;\
135 case IDENTITY_SENTINEL_PERFECT_OPENMP_HASH_ID: NAME##IdentitySentinelPerfectOpenMPHash_CreateFactory(factory, hashIndex); break;\
134136 case LCG_LINEAR_OPEN_COMPACT_HASH_ID: NAME##LCGLinearOpenCompactHash_CreateFactory(factory, hashIndex); break;\
135137 case LCG_LINEAR_OPEN_COMPACT_CL_HASH_ID: NAME##LCGLinearOpenCompactCLHash_CreateFactory(factory, hashIndex); break;\
138 case LCG_LINEAR_OPEN_COMPACT_OPENMP_HASH_ID: NAME##LCGLinearOpenCompactOpenMPHash_CreateFactory(factory, hashIndex); break;\
136139 case LCG_QUADRATIC_OPEN_COMPACT_HASH_ID: NAME##LCGQuadraticOpenCompactHash_CreateFactory(factory, hashIndex); break;\
137140 case LCG_QUADRATIC_OPEN_COMPACT_CL_HASH_ID: NAME##LCGQuadraticOpenCompactCLHash_CreateFactory(factory, hashIndex); break;\
141 case LCG_QUADRATIC_OPEN_COMPACT_OPENMP_HASH_ID: NAME##LCGQuadraticOpenCompactOpenMPHash_CreateFactory(factory, hashIndex); break;\
138142 }\
139143 }\
140144 return factory;\
141145 }\
142146 \
143147 int NAME##Hash_DestroyFactory(NAME##Hash_Factory *factory){\
144 int hashType;\
145 for(int hashIndex = 0; hashIndex < HASH_NUM_HASHES; hashType = 1 << hashIndex){\
148 int hashType = 1;\
149 for(int hashIndex = 0; hashIndex < HASH_NUM_HASHES; hashIndex++){\
150 hashType = 1 << hashIndex;\
146151 switch(hashType & factory->hashTypesAvailable){\
147152 case IDENTITY_PERFECT_HASH_ID: NAME##IdentityPerfectHash_DestroyFactory(factory, hashIndex); break;\
148153 case IDENTITY_PERFECT_CL_HASH_ID: NAME##IdentityPerfectCLHash_DestroyFactory(factory, hashIndex); break;\
154 case IDENTITY_PERFECT_OPENMP_HASH_ID: NAME##IdentityPerfectOpenMPHash_DestroyFactory(factory, hashIndex); break;\
149155 case IDENTITY_SENTINEL_PERFECT_HASH_ID: NAME##IdentitySentinelPerfectHash_DestroyFactory(factory, hashIndex); break;\
150156 case IDENTITY_SENTINEL_PERFECT_CL_HASH_ID: NAME##IdentitySentinelPerfectCLHash_DestroyFactory(factory, hashIndex); break;\
157 case IDENTITY_SENTINEL_PERFECT_OPENMP_HASH_ID: NAME##IdentitySentinelPerfectOpenMPHash_DestroyFactory(factory, hashIndex); break;\
151158 case LCG_LINEAR_OPEN_COMPACT_HASH_ID: NAME##LCGLinearOpenCompactHash_DestroyFactory(factory, hashIndex); break;\
152159 case LCG_LINEAR_OPEN_COMPACT_CL_HASH_ID: NAME##LCGLinearOpenCompactCLHash_DestroyFactory(factory, hashIndex); break;\
160 case LCG_LINEAR_OPEN_COMPACT_OPENMP_HASH_ID: NAME##LCGLinearOpenCompactOpenMPHash_DestroyFactory(factory, hashIndex); break;\
153161 case LCG_QUADRATIC_OPEN_COMPACT_HASH_ID: NAME##LCGQuadraticOpenCompactHash_DestroyFactory(factory, hashIndex); break;\
154162 case LCG_QUADRATIC_OPEN_COMPACT_CL_HASH_ID: NAME##LCGQuadraticOpenCompactCLHash_DestroyFactory(factory, hashIndex); break;\
163 case LCG_QUADRATIC_OPEN_COMPACT_OPENMP_HASH_ID: NAME##LCGQuadraticOpenCompactOpenMPHash_DestroyFactory(factory, hashIndex); break;\
155164 }\
156165 hashIndex++;\
157166 }\
……@@ -170,7 +179,7 @@
170179 }\
171180 if(hashTypes == 0){\
172181 hashTypes = factory->hashTypesAvailable;\
173 if((hashTypes & HASH_ALL_CL_HASHES) && (hashTypes & HASH_ALL_C_HASHES)){\
182 if((hashTypes & HASH_ALL_CL_HASHES) && (hashTypes & HASH_ALL_OPENMP_HASHES) && (hashTypes & HASH_ALL_C_HASHES)){\
174183 hashTypes &= HASH_ALL_C_HASHES;\
175184 }\
176185 }\
……@@ -179,8 +188,8 @@
179188 exit(1);\
180189 }\
181190 hashTypes &= factory->hashTypesAvailable;\
182 if((hashTypes & HASH_ALL_CL_HASHES) && (hashTypes & HASH_ALL_C_HASHES)){\
183 printf("Please decide between OpenCL or C hash.\n");\
191 if((hashTypes & HASH_ALL_CL_HASHES) && (hashTypes & HASH_ALL_OPENMP_HASHES) && (hashTypes & HASH_ALL_C_HASHES)){\
192 printf("Please decide between OpenCL, OpenMP or C hash.\n");\
184193 exit(1);\
185194 }\
186195 if((hashTypes & HASH_PERFECT_HASHES) == hashTypes && keyRange == 0){\