Subversion Repositories Games.Chess Giants

Rev

Rev 154 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 154 Rev 156
Line 412... Line 412...
412
    int squares[64];
412
    int squares[64];
413
    int numsquares = 0;
413
    int numsquares = 0;
414
    uint64_t temp = magic_bishop_mask[i];
414
    uint64_t temp = magic_bishop_mask[i];
415
 
415
 
416
    while (temp) {
416
    while (temp) {
417
      uint64_t abit = temp & -temp;
417
      uint64_t abit = temp & (0-temp); // Pierre-Marie Baty -- signedness fix
418
 
418
 
419
      squares[numsquares++] =
419
      squares[numsquares++] =
420
          initmagicmoves_bitpos64_database[(abit *
420
          initmagicmoves_bitpos64_database[(abit *
421
              0x07EDD5E59A4E28C2ull) >> 58];
421
              0x07EDD5E59A4E28C2ull) >> 58];
422
      temp ^= abit;
422
      temp ^= abit;
Line 445... Line 445...
445
    int squares[64];
445
    int squares[64];
446
    int numsquares = 0;
446
    int numsquares = 0;
447
    uint64_t temp = magic_rook_mask[i];
447
    uint64_t temp = magic_rook_mask[i];
448
 
448
 
449
    while (temp) {
449
    while (temp) {
450
      uint64_t abit = temp & -temp;
450
      uint64_t abit = temp & (0-temp); // Pierre-Marie Baty -- signedness fix
451
 
451
 
452
      squares[numsquares++] =
452
      squares[numsquares++] =
453
          initmagicmoves_bitpos64_database[(abit *
453
          initmagicmoves_bitpos64_database[(abit *
454
              0x07EDD5E59A4E28C2ull) >> 58];
454
              0x07EDD5E59A4E28C2ull) >> 58];
455
      temp ^= abit;
455
      temp ^= abit;
Line 819... Line 819...
819
 */
819
 */
820
    mem_per_node =
820
    mem_per_node =
821
        hash_table_size * sizeof(HASH_ENTRY) / Max(smp_max_threads, 1);
821
        hash_table_size * sizeof(HASH_ENTRY) / Max(smp_max_threads, 1);
822
    for (node = 0; node < smp_max_threads; node++) {
822
    for (node = 0; node < smp_max_threads; node++) {
823
      ThreadAffinity(node);
823
      ThreadAffinity(node);
824
      memset((char *) hash_table + node * mem_per_node, 0, mem_per_node);
824
      memset((char *) hash_table + node * mem_per_node, 0, (size_t) mem_per_node); // Pierre-Marie Baty -- added type cast
825
    }
825
    }
826
    ThreadAffinity(0);
826
    ThreadAffinity(0);
827
    if (mem_per_node * Max(smp_max_threads,
827
    if (mem_per_node * Max(smp_max_threads,
828
            1) < hash_table_size * sizeof(HASH_ENTRY))
828
            1) < hash_table_size * sizeof(HASH_ENTRY))
829
      memset((char *) hash_table + smp_max_threads * mem_per_node, 0,
829
      memset((char *) hash_table + smp_max_threads * mem_per_node, 0,
830
          hash_table_size * sizeof(HASH_ENTRY) -
830
          (size_t) (hash_table_size * sizeof(HASH_ENTRY) - // Pierre-Marie Baty -- added type cast
831
          mem_per_node * smp_max_threads);
831
          mem_per_node * smp_max_threads));
832
/*
832
/*
833
 ************************************************************
833
 ************************************************************
834
 *                                                          *
834
 *                                                          *
835
 *  Second, initialize the primary hash path table, using   *
835
 *  Second, initialize the primary hash path table, using   *
836
 *  the NUMA trick to place part of the hash path table on  *
836
 *  the NUMA trick to place part of the hash path table on  *
Line 840... Line 840...
840
 */
840
 */
841
    mem_per_node =
841
    mem_per_node =
842
        hash_path_size * sizeof(HPATH_ENTRY) / Max(smp_max_threads, 1);
842
        hash_path_size * sizeof(HPATH_ENTRY) / Max(smp_max_threads, 1);
843
    for (node = 0; node < smp_max_threads; node++) {
843
    for (node = 0; node < smp_max_threads; node++) {
844
      ThreadAffinity(node);
844
      ThreadAffinity(node);
845
      memset((char *) hash_path + node * mem_per_node, 0, mem_per_node);
845
      memset((char *) hash_path + node * mem_per_node, 0, (size_t) mem_per_node); // Pierre-Marie Baty -- added type cast
846
    }
846
    }
847
    ThreadAffinity(0);
847
    ThreadAffinity(0);
848
    if (mem_per_node * Max(smp_max_threads,
848
    if (mem_per_node * Max(smp_max_threads,
849
            1) < hash_path_size * sizeof(HPATH_ENTRY))
849
            1) < hash_path_size * sizeof(HPATH_ENTRY))
850
      memset((char *) hash_path + smp_max_threads * mem_per_node, 0,
850
      memset((char *) hash_path + smp_max_threads * mem_per_node, 0,
851
          hash_path_size * sizeof(HPATH_ENTRY) -
851
          (size_t) (hash_path_size * sizeof(HPATH_ENTRY) -
852
          mem_per_node * smp_max_threads);
852
          mem_per_node * smp_max_threads)); // Pierre-Marie Baty -- added type cast
853
/*
853
/*
854
 ************************************************************
854
 ************************************************************
855
 *                                                          *
855
 *                                                          *
856
 *  Finally, initialize the primary pawn hash table, using  *
856
 *  Finally, initialize the primary pawn hash table, using  *
857
 *  the NUMA trick to place part of the pawn hash table on  *
857
 *  the NUMA trick to place part of the pawn hash table on  *
Line 862... Line 862...
862
    mem_per_node =
862
    mem_per_node =
863
        pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY) / Max(smp_max_threads,
863
        pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY) / Max(smp_max_threads,
864
        1);
864
        1);
865
    for (node = 0; node < smp_max_threads; node++) {
865
    for (node = 0; node < smp_max_threads; node++) {
866
      ThreadAffinity(node);
866
      ThreadAffinity(node);
867
      memset((char *) pawn_hash_table + node * mem_per_node, 0, mem_per_node);
867
      memset((char *) pawn_hash_table + node * mem_per_node, 0, (size_t) mem_per_node); // Pierre-Marie Baty -- added type cast
868
    }
868
    }
869
    ThreadAffinity(0);
869
    ThreadAffinity(0);
870
    if (mem_per_node * Max(smp_max_threads,
870
    if (mem_per_node * Max(smp_max_threads,
871
            1) < pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY))
871
            1) < pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY))
872
      memset((char *) pawn_hash_table + smp_max_threads * mem_per_node, 0,
872
      memset((char *) pawn_hash_table + smp_max_threads * mem_per_node, 0,
873
          pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY) -
873
          (size_t) (pawn_hash_table_size * sizeof(PAWN_HASH_ENTRY) -
874
          mem_per_node * smp_max_threads);
874
          mem_per_node * smp_max_threads)); // Pierre-Marie Baty -- added type cast
875
/*
875
/*
876
 ************************************************************
876
 ************************************************************
877
 *                                                          *
877
 *                                                          *
878
 *  Before we return, we need to re-pin this thread to the  *
878
 *  Before we return, we need to re-pin this thread to the  *
879
 *  correct processor.                                      *
879
 *  correct processor.                                      *
Line 1134... Line 1134...
1134
 */
1134
 */
1135
void InitializeLMP() {
1135
void InitializeLMP() {
1136
  int i;
1136
  int i;
1137
 
1137
 
1138
  for (i = 0; i < LMP_depth; i++)
1138
  for (i = 0; i < LMP_depth; i++)
1139
    LMP[i] = LMP_base + pow(i + .5, LMP_scale);
1139
    LMP[i] = (int) (LMP_base + pow(i + .5, LMP_scale)); // Pierre-Marie Baty -- added type cast
1140
}
1140
}
1141
 
1141
 
1142
/*
1142
/*
1143
 *******************************************************************************
1143
 *******************************************************************************
1144
 *                                                                             *
1144
 *                                                                             *
Line 1154... Line 1154...
1154
  for (d = 0; d < 32; d++)
1154
  for (d = 0; d < 32; d++)
1155
    for (m = 0; m < 64; m++)
1155
    for (m = 0; m < 64; m++)
1156
      LMR[d][m] = 0;
1156
      LMR[d][m] = 0;
1157
  for (d = 3; d < 32; d++)
1157
  for (d = 3; d < 32; d++)
1158
    for (m = 1; m < 64; m++) {
1158
    for (m = 1; m < 64; m++) {
1159
      LMR[d][m] =
1159
      LMR[d][m] = (uint8_t) // Pierre-Marie Baty -- added type cast
1160
          Max(Min(log(d * LMR_db) * log(m * LMR_mb) / LMR_s, LMR_max),
1160
          (Max(Min(log(d * LMR_db) * log(m * LMR_mb) / LMR_s, LMR_max),
1161
          LMR_min);
1161
          LMR_min));
1162
      LMR[d][m] = Min(LMR[d][m], Max(d - 1 - LMR_rdepth, 0));
1162
      LMR[d][m] = Min(LMR[d][m], Max(d - 1 - LMR_rdepth, 0));
1163
    }
1163
    }
1164
}
1164
}
1165
 
1165
 
1166
/*
1166
/*