options_setup.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #include <unistd.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdio.h>
  5. // 25
  6. void seed_increment(char *seed) {
  7. if (seed[0]) {
  8. if (seed[0] == 'z') {
  9. seed_increment(seed + 1);
  10. seed[0] = 'a';
  11. }
  12. else {
  13. seed[0]++;
  14. }
  15. }
  16. else {
  17. seed[1] = 0;
  18. seed[0] = 'a';
  19. }
  20. }
  21. // 3 per power of 10
  22. // 4 powers of 10
  23. // 4 groups
  24. // 48 + 4 = 52
  25. void next_num_documents(int *documents, int *groups, int *nodes, char *seed) {
  26. int max_num = *groups * 1000000;
  27. if (*documents >= max_num) {
  28. switch (*groups) {
  29. case 16:
  30. *groups = 32;
  31. *documents = 3200;
  32. break;
  33. case 32:
  34. *groups = 64;
  35. *documents = 6400;
  36. break;
  37. case 64:
  38. *groups = 128;
  39. *documents = 12800;
  40. break;
  41. case 128:
  42. seed_increment(seed);
  43. *groups = 16;
  44. *documents = 1600;
  45. break;
  46. }
  47. } else {
  48. int first_digit = (*documents / *groups);
  49. while (first_digit >= 10)
  50. first_digit /= 10;
  51. switch (first_digit) {
  52. case 1:
  53. case 5:
  54. *documents *= 2;
  55. break;
  56. case 2:
  57. *documents = (*documents * 5) / 2;
  58. break;
  59. }
  60. }
  61. }
  62. // 5
  63. void next_node_type(char *node_type, int *documents, int *groups, int *nodes, char *seed) {
  64. switch (node_type[1]) {
  65. case 'd':
  66. node_type[1] = 'l';
  67. break;
  68. case 'l':
  69. node_type[1] = 'q';
  70. break;
  71. case 'q':
  72. node_type[1] = 'r';
  73. break;
  74. case 'r':
  75. node_type[1] = 'b';
  76. break;
  77. case 'b':
  78. next_num_documents(documents, groups, nodes, seed);
  79. node_type[1] = 'd';
  80. break;
  81. }
  82. }
  83. int main(int argc, char *argv[]) {
  84. int num_machines = 1;
  85. int which_machine = 0;
  86. int num_documents = 1600;
  87. int document_sizes = 1024;
  88. int num_groups = 16;
  89. int num_nodes = 64;
  90. char which_node[3];
  91. char seed[3];
  92. FILE *fout;
  93. if (argc > 2) {
  94. num_machines = atoi(argv[1]);
  95. which_machine = atoi(argv[2]);
  96. }
  97. strcpy(which_node, "-d");
  98. strcpy(seed, "a");
  99. fout = fopen("test_options", "w");
  100. for (int i = 0; i < 6500; i++) {
  101. if (i % num_machines == which_machine)
  102. fprintf(fout, "%d,%d,%d,%d,%s,%s,%s\n", num_documents, document_sizes, num_groups, num_nodes, "--seed", seed, which_node);
  103. next_node_type(which_node, &num_documents, &num_groups, &num_nodes, seed);
  104. }
  105. fclose(fout);
  106. return 0;
  107. }