1
0

parallel-primes.c 882 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * The ENTIRE assignment should be completed within this file
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <math.h>
  8. #include <pthread.h>
  9. #include "pa06.h"
  10. /**
  11. * Read a uint128 from a string.
  12. * This function is provided for your convenience.
  13. */
  14. uint128 alphaTou128(const char * str)
  15. {
  16. uint128 ret = 0;
  17. while(*str >= '0' && *str <= '9') {
  18. ret *= 10; // "left-shift" a base-ten number
  19. ret += (*str - '0'); // add in the units
  20. ++str;
  21. }
  22. return ret;
  23. }
  24. /**
  25. * The caller is responsible for freeing the result
  26. */
  27. char * u128ToString(uint128 value)
  28. {
  29. return NULL;
  30. }
  31. /**
  32. * Test is 'value' is prime.
  33. * 'n_threads' is the number of threads to create to complete this computation.
  34. * Return TRUE of FALSE.
  35. *
  36. * LEAK NO MEMORY
  37. *
  38. * Good luck!
  39. */
  40. int primalityTestParallel(uint128 value, int n_threads)
  41. {
  42. return FALSE;
  43. }