| 496 | void **serializedScore, |
| 497 | unsigned int *serializedScoreSize); |
| 498 | static ds_status writeProfileToFile(ds_profile *profile, |
| 499 | ds_score_serializer serializer, |
| 500 | const char *file) { |
| 501 | ds_status status = DS_SUCCESS; |
| 502 | |
| 503 | if (profile == NULL) return DS_INVALID_PROFILE; |
| 504 | |
| 505 | FILE *profileFile = fopen(file, "wb"); |
| 506 | if (profileFile == NULL) { |
| 507 | status = DS_FILE_ERROR; |
| 508 | } else { |
| 509 | unsigned int i; |
| 510 | |
| 511 | // write version string |
| 512 | fwrite(DS_TAG_VERSION, sizeof(char), strlen(DS_TAG_VERSION), profileFile); |
| 513 | fwrite(profile->version, sizeof(char), strlen(profile->version), |
| 514 | profileFile); |
| 515 | fwrite(DS_TAG_VERSION_END, sizeof(char), strlen(DS_TAG_VERSION_END), |
| 516 | profileFile); |
| 517 | fwrite("\n", sizeof(char), 1, profileFile); |
| 518 | |
| 519 | for (i = 0; i < profile->numDevices && status == DS_SUCCESS; i++) { |
| 520 | void *serializedScore; |
| 521 | unsigned int serializedScoreSize; |
| 522 | |
| 523 | fwrite(DS_TAG_DEVICE, sizeof(char), strlen(DS_TAG_DEVICE), profileFile); |
| 524 | |
| 525 | fwrite(DS_TAG_DEVICE_TYPE, sizeof(char), strlen(DS_TAG_DEVICE_TYPE), |
| 526 | profileFile); |
| 527 | fwrite(&profile->devices[i].type, sizeof(ds_device_type), 1, profileFile); |
| 528 | fwrite(DS_TAG_DEVICE_TYPE_END, sizeof(char), |
| 529 | strlen(DS_TAG_DEVICE_TYPE_END), profileFile); |
| 530 | |
| 531 | switch (profile->devices[i].type) { |
| 532 | case DS_DEVICE_NATIVE_CPU: { |
| 533 | // There's no need to emit a device name for the native CPU device. |
| 534 | /* |
| 535 | fwrite(DS_TAG_DEVICE_NAME, sizeof(char), strlen(DS_TAG_DEVICE_NAME), |
| 536 | profileFile); |
| 537 | fwrite(DS_DEVICE_NATIVE_CPU_STRING,sizeof(char), |
| 538 | strlen(DS_DEVICE_NATIVE_CPU_STRING), profileFile); |
| 539 | fwrite(DS_TAG_DEVICE_NAME_END, sizeof(char), |
| 540 | strlen(DS_TAG_DEVICE_NAME_END), profileFile); |
| 541 | */ |
| 542 | } break; |
| 543 | case DS_DEVICE_OPENCL_DEVICE: { |
| 544 | fwrite(DS_TAG_DEVICE_NAME, sizeof(char), strlen(DS_TAG_DEVICE_NAME), |
| 545 | profileFile); |
| 546 | fwrite(profile->devices[i].oclDeviceName, sizeof(char), |
| 547 | strlen(profile->devices[i].oclDeviceName), profileFile); |
| 548 | fwrite(DS_TAG_DEVICE_NAME_END, sizeof(char), |
| 549 | strlen(DS_TAG_DEVICE_NAME_END), profileFile); |
| 550 | |
| 551 | fwrite(DS_TAG_DEVICE_DRIVER_VERSION, sizeof(char), |
| 552 | strlen(DS_TAG_DEVICE_DRIVER_VERSION), profileFile); |
| 553 | fwrite(profile->devices[i].oclDriverVersion, sizeof(char), |
| 554 | strlen(profile->devices[i].oclDriverVersion), profileFile); |
| 555 | fwrite(DS_TAG_DEVICE_DRIVER_VERSION_END, sizeof(char), |