OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-CompactHash commits / af10f54

Fixing help output so it doesn't segmentation faults after message
af10f5403af93728825c0a414ee14fbb11befc1e
by brobey <brobey@lanl.gov> · 2015-10-25T05:20:18.000Z

Changed files (4) +109 -32

HashFactory/HashFactory.c +54 -20
……@@ -1,4 +1,31 @@
11
2/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18/* This header is separate from features.h so that the compiler can
19 include it implicitly at the start of every compilation. It must
20 not itself include <features.h> or any other header that includes
21 <features.h> because the implicit include comes before any feature
22 test macros that may be defined in a source file before it first
23 explicitly includes a system header. GCC knows the name of this
24 header in order to preinclude it. */
25/* We do support the IEC 559 math functionality, real and complex. */
26/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
27 Unicode 6.0. */
28/* We do not support C11 <threads.h>. */
229/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
330 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
431 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -36,11 +63,9 @@
3663 * @date Thu Jun 6 2013
3764 */
3865//
39
4066#ifdef _OPENMP
4167#include <omp.h>
4268#endif
43
4469#include "HashFactory.h"
4570#ifdef HAVE_OPENCL
4671#ifdef __APPLE_CC__
……@@ -124,9 +149,7 @@ int clFinish(int command_queue) {
124149}
125150#endif
126151#define PRIME_NUM_CHECKS 20
127
128152#include <math.h>
129
130153/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
131154 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
132155 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -158,7 +181,6 @@ int clFinish(int command_queue) {
158181 *
159182 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
160183 */
161
162184/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
163185 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
164186 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -314,7 +336,6 @@ int clFinish(int command_queue) {
314336 *
315337 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
316338 */
317
318339/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
319340 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
320341 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -439,19 +460,14 @@ int clFinish(int command_queue) {
439460 *
440461 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
441462 */
442
443463static int reportLevel = 0;
444
445464const char *HashFactory_source;
446
447465const char *Hash_GetKernelSourceString() {
448466 return HashFactory_source;
449467}
450
451468size_t roundUpToNearest(size_t x, size_t r) {
452469 return (((x - 1) / r) + 1) * r;
453470}
454
455471int modularPow(int base, int exponent, int modulus) {
456472 int result = 1;
457473 while (exponent) {
……@@ -462,7 +478,6 @@ int modularPow(int base, int exponent, int modulus) {
462478 }
463479 return result;
464480}
465
466481int largestProthPrimeUnder(int N) {
467482 if (N < 4) {
468483 return N;
……@@ -493,7 +508,6 @@ int largestProthPrimeUnder(int N) {
493508 }
494509 return 3;
495510}
496
497511int smallestProthPrimeAbove(int N) {
498512 if (N < 4) {
499513 return N;
……@@ -524,7 +538,6 @@ int smallestProthPrimeAbove(int N) {
524538 }
525539 return 3;
526540}
527
528541int intLog2(int n) {
529542 int result = 0;
530543 while (n >>= 1) {
……@@ -532,15 +545,12 @@ int intLog2(int n) {
532545 }
533546 return result;
534547}
535
536548void Hash_SetReportLevel(int level) {
537549 reportLevel = level;
538550}
539
540551int Hash_GetReportLevel() {
541552 return reportLevel;
542553}
543
544554char *Hash_ExitCodeString(int exitCode) {
545555 switch (exitCode) {
546556 case HASH_EXIT_CODE_NORMAL:
……@@ -559,7 +569,6 @@ char *Hash_ExitCodeString(int exitCode) {
559569 return "Unknown";
560570 }
561571}
562
563572void Hash_ExitCodeDebug(int exitCode) {
564573 if (exitCode != HASH_EXIT_CODE_NORMAL) {
565574 printf("HashExitCode: %s\n", Hash_ExitCodeString(exitCode));
……@@ -5794,6 +5803,33 @@ int intintLCGQuadraticOpenCompactOpenMPHash_InsertNoOverwrite(intintHash_Table *
57945803}
57955804const char *HashFactory_source =
57965805"\n"
5806"/* Copyright (C) 1991-2012 Free Software Foundation, Inc.\n"
5807" This file is part of the GNU C Library.\n"
5808"\n"
5809" The GNU C Library is free software; you can redistribute it and/or\n"
5810" modify it under the terms of the GNU Lesser General Public\n"
5811" License as published by the Free Software Foundation; either\n"
5812" version 2.1 of the License, or (at your option) any later version.\n"
5813"\n"
5814" The GNU C Library is distributed in the hope that it will be useful,\n"
5815" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
5816" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
5817" Lesser General Public License for more details.\n"
5818"\n"
5819" You should have received a copy of the GNU Lesser General Public\n"
5820" License along with the GNU C Library; if not, see\n"
5821" <http://www.gnu.org/licenses/>. */\n"
5822"/* This header is separate from features.h so that the compiler can\n"
5823" include it implicitly at the start of every compilation. It must\n"
5824" not itself include <features.h> or any other header that includes\n"
5825" <features.h> because the implicit include comes before any feature\n"
5826" test macros that may be defined in a source file before it first\n"
5827" explicitly includes a system header. GCC knows the name of this\n"
5828" header in order to preinclude it. */\n"
5829"/* We do support the IEC 559 math functionality, real and complex. */\n"
5830"/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /\n"
5831" Unicode 6.0. */\n"
5832"/* We do not support C11 <threads.h>. */\n"
57975833"/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced\n"
57985834" * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National \n"
57995835" * Laboratory (LANL), which is operated by Los Alamos National Security, LLC\n"
……@@ -5825,7 +5861,6 @@ const char *HashFactory_source =
58255861" *\n"
58265862" * This is LANL Copyright Disclosure C14043/LA-CC-14-003\n"
58275863" */\n"
5828"\n"
58295864"int intintIdentityPerfectCLHash_InsertSingle(__global char *tableData,\n"
58305865" int key, int value);\n"
58315866"int intintIdentityPerfectCLHash_InnerInsertSingle(__global char *tableData,\n"
……@@ -6023,7 +6058,6 @@ const char *HashFactory_source =
60236058" __global int *values);\n"
60246059"int intintHash_InsertSingleNoOverwrite(__global char *tableData, int key,\n"
60256060" int value);\n"
6026"\n"
60276061"#define HASH_REPORT_NEVER /**/ 0\n"
60286062"#define HASH_REPORT_CYCLE /**/ 1\n"
60296063"#define HASH_REPORT_END /****/ 2\n"
HashFactory/HashFactory.cl +27 -2
……@@ -1,4 +1,31 @@
11
2/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18/* This header is separate from features.h so that the compiler can
19 include it implicitly at the start of every compilation. It must
20 not itself include <features.h> or any other header that includes
21 <features.h> because the implicit include comes before any feature
22 test macros that may be defined in a source file before it first
23 explicitly includes a system header. GCC knows the name of this
24 header in order to preinclude it. */
25/* We do support the IEC 559 math functionality, real and complex. */
26/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
27 Unicode 6.0. */
28/* We do not support C11 <threads.h>. */
229/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
330 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
431 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -30,7 +57,6 @@
3057 *
3158 * This is LANL Copyright Disclosure C14043/LA-CC-14-003
3259 */
33
3460int intintIdentityPerfectCLHash_InsertSingle(__global char *tableData,
3561 int key, int value);
3662int intintIdentityPerfectCLHash_InnerInsertSingle(__global char *tableData,
……@@ -228,7 +254,6 @@ int intintHash_InsertNoOverwrite(__global char *tableData,
228254 __global int *values);
229255int intintHash_InsertSingleNoOverwrite(__global char *tableData, int key,
230256 int value);
231
232257#define HASH_REPORT_NEVER /**/ 0
233258#define HASH_REPORT_CYCLE /**/ 1
234259#define HASH_REPORT_END /****/ 2
HashFactory/HashFactory.h +27 -10
……@@ -1,4 +1,31 @@
11
2/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18/* This header is separate from features.h so that the compiler can
19 include it implicitly at the start of every compilation. It must
20 not itself include <features.h> or any other header that includes
21 <features.h> because the implicit include comes before any feature
22 test macros that may be defined in a source file before it first
23 explicitly includes a system header. GCC knows the name of this
24 header in order to preinclude it. */
25/* We do support the IEC 559 math functionality, real and complex. */
26/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
27 Unicode 6.0. */
28/* We do not support C11 <threads.h>. */
229/* Copyright 2013-14. Los Alamos National Security, LLC. This material was produced
330 * under U.S. Government contract DE-AC52-06NA25396 for Los Alamos National
431 * Laboratory (LANL), which is operated by Los Alamos National Security, LLC
……@@ -36,7 +63,6 @@
3663 * @date Thu Jun 6 2013
3764 */
3865//
39
4066#ifndef HASHFACTORY_H
4167#define HASHFACTORY_H
4268//
……@@ -188,11 +214,9 @@ int clFinish(int command_queue);
188214#define HASH_BUCKET_STATUS_EMPTY /**/ -1
189215#define HASH_BUCKET_STATUS_FULL /***/ -2
190216#define HASH_BUCKET_STATUS_LOCK /***/ -3
191
192217#ifdef __cplusplus
193218extern "C" {
194219#endif
195
196220/**
197221 * Hash_ExitCodeString will return a string representation of the given exit
198222 * code.
……@@ -202,7 +226,6 @@ extern "C" {
202226 * @return A string representation of that exit code.
203227 */
204228 char *Hash_ExitCodeString(int exitCode);
205
206229/**
207230 * Hash_ExitCodeDebug will print a string representation of the given exit code
208231 * if it is not EXIT_CODE_NORMAL.
……@@ -210,7 +233,6 @@ extern "C" {
210233 * @param exitCode
211234 */
212235 void Hash_ExitCodeDebug(int exitCode);
213
214236/**
215237 * Hash_SetReportLevel sets a static report level variable in hash.c. It should
216238 * be called before hash tables are created.
……@@ -218,7 +240,6 @@ extern "C" {
218240 * @param level The level of data collection desired.
219241 */
220242 void Hash_SetReportLevel(int level);
221
222243/**
223244 * Hash_GetReportLevel gets this variable.
224245 *
……@@ -234,11 +255,9 @@ extern "C" {
234255 * last important call.
235256 */
236257 int Hash_GetReportLevel();
237
238258 const char *Hash_GetKernelSourceString();
239259 int smallestProthPrimeAbove(int N);
240260 int largestProthPrimeUnder(int N);
241
242261 typedef struct intintHash_Table_ intintHash_Table;
243262 typedef struct intintCLHash_Table_ intintCLHash_Table;
244263 typedef struct intintHash_Factory_ intintHash_Factory;
……@@ -859,9 +878,7 @@ extern "C" {
859878 int intintLCGQuadraticOpenCompactOpenMPHash_BufferInsertNoOverwrite
860879 (intintHash_Table * table, size_t numEntries, cl_mem keysBuffer,
861880 cl_mem valuesBuffer);
862
863881#ifdef __cplusplus
864882}
865883#endif /* __cplusplus */
866
867884#endif /* HASHFACTORY_H */
neigh2d.c +1 -0
……@@ -251,6 +251,7 @@ int main (int argc, const char * argv[])
251251 printf("Use -r for randomization of cell data to see performance without cache\n");
252252 printf("Use -n for min mesh size and -N for max mesh size [ default is 256 min to 256 max ]\n");
253253 printf("Use -l for min levmx and -L for max levmx [ default is 1 min to 5 max ]\n");
254 return 0;
254255 }
255256 if (strcmp(argv[i], "-r") == 0) {
256257 randomize = true;