Example #1
0
int main(void)
{
    //control the main work flow
    result_txt = fopen("./result.txt", "w+");
    log_txt = fopen("./log.txt", "w+");
    //read data:
    readData();
    readKeys();
    //omp section start
    omp_set_num_threads(core_number);
    //start parallel computing to calculate signatures for each column
#pragma omp parallel
    {
#pragma omp for
        for (int col = 499; col >= 0; col--)
        {
            calcSignatures(col);
        }
    }
    //omp section ends, all signatures are calculated into an array
    printf("%d columns have blocks, total block number is %ld\n", total_col_has_neighbours, total_block_number);
    fprintf(log_txt, "%d columns have blocks, total block number is %ld\n", total_col_has_neighbours, total_block_number);
    //sorting all signatures
    printf("\nQuick sorting all signatures...\n");
    fprintf(log_txt, "\nQuick sorting all signatures......\n");
    quicksort(signatures, 0, total_block_number);
    printf("Quick sorting finished! \n\nStart collision detecting...\n");
    fprintf(log_txt, "Quick sorting finished! \n\nStart collision detecting...\n");
    //compare sorted signatures, if they are equal then collisions are detected.
    int i = 0;
    while (i < total_block_number)
    {
        if (signatures[i] == signatures[i + 1] && correspond_col[i] != correspond_col[i + 1]) 
        {
            int last_same_index = i + 1;
            while (signatures[i] == signatures[last_same_index])
            {
                last_same_index += 1;
            }
            collision_number += 1;
            fprintf(result_txt, "Signature %ld -- block: M%d ,M%d, M%d, M%d -- collisions in columns: ", signatures[i], signatures_one[i], signatures_two[i], signatures_three[i], signatures_four[i]);
            for (int j = i; j < last_same_index && (i == j || correspond_col[i] != correspond_col[j]); j++)
            {
                fprintf(result_txt, "%d ", correspond_col[j]);
            }
            fprintf(result_txt, "\n");
            i = last_same_index;
        }
        else
        {
            i += 1;
        }
    }
    printf("%ld collisions are detected.\n", collision_number);
    fprintf(log_txt, "%ld collisions are detected.\n", collision_number);
    printf("\nLogs are recorded in the log.txt file.\n");
    printf("Collisions are recorded in the result.txt file.\n");
    fclose(result_txt);
    fclose(log_txt);
}
Example #2
0
bool Signatures::calcSignatureValues(vector<Node*> vNodes){

	if(!calcUpperValues(vNodes))
		return false;

	if(!calcLowValues(vNodes))
		return false;

	if(!calcSignatures(vNodes))
		return false;

	if(!calcd1d2(vNodes))
		return false;

	return true;
}