Skip to content

Commit

Permalink
Fixing osx build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Apr 12, 2024
1 parent bf5a820 commit ee30513
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/apex/apex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ uint64_t init(const char * thread_name, uint64_t comm_rank,
if (comm_rank == 0) {
printf("%s", apex_banner);
printf("APEX Version: %s\n", instance->version_string.c_str());
printf("Executing command line: %s\n", proc_data_reader::get_command_line().c_str());
printf("Executing command line: %s\n", getCommandLine().c_str());
}
FUNCTION_EXIT
return APEX_NOERROR;
Expand Down
9 changes: 6 additions & 3 deletions src/apex/profiler_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,11 @@ std::unordered_set<profile*> free_profiles;
thread_instance::instance(false);
std::unique_lock<std::mutex> task_map_lock(_mtx);
counter_scatterplot_samples << std::fixed
<< std::setprecision(0) << proc_data_reader::getPeriod()
<< " " << p.normalized_timestamp()
<< std::setprecision(0)
#ifdef APEX_HAVE_PROC
<< proc_data_reader::getPeriod() << " "
#endif
<< p.normalized_timestamp()
<< " " << std::setprecision(6) << p.elapsed() << " "
<< "'" << p.get_task_id()->get_name() << "'" << endl;
int loc0 = task_scatterplot_samples.tellp();
Expand Down Expand Up @@ -722,7 +725,7 @@ std::unordered_set<profile*> free_profiles;
// want to write it out
stringstream screen_output;
// iterate over the profiles in the address map
screen_output << endl << "Command line: " << proc_data_reader::get_command_line();
screen_output << endl << "Command line: " << getCommandLine();
screen_output << endl << "Start Date/Time: " << timestamp_started;
screen_output << endl << "Elapsed time: " << wall_clock_main
<< " seconds" << endl;
Expand Down
19 changes: 19 additions & 0 deletions src/apex/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <chrono>
#include <cstdarg>

#ifdef __APPLE__
#include <mach-o/dyld.h>
#endif

namespace apex {

/* Idea borrowed from:
Expand Down Expand Up @@ -764,6 +768,21 @@ std::vector<uint32_t> parseDiscreteValues(std::string inputString) {
return result;
}

std::string getCommandLine(void) {
#ifdef __APPLE__
char path[1024];
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0) {
std::string tmp{path};
return tmp;
}
#else
return proc_data_reader::get_command_line();
#endif
// just in case things failed
std::string tmp{"unknown"};
return tmp;
}

} // namespace apex

Expand Down
2 changes: 2 additions & 0 deletions src/apex/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ class in_apex {

void rank0_print(const char * fmt, ...);

std::string getCommandLine(void);

}

template <typename I>
Expand Down

0 comments on commit ee30513

Please sign in to comment.